From afe68f9cd860f202296daef406d1078db3127090 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 4 May 2020 11:43:47 +0200 Subject: [PATCH 001/192] psl1ght: Fix cores info path --- dist-scripts/dist-cores.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist-scripts/dist-cores.sh b/dist-scripts/dist-cores.sh index bc60c9bca6..a120bad14b 100755 --- a/dist-scripts/dist-cores.sh +++ b/dist-scripts/dist-cores.sh @@ -260,8 +260,8 @@ for f in `ls -v *_${platform}.${EXT}`; do if [ $platform = "psl1ght" ] ; then mv -fv ../retroarch_psl1ght.self ../pkg/psl1ght/pkg/USRDIR/cores/"${name}_libretro_${platform}.SELF" if [ -d ../../dist/info ]; then - mkdir -p ../pkg/psl1ght/USRDIR/cores/info - cp -fv ../../dist/info/"${name}_libretro.info" ../pkg/psl1ght/USRDIR/pkg/cores/info/"${name}_libretro.info" + mkdir -p ../pkg/psl1ght/pkg/USRDIR/cores/info + cp -fv ../../dist/info/"${name}_libretro.info" ../pkg/psl1ght/pkg/USRDIR/cores/info/"${name}_libretro.info" fi elif [ $platform = "ps3" ] ; then if [ $PLATFORM = "ode-ps3" ] ; then From 702bc181288af2de4be6d4db1dc511c55d31fdcc Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Mon, 4 May 2020 11:52:53 +0100 Subject: [PATCH 002/192] (3DS) Disable video filter if upscaled resolution exceeds hardware limits --- retroarch.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/retroarch.c b/retroarch.c index 223ad7c15e..be36eaf141 100644 --- a/retroarch.c +++ b/retroarch.c @@ -22555,6 +22555,21 @@ static void video_driver_init_filter(enum retro_pixel_format colfmt_int) pow2_x = next_pow2(width); pow2_y = next_pow2(height); maxsize = MAX(pow2_x, pow2_y); + +#ifdef _3DS + /* On 3DS, video is disabled if the output resolution + * exceeds 2048x2048. To avoid the user being presented + * with a black screen, we therefore have to check that + * the filter upscaling buffer fits within this limit. */ + if (maxsize >= 2048) + { + RARCH_ERR("[Video]: Softfilter initialization failed." + " Upscaling buffer exceeds hardware limitations.\n"); + video_driver_filter_free(); + return; + } +#endif + video_driver_state_scale = maxsize / RARCH_SCALE_BASE; video_driver_state_out_rgb32 = rarch_softfilter_get_output_format( video_driver_state_filter) == From a305a48a11a32c1bc19969c557e510ed6d6bd657 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Mon, 4 May 2020 16:56:41 +0100 Subject: [PATCH 003/192] (3DS) Fix font driver --- gfx/drivers_font/ctr_font.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gfx/drivers_font/ctr_font.c b/gfx/drivers_font/ctr_font.c index 3acc3e97b1..1726208675 100644 --- a/gfx/drivers_font/ctr_font.c +++ b/gfx/drivers_font/ctr_font.c @@ -243,7 +243,7 @@ static void ctr_font_render_line( GPU_TEVSOURCES(GPU_TEXTURE0, GPU_CONSTANT, 0), GPU_TEVSOURCES(GPU_TEXTURE0, GPU_CONSTANT, 0), 0, - GPU_TEVOPERANDS(GPU_TEVOP_RGB_SRC_R, GPU_TEVOP_RGB_SRC_ALPHA, 0), + GPU_TEVOPERANDS(GPU_TEVOP_RGB_SRC_ALPHA, 0, 0), GPU_MODULATE, GPU_MODULATE, color); @@ -329,7 +329,7 @@ static void ctr_font_render_message( return; } - line_height = scale / line_metrics->height; + line_height = (float)line_metrics->height * scale / (float)height; for (;;) { @@ -397,7 +397,7 @@ static void ctr_font_render_msg( b = FONT_COLOR_GET_BLUE(params->color); alpha = FONT_COLOR_GET_ALPHA(params->color); - color = params->color; + color = COLOR_ABGR(r, g, b, alpha); } else { @@ -412,10 +412,10 @@ static void ctr_font_render_msg( alpha = 255; color = COLOR_ABGR(r, g, b, alpha); - drop_x = -2; - drop_y = -2; - drop_mod = 0.3f; - drop_alpha = 1.0f; + drop_x = 1; + drop_y = -1; + drop_mod = 0.0f; + drop_alpha = 0.75f; } max_glyphs = strlen(msg); From 16d12e804cfea65ff6b189be5f480935e95b5c04 Mon Sep 17 00:00:00 2001 From: MrHuu Date: Tue, 5 May 2020 12:25:13 +0200 Subject: [PATCH 004/192] (3DS) re-Enable 7z support Adds missing HAVE_7ZIP definition for griffin builds. I have no issues with this. Browsing and loading .7z files works as it should. Unless there's a specific reason this was removed, it can be enabled. --- Makefile.ctr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.ctr b/Makefile.ctr index 83b3624a72..1eb4a1b386 100644 --- a/Makefile.ctr +++ b/Makefile.ctr @@ -51,7 +51,7 @@ DEFINES := ifeq ($(GRIFFIN_BUILD), 1) OBJ += griffin/griffin.o DEFINES += -DHAVE_GRIFFIN=1 -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_RGUI -DHAVE_XMB -DHAVE_MATERIALUI -DHAVE_LIBRETRODB -DHAVE_CC_RESAMPLER - DEFINES += -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA + DEFINES += -DHAVE_ZLIB -DHAVE_7ZIP -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA #DEFINES += -DHAVE_NETWORKING -DHAVE_CHEEVOS -DRC_DISABLE_LUA -DHAVE_SOCKET_LEGACY -DHAVE_THREADS #-DHAVE_SSL -DHAVE_BUILTINMBEDTLS -DMBEDTLS_SSL_DEBUG_ALL #ssl is currently incompatible with griffin due to use of the "static" flag on repeating functions that will conflict when included in one file From ca782bd015b5e6ef41f1669f3956944024d49879 Mon Sep 17 00:00:00 2001 From: Autechre Date: Wed, 6 May 2020 02:13:01 +0200 Subject: [PATCH 005/192] Update CHANGES.md --- CHANGES.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index a2175fb19d..d3a24c3d1b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,10 +1,39 @@ # Future + +# 1.8.6 +- 3DS: Add IDs for UZEM, TGB Dual, and NeoCD +- 3DS: Fix font driver horizontal text alignment +- 3DS: Allow button presses up to INPUT_MAX_USERS - this enables the 3DS to bind and use buttons and axis for users up to the maximum set by 'Max Users' in the input settings menu. +- 3DS: Disable video filter if upscaled resolution exceeds hardware limits. The 3DS has a maximum video buffer size of 2048x2048. This is sufficient for every core that it supports, but when using software video filters the core output resolution is doubled. This is made worse by the fact that the video filter upscaling buffer size is dependent upon the maximum output resolution of the core - which in some cases is very large indeed (e.g. pcsx-rearmed sets a maximum width of 1024, for enhanced resolution support). The 3DS has very limited 'linear memory' for graphics buffer purposes, and a large base core buffer + video filter buffer can easily exceed this - which may also disable video output, or cause a crash. + +This PR very simply adds a 3DS-specific check to the video filter initialisation: if the resultant upscaling buffer exceeds the hardware limitation, then the filter is automatically disabled. +- 3DS/FONT/BUGFIX: Text colour was wrong: the RGBA channels were muddled, and R was always set to 255 +- 3DS/FONT/BUGFIX: When drawing multiline strings, the line spacing was completely incorrect +- 3DS/FONT: Improves the appearance of the drop shadow effect on notification text. +- 3DS/ARCHIVE/7Z: Re-enable 7zip support. +- ARCHIVE/ZIP: Expand functionality of 'rzip_stream' interface. This PR expands the functionality of the new rzip_stream archived stream interface such that it now has almost complete feature parity with the standard file_stream interface, and can therefore be used as a drop-in replacement in most situations +- AI SERVICE: Hide redundant entries when service is disabled +- AI SERVICE: Added in auto-translate support +- AI SERVICE: support for NVDA and SAPI narration - AUTOCONFIG: Use correct port index in input device configured/disconnected notifications - BUGFIX: Fix race condition where task could momentarily not be in the queue when reordering - CHEEVOS/BUGFIX: Prevent null reference rendering achievement list while closing application - CHEEVOS/BUGFIX: Report non-memorymap GBA cores as unsupported +- COMMANDLINE: Advise against using -s and -S variables on the command line. … +- CONFIG FILE: Only write config files to disk when parameters change +- CONFIG FILE/BUGFIX: RetroArch no longer crashes when attempting to save a config file after 'unsetting' a parameter (currently, this can be triggered quite easily by manipulating input remaps) +- CONFIG FILE/BUGFIX: When using Material UI, RetroArch no longer modifies the wrong setting (or segfaults...) when tapping entries in the Quick Menu > Controls input remapping submenu +- CONFIG FILE/BUGFIX: Quite a few real and potential memory leaks have been fixed. - CHD: Fixes a crash caused by ignoring the return value from one of the CHD library functions +- FASTFORWARDING: A new Mute When Fast-Forwarding option has been added under Settings > Audio. When enabled, users can fast forward without having to listen to distorted audio. +- GLCORE/SLANG: Set filter and wrap mode correctly when intialising shader textures. Before, the glcore shader driver did not correctly initialise loaded textures. The texture filtering and wrap mode were forced on texture creation, but these settings were not recorded - subsequent updates would set garbage values, that would resolve to linear filtering OFF and wrap mode = CLAMP_TO_EDGE. +- LOCALIZATION: Update Japanese translation - LOCALIZATION: Update Spanish translation +- LOCALIZATION: Update Portuguese Brazilian translation +- IOS: Set audio session category to ambient so sound does not get cut off on interruption (phone call/playing back audio) +- MAC/IOHIDMANAGER/BUGFIX: Fix for Mayflash N64 adapter. In case last hatswitch does not match cookie. For the mayflash N64 adapter, I was getting a BAD EXC ADDRESS (in mac OS 10.13) for this line (tmp was NULL). Retroarch would crash in the gui if I pressed a button from the DPAD on controller 2. With this change, it no longer crashes in the gui and still registers the button push. +- MAC/COCOA: Fix mouse input - this brings back two lines of code that have been removed over time but +appear to be required in order for mouse input to work on macOS - METAL/BUGFIX: GPU capture on Metal/OSX/NVidia could crash - METAL/BUGFIX: Taking screenshots could capture black frames. Resulting PNG screenshots were black. - METAL/BUGFIX: Corrupted image due to incorrect viewport copy when taking screenshot @@ -16,13 +45,41 @@ - MENU/OZONE: Hide 'Menu Color Theme' setting when 'Use preferred system color theme' is enabled - MENU/OZONE: Fix thumbnail switching via 'scan' button functionality - MENU/OZONE: Prevent glitches when rendering Ozone's selection cursor +- MENU/OZONE: Enable proper vertical text alignment + thumbnail display improvements +- MENU/OZONE: Enable second thumbnail/content metadata toggle using RetroPad 'select' +- MENU/OZONE: Refactor footer display +- MENU/OZONE: Hide thumbnail button hints when viewing file browser lists +- MENU/OZONE/INPUT/BUGFIX: Fix undefined behaviour when using touch screen to change input remaps +- MENU/OZONE/INPUT/BUGFIX: It turns out that Windows reports negative pointer coordinates when the mouse cursor goes beyond the left hand edge of the RetroArch window (this doesn't happen on Linux, so I never encountered this issue before!). As a result, if Ozone is currently not showing the sidebar (menu depth > 1), moving the cursor off the left edge of the window generates a false positive 'cursor in sidebar' event - which breaks menu navigation, as described in #10419. With this PR, we now handle 'cursor in sidebar' status correctly in all cases +- MENU/OZONE/INPUT/BUGFIX: Pointer input is now correctly disabled when message boxes are displayed - MENU/XMB: Fix thumbnail switching via 'scan' button functionality - ODROID GO ADVANCE: Add DRM HW context driver - PSL1GHT: Initial port +- PSL1GHT/KEYBOARD: Implement PSL1GHT keyboard +- PLAYLIST/BUGFIX: Improve handling of 'broken' playlists - RetroArch will no longer segfault when attempting to run content via a playlist entry with missing path or core path fields. +- PLAYLIST/BUGFIX: Improve handling of 'broken' playlists - when a playlist entry has either core path and/or core name set to NULL, DETECT or an empty string, attempting to load content will fallback to the normal 'core selection' code (currently this happens only if both core path and core name are DETECT - this is wholly inadequate!) +- PLAYLIST/BUGFIX: RetroArch will no longer segfault when attempting to fetch content runtime information when core path is NULL +- PLAYLIST/BUGFIX: Core name + runtime info will only be displayed on playlists and in the Information submenu if both the core path and core name fields are 'valid' (i.e. not NULL or DETECT) +- PLAYLIST/BUGFIX: When handling entries with missing path fields, the menu sorting order now matches that of the playlist sorting order (at present, everything goes out of sync when paths are empty). Moreover, entries with missing path fields can now be 'selected', so users can remove them (currently, hitting A on such an entry immediately tries - and fails - to load the content, so the only way to remove the broken entry is via the Playlist Management > Clean Playlist feature) +- PLAYLIST: Add optional per-playlist alphabetical sorting +- PLAYLIST: Omit whitespace when writing compressed JSON format playlists +- PLAYLIST: Add optional playlist compression - QNX: Support analog sticks +- SAVESTATES: Add optional save state compression (enabled by default now) +- SRAM: Add optional save (SRAM) file compression - SCANNER: Prevent redundant playlist entries when handling M3U content - SCANNER/ANDROID: Fix content scanner being unable to identify certain games from CHD images (raw data sector/subcode) +- TASKS/BUGFIX: Fix task deadlocks +- TASKS/SCREENSHOT/BUGFIX: Fix heap-use-after-free error when widgets are disabled - TVOS: Disable overlays for tvOS, fix app icon +- VIDEO/WIDGETS/BUGFIX: The font ascender/descender metrics added in #10375 are now used to achieve 'pixel perfect' vertical text alignment +- VIDEO/WIDGETS/BUGFIX: Message queue text now uses its own dedicated font. Previously, a single (larger) font was used for all active widgets, and this was scaled down for message queue items. This 'squished' the text a little; more importantly, when using the stb font renderers (on Android. etc.) it caused ugly artefacts around the edges of glyphs due to pixel interpolation errors. Now that a correctly sized font is used, the message queue is always rendered cleanly. +- VIDEO/WIDGETS/BUGFIX: Previously, each widget font was 'flushed' (font_driver_flush()) at least once a frame. This is quite a slow operation. Now we only flush fonts if they have actually been used. +- VULKAN/BUGFIX: Fix display of statistics text +- UNIX/BUGFIX: Fix overflow when computing total memory on i386 +- WIIU/BUGFIX: Fix font driver horizontal text alignment +- WIIU/BUGFIX: Fix non-vertex coordinates in draws using tex shader +- WIIU/BUGFIX: Update and fix meta.xml file for the WiiU release. This change makes it so the information from the meta.xml file parsed for the WiiU's Homebrew Launcher is displayed properly. # 1.8.5 - 3DS: Keep the bottom screen hidden on sleep/wakeup. When the 3DS wakes back up after being closed, the bottom screen needs to be reinitialized. Adding the condition here will cause the screen to be turned on or off based on the state of ctr_bottom_screen_enabled, as you'd expect From 36802f713312dc16c93a7765cd4a1b0883db5a61 Mon Sep 17 00:00:00 2001 From: Autechre Date: Wed, 6 May 2020 02:13:22 +0200 Subject: [PATCH 006/192] Update CHANGES.md --- CHANGES.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d3a24c3d1b..42d9fad514 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,9 +4,7 @@ - 3DS: Add IDs for UZEM, TGB Dual, and NeoCD - 3DS: Fix font driver horizontal text alignment - 3DS: Allow button presses up to INPUT_MAX_USERS - this enables the 3DS to bind and use buttons and axis for users up to the maximum set by 'Max Users' in the input settings menu. -- 3DS: Disable video filter if upscaled resolution exceeds hardware limits. The 3DS has a maximum video buffer size of 2048x2048. This is sufficient for every core that it supports, but when using software video filters the core output resolution is doubled. This is made worse by the fact that the video filter upscaling buffer size is dependent upon the maximum output resolution of the core - which in some cases is very large indeed (e.g. pcsx-rearmed sets a maximum width of 1024, for enhanced resolution support). The 3DS has very limited 'linear memory' for graphics buffer purposes, and a large base core buffer + video filter buffer can easily exceed this - which may also disable video output, or cause a crash. - -This PR very simply adds a 3DS-specific check to the video filter initialisation: if the resultant upscaling buffer exceeds the hardware limitation, then the filter is automatically disabled. +- 3DS: Disable video filter if upscaled resolution exceeds hardware limits. The 3DS has a maximum video buffer size of 2048x2048. This is sufficient for every core that it supports, but when using software video filters the core output resolution is doubled. This is made worse by the fact that the video filter upscaling buffer size is dependent upon the maximum output resolution of the core - which in some cases is very large indeed (e.g. pcsx-rearmed sets a maximum width of 1024, for enhanced resolution support). The 3DS has very limited 'linear memory' for graphics buffer purposes, and a large base core buffer + video filter buffer can easily exceed this - which may also disable video output, or cause a crash. This PR very simply adds a 3DS-specific check to the video filter initialisation: if the resultant upscaling buffer exceeds the hardware limitation, then the filter is automatically disabled. - 3DS/FONT/BUGFIX: Text colour was wrong: the RGBA channels were muddled, and R was always set to 255 - 3DS/FONT/BUGFIX: When drawing multiline strings, the line spacing was completely incorrect - 3DS/FONT: Improves the appearance of the drop shadow effect on notification text. From ad34f4845b12564f096bcec2e093e178a968bccb Mon Sep 17 00:00:00 2001 From: Roet-Ivar Date: Thu, 7 May 2020 00:28:12 +0200 Subject: [PATCH 007/192] Added access to WiiU-formated storage to be browsed by RetroArch --- frontend/drivers/platform_wiiu.c | 5 +++++ wiiu/main.c | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/frontend/drivers/platform_wiiu.c b/frontend/drivers/platform_wiiu.c index 57c5a8d430..970d275077 100644 --- a/frontend/drivers/platform_wiiu.c +++ b/frontend/drivers/platform_wiiu.c @@ -61,6 +61,7 @@ #define WIIU_SD_PATH "sd:/" #define WIIU_USB_PATH "usb:/" +#define WIIU_STORAGE_USB_PATH "storage_usb:/" /** * The Wii U frontend driver, along with the main() method. @@ -188,6 +189,10 @@ static int frontend_wiiu_parse_drive_list(void *data, bool load_content) msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR), enum_idx, FILE_TYPE_DIRECTORY, 0, 0); + menu_entries_append_enum(list, WIIU_STORAGE_USB_PATH, + msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR), + enum_idx, + FILE_TYPE_DIRECTORY, 0, 0); #endif return 0; } diff --git a/wiiu/main.c b/wiiu/main.c index 1740460613..9a4039f5a1 100644 --- a/wiiu/main.c +++ b/wiiu/main.c @@ -22,6 +22,7 @@ #if defined(HAVE_IOSUHAX) && defined(HAVE_LIBFAT) #include #include +#include #include #endif @@ -54,7 +55,7 @@ static void fsdev_init(void); static void fsdev_exit(void); bool iosuhaxMount = 0; - +int fsaFd = -1; static int mcp_hook_fd = -1; /* HBL elf entry point */ @@ -204,7 +205,11 @@ void __mount_filesystems(void) { #ifdef HAVE_LIBFAT if(iosuhaxMount) + { fatInitDefault(); + fsaFd = IOSUHAX_FSA_Open(); + mount_fs("storage_usb", fsaFd, NULL, "/vol/storage_usb01"); + } else mount_sd_fat("sd"); #else @@ -224,6 +229,17 @@ void __unmount_filesystems(void) { fatUnmount("sd:"); fatUnmount("usb:"); + + IOSUHAX_sdio_disc_interface.shutdown(); + IOSUHAX_usb_disc_interface.shutdown(); + + unmount_fs("storage_usb"); + IOSUHAX_FSA_Close(fsaFd); + + if(mcp_hook_fd >= 0) + MCPHookClose(); + else + IOSUHAX_Close(); } else unmount_sd_fat("sd"); From 2f392f2260cdfa3339263a3ecbb594c9f00db43c Mon Sep 17 00:00:00 2001 From: meleu Date: Thu, 7 May 2020 14:28:15 -0300 Subject: [PATCH 008/192] retroarch.cfg: add cheevos related configs --- retroarch.cfg | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/retroarch.cfg b/retroarch.cfg index 2454b1bd62..2f20ebe700 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -845,6 +845,41 @@ # will be extracted to this directory. # cache_directory = +#### RetroAchievements + +# Enable the RetroAchievements feature. +# cheevos_enable = false + +# RetroAchievements.org credentials. +# cheevos_username = +# cheevos_password = + +# The hardcore mode disables savestates and cheating features, but it +# makes the achievements points double. +# cheevos_hardcore_mode_enable = false + +# Show RetroAchievements related messages right after loading a game, such as +# successfull login and the number of cheevos you have unlocked for the game. +# cheevos_verbose_enable = false + +# Show achievements' badges in Quick Menu > Achievements List. +# (note: has no effect if menu_driver = rgui). +# cheevos_badges_enable = false + +# Take a screenshot when an achievement is triggered. +# cheevos_auto_screenshot = false + +# Besides achievements, some games also have leaderboards, where you can +# compete for high-scores, speedruns, etc. +# cheevos_leaderboards_enable = false + +# Send some messages to the RetroAchievements.org saying, for example, +# where you are in the game, how many lives you have, your score, etc. +# cheevos_richpresence_enable = false + +# Unnoficial achievements are used only for achievement creators and testers. +# cheevos_test_unofficial = false + #### Misc # Enable rewinding. This will take a performance hit when playing, so it is disabled by default. @@ -913,3 +948,4 @@ # Enable device vibration for supported cores # enable_device_vibration = false + From 33cf0e160c2987f6b790ef29aa02d6c2e417e9e2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 7 May 2020 20:13:02 +0200 Subject: [PATCH 009/192] Style nits --- frontend/drivers/platform_wiiu.c | 10 ++-- wiiu/main.c | 79 ++++++++++++++------------------ 2 files changed, 40 insertions(+), 49 deletions(-) diff --git a/frontend/drivers/platform_wiiu.c b/frontend/drivers/platform_wiiu.c index 970d275077..efa677e130 100644 --- a/frontend/drivers/platform_wiiu.c +++ b/frontend/drivers/platform_wiiu.c @@ -80,7 +80,8 @@ static bool exists(char *path) return (stat(path, &stat_buf) == 0); } -static void fix_asset_directory(void) { +static void fix_asset_directory(void) +{ char src_path_buf[PATH_MAX_LENGTH] = {0}; char dst_path_buf[PATH_MAX_LENGTH] = {0}; @@ -190,16 +191,15 @@ static int frontend_wiiu_parse_drive_list(void *data, bool load_content) enum_idx, FILE_TYPE_DIRECTORY, 0, 0); menu_entries_append_enum(list, WIIU_STORAGE_USB_PATH, - msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR), - enum_idx, - FILE_TYPE_DIRECTORY, 0, 0); + msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR), + enum_idx, + FILE_TYPE_DIRECTORY, 0, 0); #endif return 0; } static void frontend_wiiu_exec(const char *path, bool should_load_content) { - struct { u32 magic; diff --git a/wiiu/main.c b/wiiu/main.c index 9a4039f5a1..c6d10f3e2b 100644 --- a/wiiu/main.c +++ b/wiiu/main.c @@ -54,8 +54,8 @@ void __init(void); static void fsdev_init(void); static void fsdev_exit(void); -bool iosuhaxMount = 0; -int fsaFd = -1; +bool iosuhaxMount = 0; +int fsaFd = -1; static int mcp_hook_fd = -1; /* HBL elf entry point */ @@ -91,10 +91,7 @@ void _start(int argc, char **argv) exit(0); } -void __eabi(void) -{ - -} +void __eabi(void) { } __attribute__((weak)) void __init(void) @@ -103,9 +100,8 @@ void __init(void) extern void (*const __CTOR_END__)(void); void (*const *ctor)(void) = &__CTOR_LIST__; - while (ctor < &__CTOR_END__) { + while (ctor < &__CTOR_END__) (*ctor++)(); - } } __attribute__((weak)) @@ -115,30 +111,27 @@ void __fini(void) extern void (*const __DTOR_END__)(void); void (*const *dtor)(void) = &__DTOR_LIST__; - while (dtor < &__DTOR_END__) { + while (dtor < &__DTOR_END__) (*dtor++)(); - } } /* libiosuhax related */ -//just to be able to call async -void someFunc(void *arg) -{ - (void)arg; -} +/* just to be able to call async */ +static void some_func(void *arg) { (void)arg; } #ifdef HAVE_IOSUHAX int MCPHookOpen(void) { - //take over mcp thread + /* take over mcp thread */ mcp_hook_fd = IOS_Open("/dev/mcp", 0); if (mcp_hook_fd < 0) return -1; - IOS_IoctlAsync(mcp_hook_fd, 0x62, (void *)0, 0, (void *)0, 0, someFunc, (void *)0); - //let wupserver start up + IOS_IoctlAsync(mcp_hook_fd, 0x62, (void *)0, 0, + (void *)0, 0, some_func, (void *)0); + /* let wupserver start up */ usleep(1000); if (IOSUHAX_Open("/dev/mcp") < 0) @@ -156,24 +149,26 @@ void MCPHookClose(void) if (mcp_hook_fd < 0) return; - //close down wupserver, return control to mcp + /* close down wupserver, return control to mcp */ IOSUHAX_Close(); - //wait for mcp to return + /* wait for mcp to return */ usleep(1000); IOS_Close(mcp_hook_fd); mcp_hook_fd = -1; } -#endif //HAVE_IOSUHAX +#endif /* HAVE_IOSUHAX */ static bool try_init_iosuhax(void) { #ifdef HAVE_IOSUHAX int result = IOSUHAX_Open(NULL); - if(result < 0) + if (result < 0) result = MCPHookOpen(); - return (result < 0) ? false : true; -#else //don't HAVE_IOSUHAX + if (result < 0) + return false; + return true; +#else /* don't HAVE_IOSUHAX */ return false; #endif } @@ -181,13 +176,13 @@ static bool try_init_iosuhax(void) static void try_shutdown_iosuhax(void) { #ifdef HAVE_IOSUHAX - if(!iosuhaxMount) - return; + if (!iosuhaxMount) + return; if (mcp_hook_fd >= 0) - MCPHookClose(); + MCPHookClose(); else - IOSUHAX_Close(); + IOSUHAX_Close(); #endif //HAVE_IOSUHAX iosuhaxMount = false; @@ -204,17 +199,15 @@ __attribute__((weak)) void __mount_filesystems(void) { #ifdef HAVE_LIBFAT - if(iosuhaxMount) + if (iosuhaxMount) { fatInitDefault(); fsaFd = IOSUHAX_FSA_Open(); mount_fs("storage_usb", fsaFd, NULL, "/vol/storage_usb01"); - } - else - mount_sd_fat("sd"); -#else - mount_sd_fat("sd"); + return; + } #endif + mount_sd_fat("sd"); } /** @@ -229,23 +222,21 @@ void __unmount_filesystems(void) { fatUnmount("sd:"); fatUnmount("usb:"); - + IOSUHAX_sdio_disc_interface.shutdown(); IOSUHAX_usb_disc_interface.shutdown(); unmount_fs("storage_usb"); IOSUHAX_FSA_Close(fsaFd); - - if(mcp_hook_fd >= 0) - MCPHookClose(); - else - IOSUHAX_Close(); + + if (mcp_hook_fd >= 0) + MCPHookClose(); + else + IOSUHAX_Close(); + return; } - else - unmount_sd_fat("sd"); -#else - unmount_sd_fat("sd"); #endif + unmount_sd_fat("sd"); } static void fsdev_init(void) From ad7612eef3afcdc719cfa7123d505c5c93358989 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 7 May 2020 20:23:14 +0200 Subject: [PATCH 010/192] (wiiu) Style nit cleanups --- wiiu/hbl.c | 88 ++++++++++++------------- wiiu/shader_utils.c | 46 ++++++++------ wiiu/slang/main.c | 6 +- wiiu/slang/slang-parse.cpp | 127 ++++++++++++++++++++----------------- 4 files changed, 146 insertions(+), 121 deletions(-) diff --git a/wiiu/hbl.c b/wiiu/hbl.c index f610599359..5024fe1746 100644 --- a/wiiu/hbl.c +++ b/wiiu/hbl.c @@ -68,18 +68,18 @@ static const memory_values_t mem_vals_540[] = static inline void memoryAddArea(int start, int end, int cur_index) { - /* Create and copy new memory area */ - s_mem_area * mem_area = MEM_AREA_TABLE; - mem_area[cur_index].address = start; - mem_area[cur_index].size = end - start; - mem_area[cur_index].next = 0; + /* Create and copy new memory area */ + s_mem_area *mem_area = MEM_AREA_TABLE; - /* Fill pointer to this area in the previous area */ - if (cur_index > 0) - { - mem_area[cur_index - 1].next = &mem_area[cur_index]; - } + mem_area[cur_index].address = start; + mem_area[cur_index].size = end - start; + mem_area[cur_index].next = 0; + + /* Fill pointer to this area in the previous area */ + if (cur_index > 0) + mem_area[cur_index - 1].next = &mem_area[cur_index]; } + void *getApplicationEndAddr(void) { extern u32 _end[]; @@ -200,43 +200,45 @@ static int HomebrewCopyMemory(u8 *address, u32 bytes, u32 args_size) */ void log_rpx(const char *filepath, unsigned char *buf, size_t len) { - unsigned int line_buffer[LINE_LEN]; - int i, offset; + unsigned int line_buffer[LINE_LEN]; + int i, offset; - RARCH_LOG("=== BEGIN file=%s size=%d ===\n", filepath, len); - for(i = 0; i < len; i++) - { - offset = i % LINE_LEN; - line_buffer[offset] = buf[i]; + RARCH_LOG("=== BEGIN file=%s size=%d ===\n", filepath, len); + + for (i = 0; i < len; i++) + { + offset = i % LINE_LEN; + line_buffer[offset] = buf[i]; + + if(offset == (LINE_LEN-1)) + { + RARCH_LOG("%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", + line_buffer[0], line_buffer[1], line_buffer[2], line_buffer[3], + line_buffer[4], line_buffer[5], line_buffer[6], line_buffer[7], + line_buffer[8], line_buffer[9], line_buffer[10], line_buffer[11], + line_buffer[12], line_buffer[13], line_buffer[14], line_buffer[15], + line_buffer[16], line_buffer[17], line_buffer[18], line_buffer[19], + line_buffer[20], line_buffer[21], line_buffer[22], line_buffer[23], + line_buffer[24], line_buffer[25], line_buffer[26], line_buffer[27], + line_buffer[28], line_buffer[29], line_buffer[30], line_buffer[31]); + } + } + if((len % LINE_LEN) != 0) + { + for (i = (LINE_LEN - (len % LINE_LEN)); i < LINE_LEN; i++) + line_buffer[i] = 0; - if(offset == (LINE_LEN-1)) { RARCH_LOG("%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", - line_buffer[0], line_buffer[1], line_buffer[2], line_buffer[3], - line_buffer[4], line_buffer[5], line_buffer[6], line_buffer[7], - line_buffer[8], line_buffer[9], line_buffer[10], line_buffer[11], - line_buffer[12], line_buffer[13], line_buffer[14], line_buffer[15], - line_buffer[16], line_buffer[17], line_buffer[18], line_buffer[19], - line_buffer[20], line_buffer[21], line_buffer[22], line_buffer[23], - line_buffer[24], line_buffer[25], line_buffer[26], line_buffer[27], - line_buffer[28], line_buffer[29], line_buffer[30], line_buffer[31]); - } - } - if((len % LINE_LEN) != 0) { - for(i = (LINE_LEN - (len % LINE_LEN)); i < LINE_LEN; i++) - { - line_buffer[i] = 0; - } - RARCH_LOG("%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", - line_buffer[0], line_buffer[1], line_buffer[2], line_buffer[3], - line_buffer[4], line_buffer[5], line_buffer[6], line_buffer[7], - line_buffer[8], line_buffer[9], line_buffer[10], line_buffer[11], - line_buffer[16], line_buffer[17], line_buffer[18], line_buffer[19], - line_buffer[20], line_buffer[21], line_buffer[22], line_buffer[23], - line_buffer[24], line_buffer[25], line_buffer[26], line_buffer[27], - line_buffer[28], line_buffer[29], line_buffer[30], line_buffer[31]); + line_buffer[0], line_buffer[1], line_buffer[2], line_buffer[3], + line_buffer[4], line_buffer[5], line_buffer[6], line_buffer[7], + line_buffer[8], line_buffer[9], line_buffer[10], line_buffer[11], + line_buffer[16], line_buffer[17], line_buffer[18], line_buffer[19], + line_buffer[20], line_buffer[21], line_buffer[22], line_buffer[23], + line_buffer[24], line_buffer[25], line_buffer[26], line_buffer[27], + line_buffer[28], line_buffer[29], line_buffer[30], line_buffer[31]); - } - RARCH_LOG("=== END %s ===\n", filepath); + } + RARCH_LOG("=== END %s ===\n", filepath); } diff --git a/wiiu/shader_utils.c b/wiiu/shader_utils.c index 402a414e3b..143c6977cb 100644 --- a/wiiu/shader_utils.c +++ b/wiiu/shader_utils.c @@ -100,18 +100,20 @@ void GX2SetShader(GX2Shader *shader) void dump_vs_data(GX2VertexShader* vs) { + unsigned i; DEBUG_INT(vs->size); DEBUG_VAR(vs->mode); DEBUG_INT(vs->uniformBlockCount); - for(int i = 0; i < vs->uniformBlockCount; i++) + + for (i = 0; i < vs->uniformBlockCount; i++) { DEBUG_STR(vs->uniformBlocks[i].name); DEBUG_INT(vs->uniformBlocks[i].offset); DEBUG_INT(vs->uniformBlocks[i].size); } DEBUG_INT(vs->uniformVarCount); - for(int i = 0; i < vs->uniformVarCount; i++) + for (i = 0; i < vs->uniformVarCount; i++) { DEBUG_STR(vs->uniformVars[i].name); DEBUG_INT(vs->uniformVars[i].offset); @@ -120,7 +122,7 @@ void dump_vs_data(GX2VertexShader* vs) DEBUG_INT(vs->uniformVars[i].block); } DEBUG_INT(vs->initialValueCount); - for(int i = 0; i < vs->initialValueCount; i++) + for (i = 0; i < vs->initialValueCount; i++) { DEBUG_INT(vs->initialValues[i].offset); DEBUG_FLOAT(vs->initialValues[i].value[0]); @@ -129,20 +131,20 @@ void dump_vs_data(GX2VertexShader* vs) DEBUG_FLOAT(vs->initialValues[i].value[3]); } DEBUG_INT(vs->loopVarCount); - for(int i = 0; i < vs->loopVarCount; i++) + for (i = 0; i < vs->loopVarCount; i++) { DEBUG_INT(vs->loopVars[i].offset); DEBUG_VAR(vs->loopVars[i].value); } DEBUG_INT(vs->samplerVarCount); - for(int i = 0; i < vs->samplerVarCount; i++) + for (i = 0; i < vs->samplerVarCount; i++) { DEBUG_STR(vs->samplerVars[i].name); DEBUG_INT(vs->samplerVars[i].type); DEBUG_INT(vs->samplerVars[i].location); } - for(int i = 0; i < vs->attribVarCount; i++) + for (i = 0; i < vs->attribVarCount; i++) { DEBUG_STR(vs->attribVars[i].name); DEBUG_VAR(vs->attribVars[i].type); @@ -153,17 +155,19 @@ void dump_vs_data(GX2VertexShader* vs) void dump_ps_data(GX2PixelShader* ps) { + unsigned i; + DEBUG_INT(ps->size); DEBUG_VAR(ps->mode); DEBUG_INT(ps->uniformBlockCount); - for(int i = 0; i < ps->uniformBlockCount; i++) + for (i = 0; i < ps->uniformBlockCount; i++) { DEBUG_STR(ps->uniformBlocks[i].name); DEBUG_INT(ps->uniformBlocks[i].offset); DEBUG_INT(ps->uniformBlocks[i].size); } DEBUG_INT(ps->uniformVarCount); - for(int i = 0; i < ps->uniformVarCount; i++) + for (i = 0; i < ps->uniformVarCount; i++) { DEBUG_STR(ps->uniformVars[i].name); DEBUG_INT(ps->uniformVars[i].offset); @@ -172,7 +176,7 @@ void dump_ps_data(GX2PixelShader* ps) DEBUG_INT(ps->uniformVars[i].block); } DEBUG_INT(ps->initialValueCount); - for(int i = 0; i < ps->initialValueCount; i++) + for (i = 0; i < ps->initialValueCount; i++) { DEBUG_INT(ps->initialValues[i].offset); DEBUG_FLOAT(ps->initialValues[i].value[0]); @@ -181,13 +185,13 @@ void dump_ps_data(GX2PixelShader* ps) DEBUG_FLOAT(ps->initialValues[i].value[3]); } DEBUG_INT(ps->loopVarCount); - for(int i = 0; i < ps->loopVarCount; i++) + for (i = 0; i < ps->loopVarCount; i++) { DEBUG_INT(ps->loopVars[i].offset); DEBUG_VAR(ps->loopVars[i].value); } DEBUG_INT(ps->samplerVarCount); - for(int i = 0; i < ps->samplerVarCount; i++) + for (i = 0; i < ps->samplerVarCount; i++) { DEBUG_STR(ps->samplerVars[i].name); DEBUG_INT(ps->samplerVars[i].type); @@ -198,6 +202,8 @@ void dump_ps_data(GX2PixelShader* ps) void check_shader_verbose(u32 *shader, u32 shader_size, u32 *org, u32 org_size, const char *name) { + unsigned i; + printf("%s :\n", name); DEBUG_VAR(shader_size); DEBUG_VAR(org_size); @@ -205,14 +211,14 @@ void check_shader_verbose(u32 *shader, u32 shader_size, u32 *org, u32 org_size, if (shader_size != org_size) printf("size mismatch : 0x%08X should be 0x%08X\n", shader_size, org_size); - for (int i = 0; i < shader_size / 4; i += 4) + for (i = 0; i < shader_size / 4; i += 4) { printf("0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\n", shader[i], shader[i + 1], shader[i + 2], shader[i + 3], org[i], org[i + 1], org[i + 2], org[i + 3]); } - for (int i = 0; i < shader_size / 4; i++) + for (i = 0; i < shader_size / 4; i++) { if (shader[i] != org[i]) printf("%i(%X): 0x%08X(0x%08X) should be 0x%08X(0x%08X) \n", i, i, shader[i], __builtin_bswap32(shader[i]), org[i], @@ -221,9 +227,11 @@ void check_shader_verbose(u32 *shader, u32 shader_size, u32 *org, u32 org_size, } void check_shader(const void *shader_, u32 shader_size, const void *org_, u32 org_size, const char *name) { - u32 *shader = (u32 *)shader_; - u32 *org = (u32 *)org_; + unsigned i; bool different = false; + u32 *shader = (u32 *)shader_; + u32 *org = (u32 *)org_; + printf("%-20s : ", name); if (shader_size != org_size) @@ -232,7 +240,7 @@ void check_shader(const void *shader_, u32 shader_size, const void *org_, u32 or printf("\nsize mismatch : 0x%08X should be 0x%08X", shader_size, org_size); } - for (int i = 0; i < shader_size / 4; i++) + for (i = 0; i < shader_size / 4; i++) { if (shader[i] != org[i]) { @@ -327,7 +335,7 @@ void gfd_free(GFDFile* gfd) static bool gfd_relocate_block(GFDBlock* block) { - + unsigned i; GFDRelocationHeader* rel = (GFDRelocationHeader*)(block->data + block->header.dataSize) - 1; if (rel->magic != GFD_BLOCK_RELOCATIONS_MAGIC) @@ -344,7 +352,7 @@ static bool gfd_relocate_block(GFDBlock* block) u32* patches = (u32*)(block->data + (rel->patchOffset & GFD_RELOCATIONS_VALUE_MASK)); - for(int i=0; i < rel->patchCount; i++) + for (i = 0; i < rel->patchCount; i++) { if(patches[i]) { @@ -371,7 +379,7 @@ static bool gfd_relocate_block(GFDBlock* block) GFDFile *gfd_open(const char *filename) { GFDFile* gfd = calloc(1, sizeof(*gfd)); - FILE *fp = fopen(filename, "rb"); + FILE *fp = fopen(filename, "rb"); if (!fp) goto error; diff --git a/wiiu/slang/main.c b/wiiu/slang/main.c index f8e6f9808e..c81d2d21c2 100644 --- a/wiiu/slang/main.c +++ b/wiiu/slang/main.c @@ -74,8 +74,10 @@ int main(int argc, const char** argv) *next++ = '\0'; -// while((*next == '\n') || (*next == '\r')) -// *next++ = '\0'; +#if 0 + while((*next == '\n') || (*next == '\r')) + *next++ = '\0'; +#endif if(strstr(line, "#version")) continue; diff --git a/wiiu/slang/slang-parse.cpp b/wiiu/slang/slang-parse.cpp index f5bdfef3c6..659969708f 100644 --- a/wiiu/slang/slang-parse.cpp +++ b/wiiu/slang/slang-parse.cpp @@ -6,6 +6,7 @@ int main(int argc, const char** argv) { + unsigned i; const char* slang_fn = NULL; const char* vs_asm_fn = NULL; const char* ps_asm_fn = NULL; @@ -13,7 +14,7 @@ int main(int argc, const char** argv) const char* ps_out_fn = NULL; bool verbose = false; - for(int i = 1; i < argc - 1; i++) + for (i = 1; i < argc - 1; i++) { if(!strcmp(argv[i], "--slang")) slang_fn = argv[++i]; @@ -92,10 +93,14 @@ int main(int argc, const char** argv) common << "#define float2 vec2\n"; common << "#define float3 vec3\n"; common << "#define float4 vec4\n"; - for (std::shared_ptr &node : ast->nodes) { - if (node->name == "Version") { + for (std::shared_ptr &node : ast->nodes) + { + if (node->name == "Version") + { /* do nothing */ - } else if (node->name == "UniformBlock") { + } + else if (node->name == "UniformBlock") + { int location = 0; int binding = 0; int set = 0; @@ -110,33 +115,37 @@ int main(int argc, const char** argv) }; std::vector members; - for (std::shared_ptr &child : node->nodes) { - if (child->name == "Layout") { - for (std::shared_ptr &layout : child->nodes) { - if (layout->name == "PushConstant") { + for (std::shared_ptr &child : node->nodes) + { + if (child->name == "Layout") + { + for (std::shared_ptr &layout : child->nodes) + { + if (layout->name == "PushConstant") push_constant = true; - } else if (layout->name == "Location") { + else if (layout->name == "Location") location = std::stoul(layout->token); - } else if (layout->name == "Binding") { + else if (layout->name == "Binding") binding = std::stoul(layout->token); - } else if (layout->name == "Set") { + else if (layout->name == "Set") set = std::stoul(layout->token); - } else if (layout->name == "Std") { + else if (layout->name == "Std") std_val = std::stoul(layout->token); - } } - } else if (child->name == "StructName") { + } + else if (child->name == "StructName") struct_name = child->token; - } else if (child->name == "Name") { + else if (child->name == "Name") name = child->token; - } else if (child->name == "Member") { + else if (child->name == "Member") + { member_type new_member; - for (std::shared_ptr &member : child->nodes) { - if (member->name == "Type") { + for (std::shared_ptr &member : child->nodes) + { + if (member->name == "Type") new_member.type = member->token; - } else if (member->name == "Name") { + else if (member->name == "Name") new_member.name = member->token; - } } members.push_back(new_member); } @@ -152,12 +161,13 @@ int main(int argc, const char** argv) *out << "layout(std" << std_val << ") "; #endif *out << "uniform " << struct_name << "\n{\n"; - for(member_type &member : members) { + for (member_type &member : members) *out << " " << member.type << " " << member.name << ";\n"; - } *out << "}" << name << ";"; - } else if (node->name == "Declaration") { + } + else if (node->name == "Declaration") + { int location = 0; int binding = 0; int set = 0; @@ -167,54 +177,55 @@ int main(int argc, const char** argv) int array_size = 0; bool has_layout = false; - for (std::shared_ptr &child : node->nodes) { - if (child->name == "Layout") { + for (std::shared_ptr &child : node->nodes) + { + if (child->name == "Layout") + { has_layout = true; - for (std::shared_ptr &layout : child->nodes) { - if (layout->name == "Location") { + for (std::shared_ptr &layout : child->nodes) + { + if (layout->name == "Location") location = std::stoul(layout->token); - } else if (layout->name == "Binding") { + else if (layout->name == "Binding") binding = std::stoul(layout->token); - } else if (layout->name == "Set") { + else if (layout->name == "Set") set = std::stoul(layout->token); - } } - } else if (child->name == "Qualifier") { - qualifier = child->token; - } else if (child->name == "Type") { - type = child->token; - } else if (child->name == "Name") { - name = child->token; - }else if (child->name == "ArraySize") { - array_size = std::stoul(child->token); } + else if (child->name == "Qualifier") + qualifier = child->token; + else if (child->name == "Type") + type = child->token; + else if (child->name == "Name") + name = child->token; + else if (child->name == "ArraySize") + array_size = std::stoul(child->token); } if(has_layout && type != "sampler2D") - { *out << "layout(location = " << location << ") "; - } *out << qualifier << " " << type << " " << name; if(array_size) *out << "[" << array_size << "]"; *out << ";"; - - } else if (node->name == "ConstArray") { + } + else if (node->name == "ConstArray") + { std::string type; std::string name; int array_size = 0; std::vector>* array; - for (std::shared_ptr &child : node->nodes) { - if (child->name == "Type") { + for (std::shared_ptr &child : node->nodes) + { + if (child->name == "Type") type = child->token; - } else if (child->name == "Name") { + else if (child->name == "Name") name = child->token; - } else if (child->name == "ArraySize") { + else if (child->name == "ArraySize") array_size = std::stoul(child->token); - } else if (child->name == "Array") { + else if (child->name == "Array") array = &child->nodes; - } } *out << type << " " << name; if(array_size) @@ -223,7 +234,8 @@ int main(int argc, const char** argv) if(array_size) *out << "[" << array_size << "]"; *out << "("; - for (std::shared_ptr &item : *array) { + for (std::shared_ptr &item : *array) + { if(array_size) *out << type << "("; *out << item->token; @@ -233,21 +245,22 @@ int main(int argc, const char** argv) *out << ", "; } *out << ");"; - - } else if (node->name == "Stage") { + } + else if (node->name == "Stage") + { std::string stage = node->token; std::transform(stage.begin(), stage.end(), stage.begin(), ::toupper); if(stage == "VERTEX") out = &vs; else out = &ps; - } else if (node->name == "Indent"){ - *out << node->token; - } else if (node->name == "Line"){ - *out << node->token << std::endl; - } else { - std::cout << "Unexcpected node " << node->name << std::endl; } + else if (node->name == "Indent") + *out << node->token; + else if (node->name == "Line") + *out << node->token << std::endl; + else + std::cout << "Unexcpected node " << node->name << std::endl; } { From e1d0514ec56140dc573af8f599a4e7ebd34dc4d9 Mon Sep 17 00:00:00 2001 From: francescotintori Date: Thu, 7 May 2020 23:03:54 +0200 Subject: [PATCH 011/192] Added VS2019 solution project (copied from VS2017) --- pkg/msvc/RetroArch-msvc2019.sln | 115 + pkg/msvc/msvc-2019/RetroArch-msvc2019.vcxproj | 2567 +++++++++++++++++ .../RetroArch-msvc2019.vcxproj.filters | 42 + pkg/msvc/msvc-2019/readme-build-qt.txt | 22 + 4 files changed, 2746 insertions(+) create mode 100644 pkg/msvc/RetroArch-msvc2019.sln create mode 100644 pkg/msvc/msvc-2019/RetroArch-msvc2019.vcxproj create mode 100644 pkg/msvc/msvc-2019/RetroArch-msvc2019.vcxproj.filters create mode 100644 pkg/msvc/msvc-2019/readme-build-qt.txt diff --git a/pkg/msvc/RetroArch-msvc2019.sln b/pkg/msvc/RetroArch-msvc2019.sln new file mode 100644 index 0000000000..41093bf6ce --- /dev/null +++ b/pkg/msvc/RetroArch-msvc2019.sln @@ -0,0 +1,115 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28803.452 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RetroArch-msvc2019", "msvc-2019\RetroArch-msvc2019.vcxproj", "{27FF7CE1-4059-4AA1-8062-FD529560FA54}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug Cg|ARM = Debug Cg|ARM + Debug Cg|ARM64 = Debug Cg|ARM64 + Debug Cg|x64 = Debug Cg|x64 + Debug Cg|x86 = Debug Cg|x86 + Debug QT|ARM = Debug QT|ARM + Debug QT|ARM64 = Debug QT|ARM64 + Debug QT|x64 = Debug QT|x64 + Debug QT|x86 = Debug QT|x86 + Debug QT+CG|ARM = Debug QT+CG|ARM + Debug QT+CG|ARM64 = Debug QT+CG|ARM64 + Debug QT+CG|x64 = Debug QT+CG|x64 + Debug QT+CG|x86 = Debug QT+CG|x86 + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release Cg|ARM = Release Cg|ARM + Release Cg|ARM64 = Release Cg|ARM64 + Release Cg|x64 = Release Cg|x64 + Release Cg|x86 = Release Cg|x86 + Release QT|ARM = Release QT|ARM + Release QT|ARM64 = Release QT|ARM64 + Release QT|x64 = Release QT|x64 + Release QT|x86 = Release QT|x86 + Release QT+CG|ARM = Release QT+CG|ARM + Release QT+CG|ARM64 = Release QT+CG|ARM64 + Release QT+CG|x64 = Release QT+CG|x64 + Release QT+CG|x86 = Release QT+CG|x86 + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug Cg|ARM.ActiveCfg = Debug Cg|ARM + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug Cg|ARM.Build.0 = Debug Cg|ARM + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug Cg|ARM64.ActiveCfg = Debug Cg|ARM64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug Cg|ARM64.Build.0 = Debug Cg|ARM64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug Cg|x64.ActiveCfg = Debug Cg|x64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug Cg|x64.Build.0 = Debug Cg|x64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug Cg|x86.ActiveCfg = Debug Cg|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug Cg|x86.Build.0 = Debug Cg|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug QT|ARM.ActiveCfg = Debug QT|ARM + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug QT|ARM.Build.0 = Debug QT|ARM + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug QT|ARM64.ActiveCfg = Debug QT|ARM64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug QT|ARM64.Build.0 = Debug QT|ARM64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug QT|x64.ActiveCfg = Debug QT|x64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug QT|x64.Build.0 = Debug QT|x64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug QT|x86.ActiveCfg = Debug QT|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug QT|x86.Build.0 = Debug QT|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug QT+CG|ARM.ActiveCfg = Debug QT+CG|ARM + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug QT+CG|ARM.Build.0 = Debug QT+CG|ARM + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug QT+CG|ARM64.ActiveCfg = Debug QT+CG|ARM64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug QT+CG|ARM64.Build.0 = Debug QT+CG|ARM64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug QT+CG|x64.ActiveCfg = Debug QT+CG|x64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug QT+CG|x64.Build.0 = Debug QT+CG|x64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug QT+CG|x86.ActiveCfg = Debug QT+CG|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug QT+CG|x86.Build.0 = Debug QT+CG|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug|ARM.ActiveCfg = Debug|ARM + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug|ARM.Build.0 = Debug|ARM + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug|ARM64.Build.0 = Debug|ARM64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug|x64.ActiveCfg = Debug|x64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug|x64.Build.0 = Debug|x64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug|x86.ActiveCfg = Debug|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug|x86.Build.0 = Debug|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release Cg|ARM.ActiveCfg = Release Cg|ARM + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release Cg|ARM.Build.0 = Release Cg|ARM + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release Cg|ARM64.ActiveCfg = Release Cg|ARM64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release Cg|ARM64.Build.0 = Release Cg|ARM64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release Cg|x64.ActiveCfg = Release Cg|x64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release Cg|x64.Build.0 = Release Cg|x64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release Cg|x86.ActiveCfg = Release Cg|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release Cg|x86.Build.0 = Release Cg|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release QT|ARM.ActiveCfg = Release QT|ARM + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release QT|ARM.Build.0 = Release QT|ARM + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release QT|ARM64.ActiveCfg = Release QT|ARM64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release QT|ARM64.Build.0 = Release QT|ARM64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release QT|x64.ActiveCfg = Release QT|x64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release QT|x64.Build.0 = Release QT|x64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release QT|x86.ActiveCfg = Release QT|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release QT|x86.Build.0 = Release QT|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release QT+CG|ARM.ActiveCfg = Release QT+CG|ARM + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release QT+CG|ARM.Build.0 = Release QT+CG|ARM + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release QT+CG|ARM64.ActiveCfg = Release QT+CG|ARM64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release QT+CG|ARM64.Build.0 = Release QT+CG|ARM64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release QT+CG|x64.ActiveCfg = Release QT+CG|x64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release QT+CG|x64.Build.0 = Release QT+CG|x64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release QT+CG|x86.ActiveCfg = Release QT+CG|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release QT+CG|x86.Build.0 = Release QT+CG|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release|ARM.ActiveCfg = Release|ARM + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release|ARM.Build.0 = Release|ARM + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release|ARM64.ActiveCfg = Release|ARM64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release|ARM64.Build.0 = Release|ARM64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release|x64.ActiveCfg = Release|x64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release|x64.Build.0 = Release|x64 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release|x86.ActiveCfg = Release|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EFD819B9-B842-45B3-9E6A-B019D8898BE8} + EndGlobalSection +EndGlobal diff --git a/pkg/msvc/msvc-2019/RetroArch-msvc2019.vcxproj b/pkg/msvc/msvc-2019/RetroArch-msvc2019.vcxproj new file mode 100644 index 0000000000..110590c213 --- /dev/null +++ b/pkg/msvc/msvc-2019/RetroArch-msvc2019.vcxproj @@ -0,0 +1,2567 @@ + + + + + Debug Cg + ARM + + + Debug Cg + ARM64 + + + Debug Cg + Win32 + + + Debug Cg + x64 + + + Debug QT+CG + ARM + + + Debug QT+CG + ARM64 + + + Debug QT+CG + Win32 + + + Debug QT+CG + x64 + + + Debug QT + ARM + + + Debug QT + ARM64 + + + Debug QT + Win32 + + + Debug QT + x64 + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Debug + x64 + + + Release Cg + ARM + + + Release Cg + ARM64 + + + Release Cg + Win32 + + + Release Cg + x64 + + + Release QT+CG + ARM + + + Release QT+CG + ARM64 + + + Release QT+CG + Win32 + + + Release QT+CG + x64 + + + Release QT + ARM + + + Release QT + ARM64 + + + Release QT + Win32 + + + Release QT + x64 + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {27FF7CE1-4059-4AA1-8062-FD529560FA54} + Win32Proj + RetroArchmsvc2015 + 10.0.18362.0 + + + + Application + true + NotSet + v141 + + + Application + true + NotSet + v141 + true + + + Application + true + NotSet + v141 + true + + + Application + true + NotSet + v141 + + + Application + true + NotSet + v142 + + + Application + true + NotSet + v141 + + + Application + true + NotSet + v141 + + + Application + true + NotSet + v141 + + + Application + true + NotSet + v141 + + + Application + true + NotSet + v141 + + + Application + true + NotSet + v141 + + + Application + true + NotSet + v141 + + + Application + true + NotSet + v142 + + + Application + true + NotSet + v142 + + + Application + true + NotSet + v141 + + + Application + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + true + + + Application + false + true + NotSet + v141 + true + + + Application + false + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + + + Application + false + true + NotSet + v142 + + + Application + false + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + $(IncludePath);$(DXSDK_DIR)Include + $(DXSDK_DIR)Lib\x86;$(LibraryPath) + AllRules.ruleset + + + + + true + $(IncludePath);$(DXSDK_DIR)Include + $(LibraryPath) + AllRules.ruleset + + + + + true + $(IncludePath);$(DXSDK_DIR)Include + $(LibraryPath) + AllRules.ruleset + + + + + true + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(LibraryPath) + AllRules.ruleset + + + + + true + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(LibraryPath) + AllRules.ruleset + + + + + true + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(LibraryPath) + AllRules.ruleset + + + + + true + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include;$(QtDirectory)\msvc2015\include\QtCore;$(QtDirectory)\msvc2015\include\QtWidgets;$(QtDirectory)\msvc2015\include\QtGui;$(QtDirectory)\msvc2015\include + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(QtDirectory)\msvc2015\lib;$(LibraryPath) + AllRules.ruleset + + + $(QtDirectory)\msvc2015\bin;$(ExecutablePath) + + + true + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include;$(QtDirectory)\msvc2015\include\QtCore;$(QtDirectory)\msvc2015\include\QtWidgets;$(QtDirectory)\msvc2015\include\QtGui;$(QtDirectory)\msvc2015\include + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(QtDirectory)\msvc2015\lib;$(LibraryPath) + AllRules.ruleset + + + $(QtDirectory)\msvc2015\bin;$(ExecutablePath) + + + true + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include;$(QtDirectory)\msvc2015\include\QtCore;$(QtDirectory)\msvc2015\include\QtWidgets;$(QtDirectory)\msvc2015\include\QtGui;$(QtDirectory)\msvc2015\include + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(QtDirectory)\msvc2015\lib;$(LibraryPath) + AllRules.ruleset + + + $(QtDirectory)\msvc2015\bin;$(ExecutablePath) + + + true + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include;$(QtDirectory)\msvc2015\include\QtCore;$(QtDirectory)\msvc2015\include\QtWidgets;$(QtDirectory)\msvc2015\include\QtGui;$(QtDirectory)\msvc2015\include + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(QtDirectory)\msvc2015\lib;$(LibraryPath) + AllRules.ruleset + + + $(QtDirectory)\msvc2015\bin;$(ExecutablePath) + + + true + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include;$(QtDirectory)\msvc2015\include\QtCore;$(QtDirectory)\msvc2015\include\QtWidgets;$(QtDirectory)\msvc2015\include\QtGui;$(QtDirectory)\msvc2015\include + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(QtDirectory)\msvc2015\lib;$(LibraryPath) + AllRules.ruleset + + + $(QtDirectory)\msvc2015\bin;$(ExecutablePath) + + + true + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include;$(QtDirectory)\msvc2015\include\QtCore;$(QtDirectory)\msvc2015\include\QtWidgets;$(QtDirectory)\msvc2015\include\QtGui;$(QtDirectory)\msvc2015\include + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(QtDirectory)\msvc2015\lib;$(LibraryPath) + AllRules.ruleset + + + $(QtDirectory)\msvc2015\bin;$(ExecutablePath) + + + true + $(IncludePath);$(DXSDK_DIR)Include + $(DXSDK_DIR)Lib\x64;$(LibraryPath) + AllRules.ruleset + + + + + true + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include + $(DXSDK_DIR)Lib\x64;$(CG_LIB64_PATH);$(LibraryPath) + AllRules.ruleset + + + + + true + $(IncludePath);$(DXSDK_DIR)Include;$(QtDirectory)\msvc2017_64\include\QtCore;$(QtDirectory)\msvc2017_64\include\QtWidgets;$(QtDirectory)\msvc2017_64\include\QtGui;$(QtDirectory)\msvc2017_64\include\QtNetwork;$(QtDirectory)\msvc2017_64\include\QtConcurrent;$(QtDirectory)\msvc2017_64\include\ + $(DXSDK_DIR)Lib\x64;$(QtDirectory)\msvc2017_64\lib;$(LibraryPath) + AllRules.ruleset + + + $(QtDirectory)\msvc2017_64\bin;$(ExecutablePath) + + + true + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include;$(QtDirectory)\msvc2017_64\include\QtCore;$(QtDirectory)\msvc2017_64\include\QtWidgets;$(QtDirectory)\msvc2017_64\include\QtGui;$(QtDirectory)\msvc2017_64\include\QtNetwork;$(QtDirectory)\msvc2017_64\include\QtConcurrent;$(QtDirectory)\msvc2017_64\include\ + $(DXSDK_DIR)Lib\x64;$(CG_LIB64_PATH);$(QtDirectory)\msvc2017_64\lib;$(LibraryPath) + AllRules.ruleset + + + $(QtDirectory)\msvc2017_64\bin;$(ExecutablePath) + + + false + $(IncludePath);$(DXSDK_DIR)Include + $(DXSDK_DIR)Lib\x86;$(LibraryPath) + AllRules.ruleset + + + + + false + $(IncludePath);$(DXSDK_DIR)Include + $(LibraryPath) + AllRules.ruleset + + + + + false + $(IncludePath);$(DXSDK_DIR)Include + $(LibraryPath) + AllRules.ruleset + + + + + false + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(LibraryPath) + AllRules.ruleset + + + + + false + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(LibraryPath) + AllRules.ruleset + + + + + false + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(LibraryPath) + AllRules.ruleset + + + + + false + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include;$(QtDirectory)\msvc2015\include\QtCore;$(QtDirectory)\msvc2015\include\QtWidgets;$(QtDirectory)\msvc2015\include\QtGui;$(QtDirectory)\msvc2015\include + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(QtDirectory)\msvc2015\lib;$(LibraryPath) + AllRules.ruleset + + + $(QtDirectory)\msvc2015\bin;$(ExecutablePath) + + + false + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include;$(QtDirectory)\msvc2015\include\QtCore;$(QtDirectory)\msvc2015\include\QtWidgets;$(QtDirectory)\msvc2015\include\QtGui;$(QtDirectory)\msvc2015\include + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(QtDirectory)\msvc2015\lib;$(LibraryPath) + AllRules.ruleset + + + $(QtDirectory)\msvc2015\bin;$(ExecutablePath) + + + false + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include;$(QtDirectory)\msvc2015\include\QtCore;$(QtDirectory)\msvc2015\include\QtWidgets;$(QtDirectory)\msvc2015\include\QtGui;$(QtDirectory)\msvc2015\include + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(QtDirectory)\msvc2015\lib;$(LibraryPath) + AllRules.ruleset + + + $(QtDirectory)\msvc2015\bin;$(ExecutablePath) + + + false + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include;$(QtDirectory)\msvc2015\include\QtCore;$(QtDirectory)\msvc2015\include\QtWidgets;$(QtDirectory)\msvc2015\include\QtGui;$(QtDirectory)\msvc2015\include + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(QtDirectory)\msvc2015\lib;$(LibraryPath) + AllRules.ruleset + + + $(QtDirectory)\msvc2015\bin;$(ExecutablePath) + + + false + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include;$(QtDirectory)\msvc2015\include\QtCore;$(QtDirectory)\msvc2015\include\QtWidgets;$(QtDirectory)\msvc2015\include\QtGui;$(QtDirectory)\msvc2015\include + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(QtDirectory)\msvc2015\lib;$(LibraryPath) + AllRules.ruleset + + + $(QtDirectory)\msvc2015\bin;$(ExecutablePath) + + + false + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include;$(QtDirectory)\msvc2015\include\QtCore;$(QtDirectory)\msvc2015\include\QtWidgets;$(QtDirectory)\msvc2015\include\QtGui;$(QtDirectory)\msvc2015\include + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(QtDirectory)\msvc2015\lib;$(LibraryPath) + AllRules.ruleset + + + $(QtDirectory)\msvc2015\bin;$(ExecutablePath) + + + false + $(IncludePath);$(DXSDK_DIR)Include + $(DXSDK_DIR)Lib\x64;$(LibraryPath) + AllRules.ruleset + + + + + false + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include + $(DXSDK_DIR)Lib\x64;$(CG_LIB64_PATH);$(LibraryPath) + AllRules.ruleset + + + + + false + $(IncludePath);$(DXSDK_DIR)Include;$(QtDirectory)\msvc2017_64\include\QtCore;$(QtDirectory)\msvc2017_64\include\QtWidgets;$(QtDirectory)\msvc2017_64\include\QtGui;$(QtDirectory)\msvc2017_64\include\QtNetwork;$(QtDirectory)\msvc2017_64\include\QtConcurrent;$(QtDirectory)\msvc2017_64\include\ + $(DXSDK_DIR)Lib\x64;$(QtDirectory)\msvc2017_64\lib;$(LibraryPath) + AllRules.ruleset + + + $(QtDirectory)\msvc2017_64\bin;$(ExecutablePath) + + + false + $(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)Include;$(QtDirectory)\msvc2017_64\include\QtCore;$(QtDirectory)\msvc2017_64\include\QtWidgets;$(QtDirectory)\msvc2017_64\include\QtGui;$(QtDirectory)\msvc2017_64\include\QtNetwork;$(QtDirectory)\msvc2017_64\include\QtConcurrent;$(QtDirectory)\msvc2017_64\include\ + $(DXSDK_DIR)Lib\x64;$(CG_LIB64_PATH);$(QtDirectory)\msvc2017_64\lib;$(LibraryPath) + AllRules.ruleset + + + $(QtDirectory)\msvc2017_64\bin;$(ExecutablePath) + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_DSOUND;HAVE_WASAPI;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_XINPUT;HAVE_XAUDIO;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_CRT_SECURE_NO_WARNINGS;HAVE_OVERLAY;HAVE_RGUI;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions + OldStyle + 4566;4819 + /bigobj /utf-8 %(AdditionalOptions) + + + Console + true + msimg32.lib;gdi32.lib;ole32.lib;shell32.lib;comdlg32.lib;winmm.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + LinkVerboseLib + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_DSOUND;HAVE_WASAPI;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_CRT_SECURE_NO_WARNINGS;HAVE_OVERLAY;HAVE_RGUI;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions + OldStyle + 4566;4819 + /bigobj /utf-8 %(AdditionalOptions) + + + Console + true + msimg32.lib;gdi32.lib;ole32.lib;shell32.lib;comdlg32.lib;winmm.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + LinkVerboseLib + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_FBO;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_FBO;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_FBO;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_QT;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_FBO;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;qtmain.lib;Qt5Widgets.lib;Qt5Gui.lib;Qt5Core.lib;Qt5Network.lib;Qt5Concurrent.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_QT;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_FBO;;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;qtmain.lib;Qt5Widgets.lib;Qt5Gui.lib;Qt5Core.lib;Qt5Network.lib;Qt5Concurrent.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_QT;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_FBO;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;qtmain.lib;Qt5Widgets.lib;Qt5Gui.lib;Qt5Core.lib;Qt5Network.lib;Qt5Concurrent.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_QT;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_FBO;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;qtmain.lib;Qt5Widgets.lib;Qt5Gui.lib;Qt5Core.lib;Qt5Network.lib;Qt5Concurrent.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_QT;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_FBO;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;qtmain.lib;Qt5Widgets.lib;Qt5Gui.lib;Qt5Core.lib;Qt5Network.lib;Qt5Concurrent.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_QT;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;;HAVE_FBO;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;qtmain.lib;Qt5Widgets.lib;Qt5Gui.lib;Qt5Core.lib;Qt5Network.lib;Qt5Concurrent.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_FBO;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + $(CG_LIB64_PATH) + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_QT;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;qtmain.lib;Qt5Widgets.lib;Qt5Gui.lib;Qt5Core.lib;Qt5Network.lib;Qt5Concurrent.lib;%(AdditionalDependencies) + $(CG_LIB64_PATH) + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_QT;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_FBO;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;qtmain.lib;Qt5Widgets.lib;Qt5Gui.lib;Qt5Core.lib;Qt5Network.lib;Qt5Concurrent.lib;%(AdditionalDependencies) + $(CG_LIB64_PATH) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions + true + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_DSOUND;HAVE_WASAPI;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_XINPUT;HAVE_XAUDIO;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_CRT_SECURE_NO_WARNINGS;HAVE_OVERLAY;HAVE_RGUI;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions + true + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + true + true + msimg32.lib;gdi32.lib;ole32.lib;shell32.lib;comdlg32.lib;winmm.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + LinkVerboseLib + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_DSOUND;HAVE_WASAPI;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_CRT_SECURE_NO_WARNINGS;HAVE_OVERLAY;HAVE_RGUI;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions + true + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + true + true + msimg32.lib;gdi32.lib;ole32.lib;shell32.lib;comdlg32.lib;winmm.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + LinkVerboseLib + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions + true + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions + true + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions + true + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_QT;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions + true + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;qtmain.lib;Qt5Widgets.lib;Qt5Gui.lib;Qt5Core.lib;Qt5Network.lib;Qt5Concurrent.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_QT;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions + true + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;qtmain.lib;Qt5Widgets.lib;Qt5Gui.lib;Qt5Core.lib;Qt5Network.lib;Qt5Concurrent.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_QT;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions + true + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;qtmain.lib;Qt5Widgets.lib;Qt5Gui.lib;Qt5Core.lib;Qt5Network.lib;Qt5Concurrent.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_QT;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions + true + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;qtmain.lib;Qt5Widgets.lib;Qt5Gui.lib;Qt5Core.lib;Qt5Network.lib;Qt5Concurrent.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_QT;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions + true + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;qtmain.lib;Qt5Widgets.lib;Qt5Gui.lib;Qt5Core.lib;Qt5Network.lib;Qt5Concurrent.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_QT;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions + true + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;qtmain.lib;Qt5Widgets.lib;Qt5Gui.lib;Qt5Core.lib;Qt5Network.lib;Qt5Concurrent.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + true + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + LinkVerboseLib + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + true + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + $(CG_LIB64_PATH) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_QT;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + true + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;qtmain.lib;Qt5Widgets.lib;Qt5Gui.lib;Qt5Core.lib;Qt5Network.lib;Qt5Concurrent.lib;%(AdditionalDependencies) + $(CG_LIB64_PATH) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_CG;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_QT;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + true + OldStyle + 4566;4819 + /utf-8 %(AdditionalOptions) + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;qtmain.lib;Qt5Widgets.lib;Qt5Gui.lib;Qt5Core.lib;Qt5Network.lib;Qt5Concurrent.lib;%(AdditionalDependencies) + $(CG_LIB64_PATH) + + + + + + + + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + + + /bigobj %(AdditionalOptions) + /bigobj %(AdditionalOptions) + /bigobj %(AdditionalOptions) + /bigobj %(AdditionalOptions) + + + /bigobj %(AdditionalOptions) + /bigobj %(AdditionalOptions) + /bigobj %(AdditionalOptions) + /bigobj %(AdditionalOptions) + + + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + false + false + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + false + false + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + false + false + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + true + true + true + true + true + true + true + true + + + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + false + false + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + false + false + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + moc.exe "%(FullPath)" > "%(RootDir)%(Directory)moc_%(Filename).cpp" + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + QT: Generate %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + %(RootDir)%(Directory)moc_%(Filename).cpp + false + false + true + true + true + true + true + true + true + true + + + + + + \ No newline at end of file diff --git a/pkg/msvc/msvc-2019/RetroArch-msvc2019.vcxproj.filters b/pkg/msvc/msvc-2019/RetroArch-msvc2019.vcxproj.filters new file mode 100644 index 0000000000..d755c76f80 --- /dev/null +++ b/pkg/msvc/msvc-2019/RetroArch-msvc2019.vcxproj.filters @@ -0,0 +1,42 @@ + + + + + + + + {9fc175c7-a869-47cf-a0ce-5447d6015ce9} + + + {e6159cab-0a32-493f-a119-a2f0fd0cc6ef} + + + + + griffin + + + griffin + + + griffin + + + + + QT + + + QT + + + + + + + + + + + + \ No newline at end of file diff --git a/pkg/msvc/msvc-2019/readme-build-qt.txt b/pkg/msvc/msvc-2019/readme-build-qt.txt new file mode 100644 index 0000000000..47f4fdf9a1 --- /dev/null +++ b/pkg/msvc/msvc-2019/readme-build-qt.txt @@ -0,0 +1,22 @@ +If you are using the MSVC 2017 project file, you must define the environment varaible QtDirectory. This should point to the directory with the version number. +For example: QtDirectory=C:\qt\5.10.1 + +Two ways to define the variable: + +Windows: + Control Panel > System + Click Advanced System Settings + Go to Advanced Tab + Click Environment Variables button + Create a new variable (either user or system is okay), name it QtDirectory, set the value to your QT directory. + Restart all instances of Visual Studio. You may have to close it, wait 15 seconds, then kill the process. +Visual Studio: + View > Other Windows > Property Manager + Open the x64 build configuration + Double click on Microsoft.Cpp.x64.user + Go to User Macros + Add a new macro, name it QtDirectory, and set the value to your QT directory. + Open the Win32 build configuration + Double click on Microsoft.Cpp.Win32.user + Go to User Macros + Add a new macro, name it QtDirectory, and set the value to your QT directory. From 38c8369e585f7196c09fdcd080de673592d7dda8 Mon Sep 17 00:00:00 2001 From: im4potato Date: Thu, 7 May 2020 20:58:50 -0700 Subject: [PATCH 012/192] US Translation: Add back RGUI_BORDER_FILLER_THICKNESS --- intl/msg_hash_us.h | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index c658ca42aa..8c5d45f715 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -7112,14 +7112,6 @@ MSG_HASH( /* RGUI: Settings > User Interface > Appearance */ -MSG_HASH( - MENU_ENUM_LABEL_VALUE_MENU_RGUI_BORDER_FILLER_ENABLE, - "Border Filler" - ) -MSG_HASH( - MENU_ENUM_SUBLABEL_MENU_RGUI_BORDER_FILLER_ENABLE, - "Display menu border." - ) MSG_HASH( MENU_ENUM_LABEL_VALUE_MENU_RGUI_BACKGROUND_FILLER_THICKNESS_ENABLE, "Background Filler Thickness" @@ -7128,6 +7120,22 @@ MSG_HASH( MENU_ENUM_SUBLABEL_MENU_RGUI_BACKGROUND_FILLER_THICKNESS_ENABLE, "Increase coarseness of menu background chequerboard pattern." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_MENU_RGUI_BORDER_FILLER_ENABLE, + "Border Filler" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_MENU_RGUI_BORDER_FILLER_THICKNESS_ENABLE, + "Border Filler Thickness" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_MENU_RGUI_BORDER_FILLER_THICKNESS_ENABLE, + "Increase coarseness of menu border checkerboard." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_MENU_RGUI_BORDER_FILLER_ENABLE, + "Display menu border." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_MENU_RGUI_FULL_WIDTH_LAYOUT, "Use Full-Width Layout" From 09e54d1e7525decc09c102407121b9123d2a8bcf Mon Sep 17 00:00:00 2001 From: im4potato Date: Thu, 7 May 2020 21:05:30 -0700 Subject: [PATCH 013/192] US Translation: Fix spelling of "checkerboard" to match other settings --- intl/msg_hash_us.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 8c5d45f715..2151b206b5 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -7118,7 +7118,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_MENU_RGUI_BACKGROUND_FILLER_THICKNESS_ENABLE, - "Increase coarseness of menu background chequerboard pattern." + "Increase coarseness of menu background checkerboard pattern." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_MENU_RGUI_BORDER_FILLER_ENABLE, From e519ccd0bee0c2f19e7622d928e612d3d31de5b5 Mon Sep 17 00:00:00 2001 From: MrHuu Date: Fri, 8 May 2020 20:50:15 +0200 Subject: [PATCH 014/192] (3DS) Enable basic networking / cheevos --- Makefile.ctr | 4 +++- config.def.h | 8 ++++++-- libretro-common/include/net/net_natt.h | 2 +- libretro-common/net/net_ifinfo.c | 17 ++++++++++++----- network/netplay/netplay_discovery.c | 2 +- network/netplay/netplay_handshake.c | 2 +- network/netplay/netplay_init.c | 2 +- 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Makefile.ctr b/Makefile.ctr index 1eb4a1b386..3fe03430a6 100644 --- a/Makefile.ctr +++ b/Makefile.ctr @@ -52,7 +52,8 @@ ifeq ($(GRIFFIN_BUILD), 1) OBJ += griffin/griffin.o DEFINES += -DHAVE_GRIFFIN=1 -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_RGUI -DHAVE_XMB -DHAVE_MATERIALUI -DHAVE_LIBRETRODB -DHAVE_CC_RESAMPLER DEFINES += -DHAVE_ZLIB -DHAVE_7ZIP -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA - #DEFINES += -DHAVE_NETWORKING -DHAVE_CHEEVOS -DRC_DISABLE_LUA -DHAVE_SOCKET_LEGACY -DHAVE_THREADS + DEFINES += -DHAVE_NETWORKING -DHAVE_CHEEVOS -DRC_DISABLE_LUA + #DEFINES += -DHAVE_SOCKET_LEGACY -DHAVE_THREADS #-DHAVE_SSL -DHAVE_BUILTINMBEDTLS -DMBEDTLS_SSL_DEBUG_ALL #ssl is currently incompatible with griffin due to use of the "static" flag on repeating functions that will conflict when included in one file else @@ -135,6 +136,7 @@ CFLAGS += -I. \ -Ideps \ -Ideps/7zip \ -Ideps/stb \ + -Ideps/rcheevos/include \ -Ilibretro-common/include \ -Ilibretro-common/include/compat/zlib diff --git a/config.def.h b/config.def.h index a9702808c9..fe7fbe1ae4 100644 --- a/config.def.h +++ b/config.def.h @@ -539,11 +539,15 @@ static const bool content_show_music = true; #if defined(HAVE_FFMPEG) || defined(HAVE_MPV) static const bool content_show_video = true; #endif -#ifdef HAVE_NETWORKING +#if defined(HAVE_NETWORKING) +#if defined(_3DS) +static const bool content_show_netplay = false; +#else static const bool content_show_netplay = true; #endif +#endif static const bool content_show_history = true; -static const bool content_show_add = true; +static const bool content_show_add = true; static const bool content_show_playlists = true; #ifdef HAVE_XMB diff --git a/libretro-common/include/net/net_natt.h b/libretro-common/include/net/net_natt.h index 93c4c2ebe1..74ca3164ac 100644 --- a/libretro-common/include/net/net_natt.h +++ b/libretro-common/include/net/net_natt.h @@ -50,7 +50,7 @@ struct natt_status /** True if we've resolved an external IPv6 address */ bool have_inet6; -#if defined(AF_INET6) && !defined(HAVE_SOCKET_LEGACY) +#if defined(AF_INET6) && !defined(HAVE_SOCKET_LEGACY) && !defined(_3DS) /** External IPv6 address */ struct sockaddr_in6 ext_inet6_addr; #endif diff --git a/libretro-common/net/net_ifinfo.c b/libretro-common/net/net_ifinfo.c index 984e981656..b9238d2d61 100644 --- a/libretro-common/net/net_ifinfo.c +++ b/libretro-common/net/net_ifinfo.c @@ -38,7 +38,7 @@ #ifdef WANT_IFADDRS #include #else -#ifndef HAVE_LIBNX +#if !defined HAVE_LIBNX && !defined(_3DS) #include #endif #endif @@ -73,7 +73,7 @@ void net_ifinfo_free(net_ifinfo_t *list) free(list->entries); } -#ifdef HAVE_LIBNX +#if defined(HAVE_LIBNX) || defined(_3DS) static void convert_ip(char *dst, size_t size, uint32_t ip, bool inverted) { unsigned char bytes[4]; @@ -92,7 +92,7 @@ static void convert_ip(char *dst, size_t size, uint32_t ip, bool inverted) bool net_ifinfo_new(net_ifinfo_t *list) { unsigned k = 0; -#ifdef HAVE_LIBNX +#if defined(HAVE_LIBNX) || defined(_3DS) uint32_t id; Result rc; @@ -123,12 +123,16 @@ bool net_ifinfo_new(net_ifinfo_t *list) can be wlan or eth (with a wiiu adapter) so we just use "switch" as a name */ +#if defined(_3DS) + convert_ip(hostname, sizeof(hostname), gethostid(), true); +#else rc = nifmGetCurrentIpAddress(&id); if (!R_SUCCEEDED(rc)) /* not connected to any network */ return true; convert_ip(hostname, sizeof(hostname), id, true); +#endif ptr = (struct net_ifinfo_entry*) realloc(list->entries, (k+1) * sizeof(struct net_ifinfo_entry)); @@ -137,8 +141,11 @@ bool net_ifinfo_new(net_ifinfo_t *list) goto error; list->entries = ptr; - +#if defined(_3DS) + list->entries[k].name = strdup("wlan"); +#else list->entries[k].name = strdup("switch"); +#endif list->entries[k].host = strdup(hostname); list->size = k + 1; @@ -242,7 +249,7 @@ error: #ifdef _WIN32 if (adapter_addresses) free(adapter_addresses); -#elif !defined(HAVE_LIBNX) +#elif !defined(HAVE_LIBNX) && !defined(_3DS) freeifaddrs(ifaddr); #endif net_ifinfo_free(list); diff --git a/network/netplay/netplay_discovery.c b/network/netplay/netplay_discovery.c index 350ce91e39..12234cd075 100644 --- a/network/netplay/netplay_discovery.c +++ b/network/netplay/netplay_discovery.c @@ -51,7 +51,7 @@ #include "netplay_discovery.h" #include "netplay_private.h" -#if defined(AF_INET6) && !defined(HAVE_SOCKET_LEGACY) +#if defined(AF_INET6) && !defined(HAVE_SOCKET_LEGACY) && !defined(_3DS) #define HAVE_INET6 1 #endif diff --git a/network/netplay/netplay_handshake.c b/network/netplay/netplay_handshake.c index d77656aa4c..d0bc161a49 100644 --- a/network/netplay/netplay_handshake.c +++ b/network/netplay/netplay_handshake.c @@ -42,7 +42,7 @@ const uint32_t netplay_magic = 0x52414E50; /* RANP */ /* TODO/FIXME - replace netplay_log_connection with calls * to inet_ntop_compat and move runloop message queue pushing * outside */ -#if !defined(HAVE_SOCKET_LEGACY) && !defined(WIIU) +#if !defined(HAVE_SOCKET_LEGACY) && !defined(WIIU) && !defined(_3DS) /* Custom inet_ntop. Win32 doesn't seem to support this ... */ void netplay_log_connection(const struct sockaddr_storage *their_addr, unsigned slot, const char *nick, char *s, size_t len) diff --git a/network/netplay/netplay_init.c b/network/netplay/netplay_init.c index 35f3e304ab..fd3d0b04fc 100644 --- a/network/netplay/netplay_init.c +++ b/network/netplay/netplay_init.c @@ -33,7 +33,7 @@ #include "../../autosave.h" #include "../../retroarch.h" -#if defined(AF_INET6) && !defined(HAVE_SOCKET_LEGACY) +#if defined(AF_INET6) && !defined(HAVE_SOCKET_LEGACY) && !defined(_3DS) #define HAVE_INET6 1 #endif From df3af35ee46fdd91dec7ef51d9b4493802b9ea56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Jos=C3=A9=20Garc=C3=ADa=20Garc=C3=ADa?= Date: Sat, 9 May 2020 09:51:00 +0200 Subject: [PATCH 015/192] (VITA) Fix for new VITASDK --- Makefile.vita | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.vita b/Makefile.vita index a5097f7ce9..08508371a0 100644 --- a/Makefile.vita +++ b/Makefile.vita @@ -87,7 +87,7 @@ AR := $(PREFIX)ar OBJCOPY := $(PREFIX)objcopy STRIP := $(PREFIX)strip NM := $(PREFIX)nm -LD := $(CXX) +LD := $(CC) LIBDIRS := -L. @@ -122,7 +122,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions VITA_LIBS := -lSceDisplay_stub -lSceGxm_stub -lSceNet_stub -lSceNetCtl_stub -lSceAppUtil_stub \ -lSceSysmodule_stub -lSceCtrl_stub -lSceHid_stub -lSceTouch_stub -lSceAudio_stub \ -lScePower_stub -lSceRtc_stub -lSceCommonDialog_stub -lScePgf_stub -lSceMotion_stub \ - -lSceFiber_stub -lSceMotion_stub -lSceAppMgr_stub -lpthread -lpng -lz + -lSceFiber_stub -lSceMotion_stub -lSceAppMgr_stub -lstdc++ -lpthread -lpng -lz LIBS := $(WHOLE_START) -lretro_vita $(WHOLE_END) $(VITA_LIBS) -lm -lc From 63644ac76163ba7e7c4a32519c4dfbd0868f21c8 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Sat, 9 May 2020 14:30:49 +0100 Subject: [PATCH 016/192] (GLUI) Add desktop-style playlist view mode --- gfx/gfx_thumbnail.c | 111 +- gfx/gfx_thumbnail.h | 10 + intl/msg_hash_us.h | 4 + menu/drivers/materialui.c | 2246 +++++++++++++++++++++++++++--------- menu/drivers/ozone/ozone.c | 1 + menu/drivers/xmb.c | 1 + menu/menu_defines.h | 1 + menu/menu_setting.c | 5 + msg_hash.h | 1 + runtime_file.c | 17 +- 10 files changed, 1797 insertions(+), 600 deletions(-) diff --git a/gfx/gfx_thumbnail.c b/gfx/gfx_thumbnail.c index 6f63ac00bf..72a42cdae4 100644 --- a/gfx/gfx_thumbnail.c +++ b/gfx/gfx_thumbnail.c @@ -51,6 +51,10 @@ struct gfx_thumbnail_state /* Duration in ms of the thumbnail 'fade in' animation */ float fade_duration; + /* When true, 'fade in' animation will also be + * triggered for missing thumbnails */ + bool fade_missing; + /* Due to the asynchronous nature of thumbnail * loading, it is quite possible to trigger a load * then navigate to a different menu list before @@ -111,6 +115,17 @@ void gfx_thumbnail_set_fade_duration(float duration) duration : DEFAULT_GFX_THUMBNAIL_FADE_DURATION; } +/* Specifies whether 'fade in' animation should be + * triggered for missing thumbnails + * > When 'true', allows menu driver to animate + * any 'thumbnail unavailable' notifications */ +void gfx_thumbnail_set_fade_missing(bool fade_missing) +{ + gfx_thumbnail_state_t *p_gfx_thumb = gfx_thumb_get_ptr(); + + p_gfx_thumb->fade_missing = fade_missing; +} + /* Getters */ /* Fetches current streaming thumbnails request delay */ @@ -129,17 +144,63 @@ float gfx_thumbnail_get_fade_duration(void) return p_gfx_thumb->fade_duration; } +/* Fetches current enable state for missing + * thumbnail 'fade in' animations */ +bool gfx_thumbnail_get_fade_missing(bool fade_missing) +{ + gfx_thumbnail_state_t *p_gfx_thumb = gfx_thumb_get_ptr(); + + return p_gfx_thumb->fade_missing; +} + /* Callbacks */ +/* Initialises thumbnail 'fade in' animation */ +static void gfx_thumbnail_init_fade(gfx_thumbnail_t *thumbnail) +{ + gfx_thumbnail_state_t *p_gfx_thumb = gfx_thumb_get_ptr(); + + /* Sanity check */ + if (!thumbnail) + return; + + /* A 'fade in' animation is triggered if: + * - Thumbnail is available + * - Thumbnail is missing and 'fade_missing' is enabled */ + if ((thumbnail->status == GFX_THUMBNAIL_STATUS_AVAILABLE) || + (p_gfx_thumb->fade_missing && + (thumbnail->status == GFX_THUMBNAIL_STATUS_MISSING))) + { + if (p_gfx_thumb->fade_duration > 0.0f) + { + gfx_animation_ctx_entry_t animation_entry; + + thumbnail->alpha = 0.0f; + + animation_entry.easing_enum = EASING_OUT_QUAD; + animation_entry.tag = (uintptr_t)&thumbnail->alpha; + animation_entry.duration = p_gfx_thumb->fade_duration; + animation_entry.target_value = 1.0f; + animation_entry.subject = &thumbnail->alpha; + animation_entry.cb = NULL; + animation_entry.userdata = NULL; + + gfx_animation_push(&animation_entry); + } + else + thumbnail->alpha = 1.0f; + } +} + /* Used to process thumbnail data following completion * of image load task */ static void gfx_thumbnail_handle_upload( retro_task_t *task, void *task_data, void *user_data, const char *err) { - gfx_animation_ctx_entry_t animation_entry; gfx_thumbnail_state_t *p_gfx_thumb = gfx_thumb_get_ptr(); struct texture_image *img = (struct texture_image*)task_data; gfx_thumbnail_tag_t *thumbnail_tag = (gfx_thumbnail_tag_t*)user_data; + bool fade_enabled = false; /* Sanity check */ if (!thumbnail_tag) @@ -165,6 +226,11 @@ static void gfx_thumbnail_handle_upload( * (saves a number of checks later) */ thumbnail_tag->thumbnail->status = GFX_THUMBNAIL_STATUS_MISSING; + /* If we reach this stage, thumbnail 'fade in' + * animations should be applied (based on current + * thumbnail status and global configuration) */ + fade_enabled = true; + /* Check we have a valid image */ if (!img) goto end; @@ -184,24 +250,6 @@ static void gfx_thumbnail_handle_upload( /* Update thumbnail status */ thumbnail_tag->thumbnail->status = GFX_THUMBNAIL_STATUS_AVAILABLE; - /* Trigger 'fade in' animation, if required */ - if (p_gfx_thumb->fade_duration > 0.0f) - { - thumbnail_tag->thumbnail->alpha = 0.0f; - - animation_entry.easing_enum = EASING_OUT_QUAD; - animation_entry.tag = (uintptr_t)&thumbnail_tag->thumbnail->alpha; - animation_entry.duration = p_gfx_thumb->fade_duration; - animation_entry.target_value = 1.0f; - animation_entry.subject = &thumbnail_tag->thumbnail->alpha; - animation_entry.cb = NULL; - animation_entry.userdata = NULL; - - gfx_animation_push(&animation_entry); - } - else - thumbnail_tag->thumbnail->alpha = 1.0f; - end: /* Clean up */ if (img) @@ -211,7 +259,13 @@ end: } if (thumbnail_tag) + { + /* Trigger 'fade in' animation, if required */ + if (fade_enabled) + gfx_thumbnail_init_fade(thumbnail_tag->thumbnail); + free(thumbnail_tag); + } } /* Core interface */ @@ -248,8 +302,8 @@ void gfx_thumbnail_request( bool network_on_demand_thumbnails ) { - const char *thumbnail_path = NULL; - bool has_thumbnail = false; + const char *thumbnail_path = NULL; + bool has_thumbnail = false; if (!path_data || !thumbnail) return; @@ -274,7 +328,7 @@ void gfx_thumbnail_request( (gfx_thumbnail_tag_t*)calloc(1, sizeof(gfx_thumbnail_tag_t)); if (!thumbnail_tag) - return; + goto end; /* Configure user data */ thumbnail_tag->thumbnail = thumbnail; @@ -297,11 +351,11 @@ void gfx_thumbnail_request( static char last_img_name[PATH_MAX_LENGTH] = {0}; if (!playlist) - return; + goto end; /* Get current image name */ if (!gfx_thumbnail_get_img_name(path_data, &img_name)) - return; + goto end; /* Only trigger a thumbnail download if image * name has changed since the last call of @@ -316,13 +370,13 @@ void gfx_thumbnail_request( * overheads. We can avoid this entirely with * a simple string comparison) */ if (string_is_equal(img_name, last_img_name)) - return; + goto end; strlcpy(last_img_name, img_name, sizeof(last_img_name)); /* Get system name */ if (!gfx_thumbnail_get_system(path_data, &system)) - return; + goto end; /* Trigger thumbnail download */ task_push_pl_entry_thumbnail_download( @@ -331,6 +385,11 @@ void gfx_thumbnail_request( } #endif } + +end: + /* Trigger 'fade in' animation, if required */ + if (thumbnail->status != GFX_THUMBNAIL_STATUS_PENDING) + gfx_thumbnail_init_fade(thumbnail); } /* Requests loading of a specific thumbnail image file diff --git a/gfx/gfx_thumbnail.h b/gfx/gfx_thumbnail.h index f1f89205b0..1c27041a75 100644 --- a/gfx/gfx_thumbnail.h +++ b/gfx/gfx_thumbnail.h @@ -104,6 +104,12 @@ void gfx_thumbnail_set_stream_delay(float delay); * > If 'duration' is negative, default value is set */ void gfx_thumbnail_set_fade_duration(float duration); +/* Specifies whether 'fade in' animation should be + * triggered for missing thumbnails + * > When 'true', allows menu driver to animate + * any 'thumbnail unavailable' notifications */ +void gfx_thumbnail_set_fade_missing(bool fade_missing); + /* Getters */ /* Fetches current streaming thumbnails request delay */ @@ -112,6 +118,10 @@ float gfx_thumbnail_get_stream_delay(void); /* Fetches current 'fade in' animation duration */ float gfx_thumbnail_get_fade_duration(void); +/* Fetches current enable state for missing + * thumbnail 'fade in' animations */ +bool gfx_thumbnail_get_fade_missing(bool fade_missing); + /* Core interface */ /* When called, prevents the handling of any pending diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 2151b206b5..d5d77dd606 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -8107,6 +8107,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_MATERIALUI_THUMBNAIL_VIEW_LANDSCAPE_LIST_LARGE, "List (Large)" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_MATERIALUI_THUMBNAIL_VIEW_LANDSCAPE_DESKTOP, + "Desktop" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_MATERIALUI_LANDSCAPE_LAYOUT_OPTIMIZATION_DISABLED, "OFF" diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 39b1999711..601983d4d9 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -51,6 +51,7 @@ #include "../../configuration.h" #include "../../verbosity.h" #include "../../tasks/tasks_internal.h" +#include "../../runtime_file.h" /* Defines the 'device independent pixel' base * unit reference size for all UI elements. @@ -82,6 +83,7 @@ typedef struct uint32_t list_text_highlighted; uint32_t list_hint_text; uint32_t list_hint_text_highlighted; + uint32_t status_bar_text; /* Background colours */ uint32_t sys_bar_background; uint32_t title_bar_background; @@ -90,6 +92,8 @@ typedef struct uint32_t nav_bar_background; uint32_t surface_background; uint32_t thumbnail_background; + uint32_t side_bar_background; + uint32_t status_bar_background; /* List icon colours */ uint32_t list_icon; uint32_t list_switch_on; @@ -103,12 +107,14 @@ typedef struct /* Misc. colours */ uint32_t header_shadow; uint32_t landscape_border_shadow; + uint32_t status_bar_shadow; uint32_t scrollbar; uint32_t divider; uint32_t screen_fade; uint32_t missing_thumbnail_icon; float header_shadow_opacity; float landscape_border_shadow_opacity; + float status_bar_shadow_opacity; float screen_fade_opacity; } materialui_theme_t; @@ -120,6 +126,7 @@ static const materialui_theme_t materialui_theme_blue = { 0x000000, /* list_text_highlighted */ 0x666666, /* list_hint_text */ 0x212121, /* list_hint_text_highlighted */ + 0x000000, /* status_bar_text */ /* Background colours */ 0x0069c0, /* sys_bar_background */ 0x2196f3, /* title_bar_background */ @@ -128,6 +135,8 @@ static const materialui_theme_t materialui_theme_blue = { 0xE1E2E1, /* nav_bar_background */ 0xFFFFFF, /* surface_background */ 0x242424, /* thumbnail_background */ + 0xc1d5e0, /* side_bar_background */ + 0x9F9FA0, /* status_bar_background */ /* List icon colours */ 0x0069c0, /* list_icon */ 0x2196f3, /* list_switch_on */ @@ -141,12 +150,14 @@ static const materialui_theme_t materialui_theme_blue = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x000000, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0x0069c0, /* scrollbar */ 0x9ea7aa, /* divider */ 0x000000, /* screen_fade */ 0xF5F5F6, /* missing_thumbnail_icon */ 0.3f, /* header_shadow_opacity */ 0.35f, /* landscape_border_shadow_opacity */ + 0.45f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -158,6 +169,7 @@ static const materialui_theme_t materialui_theme_blue_grey = { 0x000000, /* list_text_highlighted */ 0x666666, /* list_hint_text */ 0x212121, /* list_hint_text_highlighted */ + 0x000000, /* status_bar_text */ /* Background colours */ 0x34515e, /* sys_bar_background */ 0x607d8b, /* title_bar_background */ @@ -166,6 +178,8 @@ static const materialui_theme_t materialui_theme_blue_grey = { 0xE1E2E1, /* nav_bar_background */ 0xFFFFFF, /* surface_background */ 0x242424, /* thumbnail_background */ + 0xe0e0e0, /* side_bar_background */ + 0x9F9FA0, /* status_bar_background */ /* List icon colours */ 0x34515e, /* list_icon */ 0x607d8b, /* list_switch_on */ @@ -179,12 +193,14 @@ static const materialui_theme_t materialui_theme_blue_grey = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x000000, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0x34515e, /* scrollbar */ 0xc2c2c2, /* divider */ 0x000000, /* screen_fade */ 0xF5F5F6, /* missing_thumbnail_icon */ 0.3f, /* header_shadow_opacity */ 0.35f, /* landscape_border_shadow_opacity */ + 0.45f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -196,6 +212,7 @@ static const materialui_theme_t materialui_theme_dark_blue = { 0xFFFFFF, /* list_text_highlighted */ 0x999999, /* list_hint_text */ 0xDEDEDE, /* list_hint_text_highlighted */ + 0x999999, /* status_bar_text */ /* Background colours */ 0x000000, /* sys_bar_background */ 0x1F1F1F, /* title_bar_background */ @@ -204,6 +221,8 @@ static const materialui_theme_t materialui_theme_dark_blue = { 0x242424, /* nav_bar_background */ 0x1D1D1D, /* surface_background */ 0x000000, /* thumbnail_background */ + 0x1D1D1D, /* side_bar_background */ + 0x242424, /* status_bar_background */ /* List icon colours */ 0x90caf9, /* list_icon */ 0x64b5f6, /* list_switch_on */ @@ -217,12 +236,14 @@ static const materialui_theme_t materialui_theme_dark_blue = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x3B3B3B, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0x90caf9, /* scrollbar */ 0x607d8b, /* divider */ 0x000000, /* screen_fade */ 0xDEDEDE, /* missing_thumbnail_icon */ 0.3f, /* header_shadow_opacity */ 0.45f, /* landscape_border_shadow_opacity */ + 0.8f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -234,6 +255,7 @@ static const materialui_theme_t materialui_theme_green = { 0x000000, /* list_text_highlighted */ 0x666666, /* list_hint_text */ 0x212121, /* list_hint_text_highlighted */ + 0x000000, /* status_bar_text */ /* Background colours */ 0x087f23, /* sys_bar_background */ 0x4caf50, /* title_bar_background */ @@ -242,6 +264,8 @@ static const materialui_theme_t materialui_theme_green = { 0xE1E2E1, /* nav_bar_background */ 0xFFFFFF, /* surface_background */ 0x242424, /* thumbnail_background */ + 0xdcedc8, /* side_bar_background */ + 0x9F9FA0, /* status_bar_background */ /* List icon colours */ 0x087f23, /* list_icon */ 0x4caf50, /* list_switch_on */ @@ -255,12 +279,14 @@ static const materialui_theme_t materialui_theme_green = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x000000, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0x087f23, /* scrollbar */ 0xaabb97, /* divider */ 0x000000, /* screen_fade */ 0xF5F5F6, /* missing_thumbnail_icon */ 0.3f, /* header_shadow_opacity */ 0.35f, /* landscape_border_shadow_opacity */ + 0.45f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -272,6 +298,7 @@ static const materialui_theme_t materialui_theme_red = { 0x000000, /* list_text_highlighted */ 0x666666, /* list_hint_text */ 0x212121, /* list_hint_text_highlighted */ + 0x000000, /* status_bar_text */ /* Background colours */ 0xba000d, /* sys_bar_background */ 0xf44336, /* title_bar_background */ @@ -280,6 +307,8 @@ static const materialui_theme_t materialui_theme_red = { 0xE1E2E1, /* nav_bar_background */ 0xFFFFFF, /* surface_background */ 0x242424, /* thumbnail_background */ + 0xf8bbd0, /* side_bar_background */ + 0x9F9FA0, /* status_bar_background */ /* List icon colours */ 0xba000d, /* list_icon */ 0xf44336, /* list_switch_on */ @@ -293,12 +322,14 @@ static const materialui_theme_t materialui_theme_red = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x000000, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0xba000d, /* scrollbar */ 0xbf5f82, /* divider */ 0x000000, /* screen_fade */ 0xF5F5F6, /* missing_thumbnail_icon */ 0.3f, /* header_shadow_opacity */ 0.35f, /* landscape_border_shadow_opacity */ + 0.45f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -310,6 +341,7 @@ static const materialui_theme_t materialui_theme_yellow = { 0x000000, /* list_text_highlighted */ 0x666666, /* list_hint_text */ 0x212121, /* list_hint_text_highlighted */ + 0x000000, /* status_bar_text */ /* Background colours */ 0xc8b900, /* sys_bar_background */ 0xffeb3b, /* title_bar_background */ @@ -318,6 +350,8 @@ static const materialui_theme_t materialui_theme_yellow = { 0xE1E2E1, /* nav_bar_background */ 0xFFFFFF, /* surface_background */ 0x242424, /* thumbnail_background */ + 0xffecb3, /* side_bar_background */ + 0x9F9FA0, /* status_bar_background */ /* List icon colours */ 0xc6a700, /* list_icon */ 0xffeb3b, /* list_switch_on */ @@ -331,12 +365,14 @@ static const materialui_theme_t materialui_theme_yellow = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x000000, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0xc6a700, /* scrollbar */ 0xcbba83, /* divider */ 0x000000, /* screen_fade */ 0xF5F5F6, /* missing_thumbnail_icon */ 0.3f, /* header_shadow_opacity */ 0.35f, /* landscape_border_shadow_opacity */ + 0.45f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -348,6 +384,7 @@ static const materialui_theme_t materialui_theme_nvidia_shield = { 0xFFFFFF, /* list_text_highlighted */ 0x999999, /* list_hint_text */ 0xDEDEDE, /* list_hint_text_highlighted */ + 0x999999, /* status_bar_text */ /* Background colours */ 0x000000, /* sys_bar_background */ 0x1F1F1F, /* title_bar_background */ @@ -356,6 +393,8 @@ static const materialui_theme_t materialui_theme_nvidia_shield = { 0x242424, /* nav_bar_background */ 0x1D1D1D, /* surface_background */ 0x000000, /* thumbnail_background */ + 0x1D1D1D, /* side_bar_background */ + 0x242424, /* status_bar_background */ /* List icon colours */ 0x7ab547, /* list_icon */ 0x85bb5c, /* list_switch_on */ @@ -369,12 +408,14 @@ static const materialui_theme_t materialui_theme_nvidia_shield = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x3B3B3B, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0x7ab547, /* scrollbar */ 0x498515, /* divider */ 0x000000, /* screen_fade */ 0xDEDEDE, /* missing_thumbnail_icon */ 0.3f, /* header_shadow_opacity */ 0.45f, /* landscape_border_shadow_opacity */ + 0.8f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -386,6 +427,7 @@ static const materialui_theme_t materialui_theme_materialui = { 0x000000, /* list_text_highlighted */ 0x666666, /* list_hint_text */ 0x212121, /* list_hint_text_highlighted */ + 0x000000, /* status_bar_text */ /* Background colours */ 0x3700B3, /* sys_bar_background */ 0x6200ee, /* title_bar_background */ @@ -394,6 +436,8 @@ static const materialui_theme_t materialui_theme_materialui = { 0xE1E2E1, /* nav_bar_background */ 0xFFFFFF, /* surface_background */ 0x242424, /* thumbnail_background */ + 0xe7b9ff, /* side_bar_background */ + 0x9F9FA0, /* status_bar_background */ /* List icon colours */ 0x3700B3, /* list_icon */ 0x03DAC6, /* list_switch_on */ @@ -407,12 +451,14 @@ static const materialui_theme_t materialui_theme_materialui = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x000000, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0x018786, /* scrollbar */ 0x018786, /* divider */ 0x000000, /* screen_fade */ 0xF5F5F6, /* missing_thumbnail_icon */ 0.3f, /* header_shadow_opacity */ 0.35f, /* landscape_border_shadow_opacity */ + 0.45f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -424,6 +470,7 @@ static const materialui_theme_t materialui_theme_materialui_dark = { 0xFFFFFF, /* list_text_highlighted */ 0x999999, /* list_hint_text */ 0xDEDEDE, /* list_hint_text_highlighted */ + 0x999999, /* status_bar_text */ /* Background colours */ 0x000000, /* sys_bar_background */ 0x1F1F1F, /* title_bar_background */ @@ -432,6 +479,8 @@ static const materialui_theme_t materialui_theme_materialui_dark = { 0x242424, /* nav_bar_background */ 0x1D1D1D, /* surface_background */ 0x000000, /* thumbnail_background */ + 0x1D1D1D, /* side_bar_background */ + 0x242424, /* status_bar_background */ /* List icon colours */ 0xbb86fc, /* list_icon */ 0x03DAC5, /* list_switch_on */ @@ -445,12 +494,14 @@ static const materialui_theme_t materialui_theme_materialui_dark = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x3B3B3B, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0xC89EFC, /* scrollbar */ 0x03DAC6, /* divider */ 0x000000, /* screen_fade */ 0xDEDEDE, /* missing_thumbnail_icon */ 0.3f, /* header_shadow_opacity */ 0.45f, /* landscape_border_shadow_opacity */ + 0.8f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -462,6 +513,7 @@ static const materialui_theme_t materialui_theme_ozone_dark = { 0xFFFFFF, /* list_text_highlighted */ 0xDADADA, /* list_hint_text */ 0xEEEEEE, /* list_hint_text_highlighted */ + 0xDADADA, /* status_bar_text */ /* Background colours */ 0x000000, /* sys_bar_background */ 0x373737, /* title_bar_background */ @@ -470,6 +522,8 @@ static const materialui_theme_t materialui_theme_ozone_dark = { 0x373737, /* nav_bar_background */ 0x333333, /* surface_background */ 0x0B0B0B, /* thumbnail_background */ + 0x333333, /* side_bar_background */ + 0x191919, /* status_bar_background */ /* List icon colours */ 0xFFFFFF, /* list_icon */ 0x00FFC5, /* list_switch_on */ @@ -483,12 +537,14 @@ static const materialui_theme_t materialui_theme_ozone_dark = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x000000, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0x9F9F9F, /* scrollbar */ 0xFFFFFF, /* divider */ 0x000000, /* screen_fade */ 0xDADADA, /* missing_thumbnail_icon */ 0.3f, /* header_shadow_opacity */ 0.45f, /* landscape_border_shadow_opacity */ + 0.8f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -500,6 +556,7 @@ static const materialui_theme_t materialui_theme_nord = { 0xECEFF4, /* list_text_highlighted */ 0x93E5CC, /* list_hint_text */ 0x93E5CC, /* list_hint_text_highlighted */ + 0x93E5CC, /* status_bar_text */ /* Background colours */ 0x000000, /* sys_bar_background */ 0x4C566A, /* title_bar_background */ @@ -508,6 +565,8 @@ static const materialui_theme_t materialui_theme_nord = { 0x3B4252, /* nav_bar_background */ 0x3B4252, /* surface_background */ 0x0B0B0B, /* thumbnail_background */ + 0x3f444f, /* side_bar_background */ + 0x191D23, /* status_bar_background */ /* List icon colours */ 0xD8DEE9, /* list_icon */ 0xA3BE8C, /* list_switch_on */ @@ -521,12 +580,14 @@ static const materialui_theme_t materialui_theme_nord = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x000000, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0xA0A5AD, /* scrollbar */ 0x81A1C1, /* divider */ 0x000000, /* screen_fade */ 0xD8DEE9, /* missing_thumbnail_icon */ 0.4f, /* header_shadow_opacity */ 0.45f, /* landscape_border_shadow_opacity */ + 0.8f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -538,6 +599,7 @@ static const materialui_theme_t materialui_theme_gruvbox_dark = { 0xFBF1C7, /* list_text_highlighted */ 0xD79921, /* list_hint_text */ 0xFABD2F, /* list_hint_text_highlighted */ + 0xD79921, /* status_bar_text */ /* Background colours */ 0x000000, /* sys_bar_background */ 0x504945, /* title_bar_background */ @@ -546,6 +608,8 @@ static const materialui_theme_t materialui_theme_gruvbox_dark = { 0x1D2021, /* nav_bar_background */ 0x32302F, /* surface_background */ 0x0B0B0B, /* thumbnail_background */ + 0x3C3836, /* side_bar_background */ + 0x161616, /* status_bar_background */ /* List icon colours */ 0xA89984, /* list_icon */ 0xB8BB26, /* list_switch_on */ @@ -559,12 +623,14 @@ static const materialui_theme_t materialui_theme_gruvbox_dark = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x000000, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0x7C6F64, /* scrollbar */ 0xD5C4A1, /* divider */ 0x000000, /* screen_fade */ 0xA89984, /* missing_thumbnail_icon */ 0.4f, /* header_shadow_opacity */ 0.45f, /* landscape_border_shadow_opacity */ + 0.8f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -576,6 +642,7 @@ static const materialui_theme_t materialui_theme_solarized_dark = { 0x93A1A1, /* list_text_highlighted */ 0x2AA198, /* list_hint_text */ 0x2AA198, /* list_hint_text_highlighted */ + 0x2AA198, /* status_bar_text */ /* Background colours */ 0x000000, /* sys_bar_background */ 0x053542, /* title_bar_background */ @@ -584,6 +651,8 @@ static const materialui_theme_t materialui_theme_solarized_dark = { 0x003541, /* nav_bar_background */ 0x073642, /* surface_background */ 0x0B0B0B, /* thumbnail_background */ + 0x073642, /* side_bar_background */ + 0x00181E, /* status_bar_background */ /* List icon colours */ 0x657B83, /* list_icon */ 0x859900, /* list_switch_on */ @@ -597,12 +666,14 @@ static const materialui_theme_t materialui_theme_solarized_dark = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x000000, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0x586E75, /* scrollbar */ 0x2AA198, /* divider */ 0x000000, /* screen_fade */ 0x657B83, /* missing_thumbnail_icon */ 0.4f, /* header_shadow_opacity */ 0.45f, /* landscape_border_shadow_opacity */ + 0.8f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -614,6 +685,7 @@ static const materialui_theme_t materialui_theme_cutie_blue = { 0xFFFFFF, /* list_text_highlighted */ 0xDADADA, /* list_hint_text */ 0xEEEEEE, /* list_hint_text_highlighted */ + 0xDADADA, /* status_bar_text */ /* Background colours */ 0x000000, /* sys_bar_background */ 0x353535, /* title_bar_background */ @@ -622,6 +694,8 @@ static const materialui_theme_t materialui_theme_cutie_blue = { 0x282828, /* nav_bar_background */ 0x333333, /* surface_background */ 0x000000, /* thumbnail_background */ + 0x333333, /* side_bar_background */ + 0x0E0E0E, /* status_bar_background */ /* List icon colours */ 0xFFFFFF, /* list_icon */ 0x3399FF, /* list_switch_on */ @@ -635,12 +709,14 @@ static const materialui_theme_t materialui_theme_cutie_blue = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x000000, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0x727272, /* scrollbar */ 0x727272, /* divider */ 0x000000, /* screen_fade */ 0xDADADA, /* missing_thumbnail_icon */ 0.3f, /* header_shadow_opacity */ 0.45f, /* landscape_border_shadow_opacity */ + 0.9f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -652,6 +728,7 @@ static const materialui_theme_t materialui_theme_cutie_cyan = { 0xFFFFFF, /* list_text_highlighted */ 0xDADADA, /* list_hint_text */ 0xEEEEEE, /* list_hint_text_highlighted */ + 0xDADADA, /* status_bar_text */ /* Background colours */ 0x000000, /* sys_bar_background */ 0x353535, /* title_bar_background */ @@ -660,6 +737,8 @@ static const materialui_theme_t materialui_theme_cutie_cyan = { 0x282828, /* nav_bar_background */ 0x333333, /* surface_background */ 0x000000, /* thumbnail_background */ + 0x333333, /* side_bar_background */ + 0x0E0E0E, /* status_bar_background */ /* List icon colours */ 0xFFFFFF, /* list_icon */ 0x39859A, /* list_switch_on */ @@ -673,12 +752,14 @@ static const materialui_theme_t materialui_theme_cutie_cyan = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x000000, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0x727272, /* scrollbar */ 0x727272, /* divider */ 0x000000, /* screen_fade */ 0xDADADA, /* missing_thumbnail_icon */ 0.3f, /* header_shadow_opacity */ 0.45f, /* landscape_border_shadow_opacity */ + 0.9f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -690,6 +771,7 @@ static const materialui_theme_t materialui_theme_cutie_green = { 0xFFFFFF, /* list_text_highlighted */ 0xDADADA, /* list_hint_text */ 0xEEEEEE, /* list_hint_text_highlighted */ + 0xDADADA, /* status_bar_text */ /* Background colours */ 0x000000, /* sys_bar_background */ 0x353535, /* title_bar_background */ @@ -698,6 +780,8 @@ static const materialui_theme_t materialui_theme_cutie_green = { 0x282828, /* nav_bar_background */ 0x333333, /* surface_background */ 0x000000, /* thumbnail_background */ + 0x333333, /* side_bar_background */ + 0x0E0E0E, /* status_bar_background */ /* List icon colours */ 0xFFFFFF, /* list_icon */ 0x23A367, /* list_switch_on */ @@ -711,12 +795,14 @@ static const materialui_theme_t materialui_theme_cutie_green = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x000000, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0x727272, /* scrollbar */ 0x727272, /* divider */ 0x000000, /* screen_fade */ 0xDADADA, /* missing_thumbnail_icon */ 0.3f, /* header_shadow_opacity */ 0.45f, /* landscape_border_shadow_opacity */ + 0.9f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -728,6 +814,7 @@ static const materialui_theme_t materialui_theme_cutie_orange = { 0xFFFFFF, /* list_text_highlighted */ 0xDADADA, /* list_hint_text */ 0xEEEEEE, /* list_hint_text_highlighted */ + 0xDADADA, /* status_bar_text */ /* Background colours */ 0x000000, /* sys_bar_background */ 0x353535, /* title_bar_background */ @@ -736,6 +823,8 @@ static const materialui_theme_t materialui_theme_cutie_orange = { 0x282828, /* nav_bar_background */ 0x333333, /* surface_background */ 0x000000, /* thumbnail_background */ + 0x333333, /* side_bar_background */ + 0x0E0E0E, /* status_bar_background */ /* List icon colours */ 0xFFFFFF, /* list_icon */ 0xCE6E1F, /* list_switch_on */ @@ -749,12 +838,14 @@ static const materialui_theme_t materialui_theme_cutie_orange = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x000000, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0x727272, /* scrollbar */ 0x727272, /* divider */ 0x000000, /* screen_fade */ 0xDADADA, /* missing_thumbnail_icon */ 0.3f, /* header_shadow_opacity */ 0.45f, /* landscape_border_shadow_opacity */ + 0.9f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -766,6 +857,7 @@ static const materialui_theme_t materialui_theme_cutie_pink = { 0xFFFFFF, /* list_text_highlighted */ 0xDADADA, /* list_hint_text */ 0xEEEEEE, /* list_hint_text_highlighted */ + 0xDADADA, /* status_bar_text */ /* Background colours */ 0x000000, /* sys_bar_background */ 0x353535, /* title_bar_background */ @@ -774,6 +866,8 @@ static const materialui_theme_t materialui_theme_cutie_pink = { 0x282828, /* nav_bar_background */ 0x333333, /* surface_background */ 0x000000, /* thumbnail_background */ + 0x333333, /* side_bar_background */ + 0x0E0E0E, /* status_bar_background */ /* List icon colours */ 0xFFFFFF, /* list_icon */ 0xD16FD8, /* list_switch_on */ @@ -787,12 +881,14 @@ static const materialui_theme_t materialui_theme_cutie_pink = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x000000, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0x727272, /* scrollbar */ 0x727272, /* divider */ 0x000000, /* screen_fade */ 0xDADADA, /* missing_thumbnail_icon */ 0.3f, /* header_shadow_opacity */ 0.45f, /* landscape_border_shadow_opacity */ + 0.9f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -804,6 +900,7 @@ static const materialui_theme_t materialui_theme_cutie_purple = { 0xFFFFFF, /* list_text_highlighted */ 0xDADADA, /* list_hint_text */ 0xEEEEEE, /* list_hint_text_highlighted */ + 0xDADADA, /* status_bar_text */ /* Background colours */ 0x000000, /* sys_bar_background */ 0x353535, /* title_bar_background */ @@ -812,6 +909,8 @@ static const materialui_theme_t materialui_theme_cutie_purple = { 0x282828, /* nav_bar_background */ 0x333333, /* surface_background */ 0x000000, /* thumbnail_background */ + 0x333333, /* side_bar_background */ + 0x0E0E0E, /* status_bar_background */ /* List icon colours */ 0xFFFFFF, /* list_icon */ 0x814FFF, /* list_switch_on */ @@ -825,12 +924,14 @@ static const materialui_theme_t materialui_theme_cutie_purple = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x000000, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0x727272, /* scrollbar */ 0x727272, /* divider */ 0x000000, /* screen_fade */ 0xDADADA, /* missing_thumbnail_icon */ 0.3f, /* header_shadow_opacity */ 0.45f, /* landscape_border_shadow_opacity */ + 0.9f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -842,6 +943,7 @@ static const materialui_theme_t materialui_theme_cutie_red = { 0xFFFFFF, /* list_text_highlighted */ 0xDADADA, /* list_hint_text */ 0xEEEEEE, /* list_hint_text_highlighted */ + 0xDADADA, /* status_bar_text */ /* Background colours */ 0x000000, /* sys_bar_background */ 0x353535, /* title_bar_background */ @@ -850,6 +952,8 @@ static const materialui_theme_t materialui_theme_cutie_red = { 0x282828, /* nav_bar_background */ 0x333333, /* surface_background */ 0x000000, /* thumbnail_background */ + 0x333333, /* side_bar_background */ + 0x0E0E0E, /* status_bar_background */ /* List icon colours */ 0xFFFFFF, /* list_icon */ 0xCB1619, /* list_switch_on */ @@ -863,12 +967,14 @@ static const materialui_theme_t materialui_theme_cutie_red = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x000000, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0x727272, /* scrollbar */ 0x727272, /* divider */ 0x000000, /* screen_fade */ 0xDADADA, /* missing_thumbnail_icon */ 0.3f, /* header_shadow_opacity */ 0.45f, /* landscape_border_shadow_opacity */ + 0.9f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -880,6 +986,7 @@ static const materialui_theme_t materialui_theme_virtual_boy = { 0xF00000, /* list_text_highlighted */ 0xE60000, /* list_hint_text */ 0xF00000, /* list_hint_text_highlighted */ + 0xE60000, /* status_bar_text */ /* Background colours */ 0x000000, /* sys_bar_background */ 0x350000, /* title_bar_background */ @@ -888,6 +995,8 @@ static const materialui_theme_t materialui_theme_virtual_boy = { 0x350000, /* nav_bar_background */ 0x400000, /* surface_background */ 0x250000, /* thumbnail_background */ + 0x400000, /* side_bar_background */ + 0x000000, /* status_bar_background */ /* List icon colours */ 0xE60000, /* list_icon */ 0xE60000, /* list_switch_on */ @@ -901,12 +1010,14 @@ static const materialui_theme_t materialui_theme_virtual_boy = { /* Misc. colours */ 0x000000, /* header_shadow */ 0x000000, /* landscape_border_shadow */ + 0x000000, /* status_bar_shadow */ 0xA10000, /* scrollbar */ 0xE60000, /* divider */ 0x000000, /* screen_fade */ 0xE60000, /* missing_thumbnail_icon */ 0.3f, /* header_shadow_opacity */ 0.45f, /* landscape_border_shadow_opacity */ + 0.7f, /* status_bar_shadow_opacity */ 0.75f /* screen_fade_opacity */ }; @@ -919,6 +1030,7 @@ typedef struct uint32_t list_text_highlighted; uint32_t list_hint_text; uint32_t list_hint_text_highlighted; + uint32_t status_bar_text; /* Background colours */ float sys_bar_background[16]; float title_bar_background[16]; @@ -927,6 +1039,8 @@ typedef struct float nav_bar_background[16]; float surface_background[16]; float thumbnail_background[16]; + float side_bar_background[16]; + float status_bar_background[16]; /* System bar + header icon colours */ float sys_bar_icon[16]; float header_icon[16]; @@ -944,11 +1058,14 @@ typedef struct float header_shadow[16]; float landscape_border_shadow_left[16]; float landscape_border_shadow_right[16]; + float status_bar_shadow[16]; float scrollbar[16]; float divider[16]; + float entry_divider[16]; float screen_fade[16]; float missing_thumbnail_icon[16]; float landscape_border_shadow_opacity; + float status_bar_shadow_opacity; float screen_fade_opacity; } materialui_colors_t; @@ -995,7 +1112,8 @@ enum materialui_list_view_type MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_SMALL, MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_MEDIUM, MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_LARGE, - MUI_LIST_VIEW_PLAYLIST_THUMB_DUAL_ICON + MUI_LIST_VIEW_PLAYLIST_THUMB_DUAL_ICON, + MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP }; /* This structure holds auxiliary information for @@ -1005,8 +1123,10 @@ typedef struct { bool has_icon; unsigned icon_texture_index; + float entry_width; float entry_height; float text_height; + float x; float y; /* Thumbnail containers */ @@ -1091,6 +1211,18 @@ enum MUI_TEXTURE_LAST }; +/* This structure holds all runtime parameters + * associated with landscape optimisation + * (enable state, border width, nominal + * additional horizontal margin/padding for + * menu entries) */ +typedef struct +{ + bool enabled; + unsigned border_width; + unsigned entry_margin; +} materialui_landscape_optimization_t; + /* Maximum number of menu tabs that can be shown on * the navigation bar */ #define MUI_NAV_BAR_NUM_MENU_TABS_MAX 3 @@ -1214,6 +1346,25 @@ typedef struct int timedate_width; } materialui_sys_bar_cache_t; +/* This structure holds all runtime parameters + * for the status bar (used to display auxiliary + * information at the bottom of the current list + * view). At present, this enables metadata for + * the currently selected playlist entry to be + * shown when using the 'desktop'-layout */ +typedef struct +{ + bool enabled; + bool cached; + size_t last_selected; + float delay_timer; + float alpha; + unsigned height; + char str[MENU_SUBLABEL_MAX_LENGTH]; + char runtime_fallback_str[255]; + char last_played_fallback_str[255]; +} materialui_status_bar_t; + /* Animation defines */ #define MUI_ANIM_DURATION_SCROLL 166.66667f #define MUI_ANIM_DURATION_SCROLL_RESET 83.333333f @@ -1256,6 +1407,8 @@ typedef struct materialui_handle enum materialui_landscape_layout_optimization_type last_landscape_layout_optimization; + materialui_landscape_optimization_t + landscape_optimization; playlist_t *playlist; @@ -1273,7 +1426,6 @@ typedef struct materialui_handle unsigned sys_bar_icon_size; unsigned margin; unsigned sys_bar_margin; - unsigned landscape_entry_margin; unsigned entry_divider_width; unsigned sublabel_gap; unsigned sublabel_padding; @@ -1363,6 +1515,9 @@ typedef struct materialui_handle float fullscreen_thumbnail_alpha; char fullscreen_thumbnail_label[255]; + /* Status bar */ + materialui_status_bar_t status_bar; + enum materialui_list_view_type list_view_type; } materialui_handle_t; @@ -1442,6 +1597,7 @@ static void materialui_prepare_colors( mui->colors.list_text_highlighted = (current_theme->list_text_highlighted << 8) | 0xFF; mui->colors.list_hint_text = (current_theme->list_hint_text << 8) | 0xFF; mui->colors.list_hint_text_highlighted = (current_theme->list_hint_text_highlighted << 8) | 0xFF; + mui->colors.status_bar_text = (current_theme->status_bar_text << 8) | 0xFF; /* > Background colours */ hex32_to_rgba_normalized( @@ -1465,6 +1621,12 @@ static void materialui_prepare_colors( hex32_to_rgba_normalized( current_theme->thumbnail_background, mui->colors.thumbnail_background, 1.0f); + hex32_to_rgba_normalized( + current_theme->side_bar_background, + mui->colors.side_bar_background, 1.0f); + hex32_to_rgba_normalized( + current_theme->status_bar_background, + mui->colors.status_bar_background, 1.0f); /* > System bar + header icon colours */ hex32_to_rgba_normalized( @@ -1512,12 +1674,18 @@ static void materialui_prepare_colors( hex32_to_rgba_normalized( current_theme->landscape_border_shadow, mui->colors.landscape_border_shadow_right, 0.0f); + hex32_to_rgba_normalized( + current_theme->status_bar_shadow, + mui->colors.status_bar_shadow, 0.0f); hex32_to_rgba_normalized( current_theme->scrollbar, mui->colors.scrollbar, 1.0f); hex32_to_rgba_normalized( current_theme->divider, mui->colors.divider, 1.0f); + hex32_to_rgba_normalized( + current_theme->divider, + mui->colors.entry_divider, 1.0f); hex32_to_rgba_normalized( current_theme->missing_thumbnail_icon, mui->colors.missing_thumbnail_icon, 1.0f); @@ -1539,6 +1707,9 @@ static void materialui_prepare_colors( mui->colors.landscape_border_shadow_right[3] = current_theme->landscape_border_shadow_opacity; mui->colors.landscape_border_shadow_right[11] = current_theme->landscape_border_shadow_opacity; mui->colors.landscape_border_shadow_opacity = current_theme->landscape_border_shadow_opacity; + mui->colors.status_bar_shadow[11] = current_theme->status_bar_shadow_opacity; + mui->colors.status_bar_shadow[15] = current_theme->status_bar_shadow_opacity; + mui->colors.status_bar_shadow_opacity = current_theme->status_bar_shadow_opacity; } static const char *materialui_texture_path(unsigned id) @@ -1684,6 +1855,31 @@ static const char *materialui_texture_path(unsigned id) return NULL; } +static void INLINE materialui_font_bind(materialui_font_data_t *font_data) +{ + font_driver_bind_block(font_data->font, &font_data->raster_block); + font_data->raster_block.carr.coords.vertices = 0; +} + +static void INLINE materialui_font_unbind(materialui_font_data_t *font_data) +{ + font_driver_bind_block(font_data->font, NULL); +} + +void materialui_font_flush( + unsigned video_width, unsigned video_height, + materialui_font_data_t *font_data) +{ + /* Flushing is slow - only do it if font + * has actually been used */ + if (!font_data || + (font_data->raster_block.carr.coords.vertices == 0)) + return; + + font_driver_flush(video_width, video_height, font_data->font); + font_data->raster_block.carr.coords.vertices = 0; +} + static void materialui_context_reset_textures(materialui_handle_t *mui) { bool has_all_assets = true; @@ -1722,7 +1918,6 @@ static void materialui_draw_icon( unsigned icon_size, uintptr_t texture, float x, float y, - unsigned width, unsigned height, float rotation, float scale_factor, float *color) { @@ -1749,7 +1944,7 @@ static void materialui_draw_icon( coords.color = (const float*)color; draw.x = x; - draw.y = height - y - icon_size; + draw.y = video_height - y - icon_size; draw.width = icon_size; draw.height = icon_size; draw.scale_factor = scale_factor; @@ -1772,7 +1967,6 @@ static void materialui_draw_thumbnail( unsigned video_width, unsigned video_height, float x, float y, - unsigned width, unsigned height, float scale_factor) { float bg_x; @@ -1797,6 +1991,10 @@ static void materialui_draw_thumbnail( case GFX_THUMBNAIL_STATUS_MISSING: { float icon_size = (float)mui->icon_size; + float alpha = mui->transition_alpha * thumbnail->alpha; + + if (alpha <= 0.0f) + return; /* Adjust icon size based on scale factor */ if (scale_factor < 1.0f) @@ -1804,8 +2002,7 @@ static void materialui_draw_thumbnail( /* Background */ gfx_display_set_alpha( - mui->colors.thumbnail_background, - mui->transition_alpha); + mui->colors.thumbnail_background, alpha); gfx_display_draw_quad( userdata, @@ -1815,11 +2012,14 @@ static void materialui_draw_thumbnail( bg_y, (unsigned)bg_width, (unsigned)bg_height, - width, - height, + video_width, + video_height, mui->colors.thumbnail_background); /* Icon */ + gfx_display_set_alpha( + mui->colors.missing_thumbnail_icon, alpha); + materialui_draw_icon( userdata, video_width, @@ -1828,8 +2028,6 @@ static void materialui_draw_thumbnail( mui->textures.list[MUI_TEXTURE_IMAGE], bg_x + (bg_width - icon_size) / 2.0f, bg_y + (bg_height - icon_size) / 2.0f, - width, - height, 0.0f, 1.0f, mui->colors.missing_thumbnail_icon); @@ -1872,8 +2070,8 @@ static void materialui_draw_thumbnail( (int)bg_y, (unsigned)(bg_width + 0.5f), (unsigned)(bg_height + 1.5f), - width, - height, + video_width, + video_height, mui->colors.thumbnail_background); } @@ -1990,23 +2188,13 @@ end: string_list_free(list); } -/* Used for the sublabels */ -static unsigned materialui_count_lines(const char *str) -{ - unsigned c = 0; - unsigned lines = 1; - - for (c = 0; str[c]; c++) - lines += (str[c] == '\n'); - return lines; -} - /* Initialises scrollbar parameters (width/height) */ static void materialui_scrollbar_init( materialui_handle_t* mui, unsigned width, unsigned height, unsigned header_height) { - int view_height = (int)height - (int)header_height - (int)mui->nav_bar_layout_height; + int view_height = (int)height - (int)header_height - + (int)mui->nav_bar_layout_height - (int)mui->status_bar.height; int scrollbar_height; /* Set initial defaults */ @@ -2044,56 +2232,149 @@ static void materialui_scrollbar_init( * set elsewhere */ } +/* ============================== + * materialui_compute_entries_box() START + * ============================== */ + /* Calculate physical size of each menu entry, plus * any derived screen dimensions of menu list elements */ -static void materialui_compute_entries_box( + +/* Utility functions */ + +/* > Returns number of lines in a string */ +static unsigned materialui_count_lines(const char *str) +{ + unsigned c = 0; + unsigned lines = 1; + + for (c = 0; str[c]; c++) + lines += (str[c] == '\n'); + return lines; +} + +/* > Returns number of lines required to display + * the sublabel of entry 'entry_idx' */ +static unsigned materialui_count_sublabel_lines( + materialui_handle_t* mui, int usable_width, + size_t entry_idx, bool has_icon) +{ + menu_entry_t entry; + char wrapped_sublabel_str[MENU_SUBLABEL_MAX_LENGTH]; + const char *sublabel_str = NULL; + int sublabel_width_max = 0; + + wrapped_sublabel_str[0] = '\0'; + + /* Get entry sublabel */ + menu_entry_init(&entry); + entry.path_enabled = false; + entry.label_enabled = false; + entry.rich_label_enabled = false; + entry.value_enabled = false; + menu_entry_get(&entry, 0, entry_idx, NULL, true); + + menu_entry_get_sublabel(&entry, &sublabel_str); + + /* If sublabel is empty, return immediately */ + if (string_is_empty(sublabel_str)) + return 0; + + /* Wrap sublabel string to fit available width */ + sublabel_width_max = usable_width - (int)mui->sublabel_padding - + (has_icon ? (int)mui->icon_size : 0); + + word_wrap( + wrapped_sublabel_str, sublabel_str, + sublabel_width_max / (int)mui->font_data.hint.glyph_width, + false, 0); + + /* Return number of lines in wrapped string */ + return materialui_count_lines(wrapped_sublabel_str); +} + +/* Used for standard, non-playlist entries + * > MUI_LIST_VIEW_DEFAULT */ +static void materialui_compute_entries_box_default( materialui_handle_t* mui, unsigned width, unsigned height, unsigned header_height) { - unsigned i; - int usable_width = - (int)width - (int)(mui->margin * 2) - (int)(mui->landscape_entry_margin * 2) - (int)mui->nav_bar_layout_width; - file_list_t *list = menu_entries_get_selection_buf_ptr(0); - float sum = 0; - size_t entries_end = menu_entries_get_size(); - - /* If this is a playlist and the 'dual icon' - * thumbnail view mode is enabled, each node has - * a fixed height - and we can skip all the - * usual calculations */ - if (mui->list_view_type == MUI_LIST_VIEW_PLAYLIST_THUMB_DUAL_ICON) - { - /* One line of list text */ - float node_text_height = (float)mui->font_data.list.line_height; - /* List text + thumbnail height + padding */ - float node_entry_height = - node_text_height + (float)mui->thumbnail_height_max + - ((float)mui->dip_base_unit_size / 5.0f); - - for (i = 0; i < entries_end; i++) - { - materialui_node_t *node = (materialui_node_t*) - file_list_get_userdata_at_offset(list, i); - - node->text_height = node_text_height; - node->entry_height = node_entry_height; - node->y = sum; - sum += node_entry_height; - } - - mui->content_height = sum; - - /* Total height is now known - can initialise scrollbar */ - materialui_scrollbar_init(mui, width, height, header_height); + size_t i; + file_list_t *list = menu_entries_get_selection_buf_ptr(0); + float node_entry_width = (float)width - + (float)(mui->landscape_optimization.border_width * 2) - + (float)mui->nav_bar_layout_width; + float node_x = (float)mui->landscape_optimization.border_width; + int usable_width = node_entry_width - + (int)(mui->margin * 2) - + (int)(mui->landscape_optimization.entry_margin * 2); + float sum = 0; + if (!list) return; + + for (i = 0; i < menu_entries_get_size(); i++) + { + unsigned num_sublabel_lines = 0; + materialui_node_t *node = (materialui_node_t*) + file_list_get_userdata_at_offset(list, i); + + if (!node) + continue; + + num_sublabel_lines = materialui_count_sublabel_lines( + mui, usable_width, i, + (node->has_icon && mui->textures.list[node->icon_texture_index])); + + node->text_height = mui->font_data.list.line_height + + (num_sublabel_lines * mui->font_data.hint.line_height); + + node->entry_height = node->text_height + + mui->dip_base_unit_size / 10; + + node->entry_height += mui->dip_base_unit_size / 10; + node->y = sum; + + node->entry_width = node_entry_width; + node->x = node_x; + + sum += node->entry_height; } - /* If this is a playlist and any other thumbnail view - * mode is enabled, must reduce usable width by - * thumbnail width */ - if ((mui->list_view_type != MUI_LIST_VIEW_DEFAULT) && - (mui->list_view_type != MUI_LIST_VIEW_PLAYLIST)) + mui->content_height = sum; + + /* Total height is now known - can initialise scrollbar */ + materialui_scrollbar_init(mui, width, height, header_height); +} + +/* Used for playlist 'list view' (with and without + * thumbnails) entries + * > MUI_LIST_VIEW_PLAYLIST + * > MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_SMALL + * > MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_MEDIUM + * > MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_LARGE */ +static void materialui_compute_entries_box_playlist_list( + materialui_handle_t* mui, + unsigned width, unsigned height, unsigned header_height) +{ + size_t i; + file_list_t *list = menu_entries_get_selection_buf_ptr(0); + float node_entry_width = (float)width - + (float)(mui->landscape_optimization.border_width * 2) - + (float)mui->nav_bar_layout_width; + float node_x = (float)mui->landscape_optimization.border_width; + int usable_width = node_entry_width - (int)(mui->margin * 2); + float sum = 0; + + if (!list) + return; + + /* If thumbnails are *not* enabled, decrease usable + * width by landscape optimisation entry margin */ + if (mui->list_view_type == MUI_LIST_VIEW_PLAYLIST) + usable_width -= (int)(mui->landscape_optimization.entry_margin * 2); + /* If a thumbnail view mode is enabled, must reduce + * usable width by thumbnail width */ + else { int thumbnail_margin = 0; @@ -2105,60 +2386,26 @@ static void materialui_compute_entries_box( } /* Account for additional padding in landscape mode */ else - if (mui->landscape_entry_margin < mui->margin) - thumbnail_margin = (int)(mui->margin - mui->landscape_entry_margin); + thumbnail_margin = (int)mui->margin; usable_width -= mui->thumbnail_width_max + thumbnail_margin; /* Account for second thumbnail, if enabled */ if (mui->secondary_thumbnail_enabled) usable_width -= mui->thumbnail_width_max + thumbnail_margin; - /* If there is no second thumbnail and landscape - * optimisations are active, increase width to - * balance x offset of primary thumbnail */ - else if (mui->landscape_entry_margin > 0) - usable_width += (mui->margin > mui->landscape_entry_margin) ? - (int)mui->landscape_entry_margin : (int)mui->margin; } - for (i = 0; i < entries_end; i++) + for (i = 0; i < menu_entries_get_size(); i++) { - menu_entry_t entry; - char wrapped_sublabel_str[MENU_SUBLABEL_MAX_LENGTH]; - const char *sublabel_str = NULL; - unsigned num_sublabel_lines = 0; - materialui_node_t *node = (materialui_node_t*) - file_list_get_userdata_at_offset(list, i); + unsigned num_sublabel_lines = 0; + materialui_node_t *node = (materialui_node_t*) + file_list_get_userdata_at_offset(list, i); - wrapped_sublabel_str[0] = '\0'; + if (!node) + continue; - menu_entry_init(&entry); - entry.path_enabled = false; - entry.label_enabled = false; - entry.rich_label_enabled = false; - entry.value_enabled = false; - menu_entry_get(&entry, 0, i, NULL, true); - - menu_entry_get_sublabel(&entry, &sublabel_str); - - if (!string_is_empty(sublabel_str)) - { - int sublabel_width_max = usable_width - (int)mui->sublabel_padding; - - /* If this is a default menu list with an icon, - * must subtract icon size from sublabel width */ - if (mui->list_view_type == MUI_LIST_VIEW_DEFAULT) - if (node->has_icon) - if (mui->textures.list[node->icon_texture_index]) - sublabel_width_max -= (int)mui->icon_size; - - word_wrap( - wrapped_sublabel_str, sublabel_str, - sublabel_width_max / (int)mui->font_data.hint.glyph_width, - false, 0); - - num_sublabel_lines = materialui_count_lines(wrapped_sublabel_str); - } + num_sublabel_lines = materialui_count_sublabel_lines( + mui, usable_width, i, false); node->text_height = mui->font_data.list.line_height + (num_sublabel_lines * mui->font_data.hint.line_height); @@ -2166,16 +2413,19 @@ static void materialui_compute_entries_box( node->entry_height = node->text_height + mui->dip_base_unit_size / 10; - /* If this is a playlist and thumbnails are enabled, - * must ensure that line_height is greater than - * maximum thumbnail height */ - if ((mui->list_view_type != MUI_LIST_VIEW_DEFAULT) && - (mui->list_view_type != MUI_LIST_VIEW_PLAYLIST)) + /* If thumbnails are enabled, must ensure + * that line_height is greater than maximum + * thumbnail height */ + if (mui->list_view_type != MUI_LIST_VIEW_PLAYLIST) node->entry_height = (node->entry_height < mui->thumbnail_height_max) ? mui->thumbnail_height_max : node->entry_height; node->entry_height += mui->dip_base_unit_size / 10; node->y = sum; + + node->entry_width = node_entry_width; + node->x = node_x; + sum += node->entry_height; } @@ -2185,6 +2435,126 @@ static void materialui_compute_entries_box( materialui_scrollbar_init(mui, width, height, header_height); } +/* Used for playlist 'dual icon' entries + * > MUI_LIST_VIEW_PLAYLIST_THUMB_DUAL_ICON */ +static void materialui_compute_entries_box_playlist_dual_icon( + materialui_handle_t* mui, + unsigned width, unsigned height, unsigned header_height) +{ + size_t i; + file_list_t *list = menu_entries_get_selection_buf_ptr(0); + float node_entry_width = (float)width - + (float)(mui->landscape_optimization.border_width * 2) - + (float)mui->nav_bar_layout_width; + float node_x = (float)mui->landscape_optimization.border_width; + /* Entry height is constant: + * > One line of list text */ + float node_text_height = (float)mui->font_data.list.line_height; + /* > List text + thumbnail height + padding */ + float node_entry_height = node_text_height + + (float)mui->thumbnail_height_max + + ((float)mui->dip_base_unit_size / 5.0f); + float sum = 0; + + if (!list) + return; + + for (i = 0; i < menu_entries_get_size(); i++) + { + materialui_node_t *node = (materialui_node_t*) + file_list_get_userdata_at_offset(list, i); + + if (!node) + continue; + + node->text_height = node_text_height; + node->entry_width = node_entry_width; + node->entry_height = node_entry_height; + node->x = node_x; + node->y = sum; + sum += node_entry_height; + } + + mui->content_height = sum; + + /* Total height is now known - can initialise scrollbar */ + materialui_scrollbar_init(mui, width, height, header_height); +} + +/* Used for playlist 'desktop'-layout entries + * > MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP */ +static void materialui_compute_entries_box_playlist_desktop( + materialui_handle_t* mui, + unsigned width, unsigned height, unsigned header_height) +{ + size_t i; + file_list_t *list = menu_entries_get_selection_buf_ptr(0); + /* Entry width is available screen width minus + * thumbnail sidebar + * > Note: If landscape optimisations are enabled, + * need to allow space for a second divider at + * the left hand edge of the sidebar */ + float node_entry_width = (float)width - + (float)(mui->landscape_optimization.border_width * 2) - + (float)mui->nav_bar_layout_width - + (float)mui->thumbnail_width_max - + (float)(mui->margin * 2) - + (float)(mui->entry_divider_width * + (mui->landscape_optimization.enabled ? + 2 : 1)); + /* Entry x position is the right hand edge of + * the thumbnail sidebar */ + float node_x = (float)mui->landscape_optimization.border_width + + (float)mui->thumbnail_width_max + (float)(mui->margin * 2) + + (float)(mui->entry_divider_width * + (mui->landscape_optimization.enabled ? + 2 : 1)); + /* Entry height: + * > One line of list text */ + float node_text_height = (float)mui->font_data.list.line_height; + /* > List text + padding + * Note: Since this is intended for the desktop, + * use less padding than normal to increase list + * density (each entry will still be large enough + * to select with a finger via touchscreen, but + * this is optimised for gamepad/keyboard) */ + float node_entry_height = node_text_height + + ((float)mui->dip_base_unit_size / 7.0f); + float sum = 0; + + if (!list) + return; + + for (i = 0; i < menu_entries_get_size(); i++) + { + materialui_node_t *node = (materialui_node_t*) + file_list_get_userdata_at_offset(list, i); + + if (!node) + continue; + + node->text_height = node_text_height; + node->entry_width = node_entry_width; + node->entry_height = node_entry_height; + node->x = node_x; + node->y = sum; + sum += node_entry_height; + } + + mui->content_height = sum; + + /* Total height is now known - can initialise scrollbar */ + materialui_scrollbar_init(mui, width, height, header_height); +} + +static void (*materialui_compute_entries_box)( + materialui_handle_t* mui, + unsigned width, unsigned height, unsigned header_height) = materialui_compute_entries_box_default; + +/* ============================== + * materialui_compute_entries_box() END + * ============================== */ + /* Compute the scroll value depending on the highlighted entry */ static float materialui_get_scroll(materialui_handle_t *mui) { @@ -2207,8 +2577,8 @@ static float materialui_get_scroll(materialui_handle_t *mui) /* Get the vertical midpoint of the actual * list view - i.e. account for header + * navigation bar */ - view_centre = - (float)(height - header_height - mui->nav_bar_layout_height) / 2.0f; + view_centre = (float)(height - header_height - mui->nav_bar_layout_height - + mui->status_bar.height) / 2.0f; /* Get the vertical midpoint of the currently * selected entry */ @@ -2313,12 +2683,284 @@ static INLINE void materialui_kill_scroll_animation( mui->scroll_animation_selection = 0; } +/* ============================== + * materialui_render_process_entry() START + * ============================== */ + +/* Handles any auxiliary entry-specific processing + * required during the per-frame 'materialui_render()' + * task. This typically involves the loading/unloading + * of playlist thumbnails. + * > Should be called within a loop over all entries + * in the current menu list + * > If return value is false, loop should break + * (i.e. indicates that last entry to be processed + * has been found) */ + +/* Used for non-playlist menus, and playlists + * without thumbnails (i.e. any list without + * thumbnails) + * > MUI_LIST_VIEW_DEFAULT + * > MUI_LIST_VIEW_PLAYLIST + * Returns false when the last on-screen entry + * is detected */ +static bool materialui_render_process_entry_default( + materialui_handle_t* mui, + materialui_node_t *node, + size_t entry_idx, size_t selection, + bool first_entry_found, bool last_entry_found, + unsigned thumbnail_upscale_threshold, + bool network_on_demand_thumbnails) +{ + /* 'Normal' menu lists require no entry-specific + * processing */ + return !last_entry_found; +} + +/* Used for 'list view' playlists *with* + * thumbnails + * > MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_SMALL + * > MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_MEDIUM + * > MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_LARGE + * Always returns true */ +static bool materialui_render_process_entry_playlist_thumb_list( + materialui_handle_t* mui, + materialui_node_t *node, + size_t entry_idx, size_t selection, + bool first_entry_found, bool last_entry_found, + unsigned thumbnail_upscale_threshold, + bool network_on_demand_thumbnails) +{ + bool on_screen = first_entry_found && !last_entry_found; + + /* Load thumbnails for all on-screen entries + * and free thumbnails for all off-screen entries */ + if (mui->secondary_thumbnail_enabled) + gfx_thumbnail_process_streams( + mui->thumbnail_path_data, mui->playlist, entry_idx, + &node->thumbnails.primary, &node->thumbnails.secondary, + on_screen, + thumbnail_upscale_threshold, + network_on_demand_thumbnails); + else + gfx_thumbnail_process_stream( + mui->thumbnail_path_data, GFX_THUMBNAIL_RIGHT, + mui->playlist, entry_idx, &node->thumbnails.primary, + on_screen, + thumbnail_upscale_threshold, + network_on_demand_thumbnails); + + /* Always return true - every entry must + * be processed */ + return true; +} + +/* Used for 'dual icon' playlists + * > MUI_LIST_VIEW_PLAYLIST_THUMB_DUAL_ICON + * Always returns true */ +static bool materialui_render_process_entry_playlist_dual_icon( + materialui_handle_t* mui, + materialui_node_t *node, + size_t entry_idx, size_t selection, + bool first_entry_found, bool last_entry_found, + unsigned thumbnail_upscale_threshold, + bool network_on_demand_thumbnails) +{ + bool on_screen = first_entry_found && !last_entry_found; + + /* Load thumbnails for all on-screen entries + * and free thumbnails for all off-screen entries + * > Note that secondary thumbnail is force + * enabled in dual icon mode */ + gfx_thumbnail_process_streams( + mui->thumbnail_path_data, mui->playlist, entry_idx, + &node->thumbnails.primary, &node->thumbnails.secondary, + on_screen, + thumbnail_upscale_threshold, + network_on_demand_thumbnails); + + /* Always return true - every entry must + * be processed */ + return true; +} + +/* Used for 'desktop'-layout playlists + * > MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP + * Always returns true */ +static bool materialui_render_process_entry_playlist_desktop( + materialui_handle_t* mui, + materialui_node_t *node, + size_t entry_idx, size_t selection, + bool first_entry_found, bool last_entry_found, + unsigned thumbnail_upscale_threshold, + bool network_on_demand_thumbnails) +{ + bool is_selected = (entry_idx == selection); + + /* Load thumbnails for selected entry and free + * thumbnails for all other entries + * > Note that secondary thumbnail is force + * enabled */ + gfx_thumbnail_process_streams( + mui->thumbnail_path_data, mui->playlist, entry_idx, + &node->thumbnails.primary, &node->thumbnails.secondary, + is_selected, + thumbnail_upscale_threshold, + network_on_demand_thumbnails); + + /* Fetch metadata for selected entry */ + if (is_selected && mui->status_bar.enabled) + { + gfx_animation_ctx_tag alpha_tag = (uintptr_t)&mui->status_bar.alpha; + + /* Reset metadata if current selection + * has changed */ + if (selection != mui->status_bar.last_selected) + { + gfx_animation_kill_by_tag(&alpha_tag); + + mui->status_bar.cached = false; + mui->status_bar.last_selected = selection; + mui->status_bar.delay_timer = 0.0f; + mui->status_bar.alpha = 0.0f; + mui->status_bar.str[0] = '\0'; + } + + /* Check whether metadata needs to be cached */ + if (!mui->status_bar.cached) + { + /* Check if delay timer has elapsed */ + mui->status_bar.delay_timer += gfx_animation_get_delta_time(); + + if (mui->status_bar.delay_timer > gfx_thumbnail_get_stream_delay()) + { + settings_t *settings = config_get_ptr(); + bool content_runtime_log = settings->bools.content_runtime_log; + bool content_runtime_log_aggregate = settings->bools.content_runtime_log_aggregate; + const char *directory_runtime_log = settings->paths.directory_runtime_log; + const char *directory_playlist = settings->paths.directory_playlist; + unsigned runtime_type = settings->uints.playlist_sublabel_runtime_type; + enum playlist_sublabel_last_played_style_type + runtime_last_played_style = + (enum playlist_sublabel_last_played_style_type) + settings->uints.playlist_sublabel_last_played_style; + float fade_duration = gfx_thumbnail_get_fade_duration(); + const struct playlist_entry *entry = NULL; + const char *core_name = NULL; + const char *runtime_str = NULL; + const char *last_played_str = NULL; + int n; + + /* Read playlist entry */ + playlist_get_index(mui->playlist, selection, &entry); + + /* Sanity check */ + if (!entry) + { + /* If this happens, then everything is + * broken - just ensure that metadata + * string is NUL and set cached status + * to 'true' to avoid reading this + * broken playlist again... */ + mui->status_bar.str[0] = '\0'; + mui->status_bar.cached = true; + return true; + } + + /* Get core name */ + if (string_is_empty(entry->core_name) || + string_is_equal(entry->core_name, "DETECT")) + core_name = msg_hash_to_str(MSG_AUTODETECT); + else + core_name = entry->core_name; + + /* Get runtime info, if available */ + if (content_runtime_log || content_runtime_log_aggregate) + { + if (entry->runtime_status == PLAYLIST_RUNTIME_UNKNOWN) + runtime_update_playlist( + mui->playlist, selection, + directory_runtime_log, + directory_playlist, + (runtime_type == PLAYLIST_RUNTIME_PER_CORE), + runtime_last_played_style); + + if (!string_is_empty(entry->runtime_str)) + runtime_str = entry->runtime_str; + + if (!string_is_empty(entry->last_played_str)) + last_played_str = entry->last_played_str; + } + + /* Set fallback strings, if required */ + if (string_is_empty(runtime_str)) + runtime_str = mui->status_bar.runtime_fallback_str; + + if (string_is_empty(last_played_str)) + last_played_str = mui->status_bar.last_played_fallback_str; + + /* Generate metadata string */ + n = snprintf(mui->status_bar.str, sizeof(mui->status_bar.str), + "%s %s%s%s%s%s", + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_CORE), + core_name, + MUI_TICKER_SPACER, + runtime_str, + MUI_TICKER_SPACER, + last_played_str); + + if ((n < 0) || (n >= 255)) + n = 0; /* Silence GCC warnings... */ + + /* All metadata is cached */ + mui->status_bar.cached = true; + + /* Trigger fade in animation */ + if (fade_duration > 0.0f) + { + gfx_animation_ctx_entry_t animation_entry; + + mui->status_bar.alpha = 0.0f; + + animation_entry.easing_enum = EASING_OUT_QUAD; + animation_entry.tag = alpha_tag; + animation_entry.duration = fade_duration; + animation_entry.target_value = 1.0f; + animation_entry.subject = &mui->status_bar.alpha; + animation_entry.cb = NULL; + animation_entry.userdata = NULL; + + gfx_animation_push(&animation_entry); + } + else + mui->status_bar.alpha = 1.0f; + } + } + } + + /* Always return true - every entry must + * be processed */ + return true; +} + +static bool (*materialui_render_process_entry)( + materialui_handle_t* mui, + materialui_node_t *node, + size_t entry_idx, size_t selection, + bool first_entry_found, bool last_entry_found, + unsigned thumbnail_upscale_threshold, + bool network_on_demand_thumbnails) = materialui_render_process_entry_default; + +/* ============================== + * materialui_render_process_entry() END + * ============================== */ + static void materialui_layout( materialui_handle_t *mui, bool video_is_threaded); /* Called on each frame. We use this callback to: * - Determine current scroll position - * - Determine index of first/last onscreen entries + * - Determine index of first/last on-screen entries * - Handle dynamic pointer input * - Handle streaming thumbnails */ static void materialui_render(void *data, @@ -2332,6 +2974,7 @@ static void materialui_render(void *data, materialui_handle_t *mui = (materialui_handle_t*)data; unsigned header_height = gfx_display_get_header_height(); size_t entries_end = menu_entries_get_size(); + size_t selection = menu_navigation_get_selection(); file_list_t *list = menu_entries_get_selection_buf_ptr(0); bool first_entry_found = false; bool last_entry_found = false; @@ -2424,7 +3067,8 @@ static void materialui_render(void *data, * y position */ if (mui->scrollbar.dragged) { - float view_height = (float)height - (float)header_height - (float)mui->nav_bar_layout_height; + float view_height = (float)height - (float)header_height - + (float)mui->nav_bar_layout_height - (float)mui->status_bar.height; float view_y = (float)mui->pointer.y - (float)header_height; float y_scroll_max = mui->content_height - view_height; @@ -2451,11 +3095,12 @@ static void materialui_render(void *data, if (mui->scroll_y < 0.0f) mui->scroll_y = 0.0f; - bottom = mui->content_height - (float)height + (float)header_height + (float)mui->nav_bar_layout_height; + bottom = mui->content_height - (float)height + (float)header_height + + (float)mui->nav_bar_layout_height + (float)mui->status_bar.height; if (mui->scroll_y > bottom) mui->scroll_y = bottom; - if (mui->content_height < (height - header_height - mui->nav_bar_layout_height)) + if (mui->content_height < (height - header_height - mui->nav_bar_layout_height - mui->status_bar.height)) mui->scroll_y = 0.0f; /* Loop over all entries */ @@ -2466,13 +3111,15 @@ static void materialui_render(void *data, { materialui_node_t *node = (materialui_node_t*) file_list_get_userdata_at_offset(list, i); + int entry_x; int entry_y; /* Sanity check */ if (!node) break; - /* Get current entry y position */ + /* Get current entry x/y position */ + entry_x = (int)node->x; entry_y = (int)((float)header_height - mui->scroll_y + node->y); /* Check whether this is the first on screen entry */ @@ -2487,7 +3134,7 @@ static void materialui_render(void *data, /* Check whether this is the last on screen entry */ else if (!last_entry_found) { - if (entry_y > ((int)height - (int)mui->nav_bar_layout_height)) + if (entry_y > ((int)height - (int)mui->nav_bar_layout_height - (int)mui->status_bar.height)) { /* Current entry is off screen - get index * of previous entry */ @@ -2512,14 +3159,16 @@ static void materialui_render(void *data, /* Check if pointer is within the 'list' region of * the window (i.e. exclude header, navigation bar, * landscape borders) */ - if ((pointer_x > mui->landscape_entry_margin) && - (pointer_x < width - mui->landscape_entry_margin - mui->nav_bar_layout_width) && + if ((pointer_x > mui->landscape_optimization.border_width) && + (pointer_x < width - mui->landscape_optimization.border_width - mui->nav_bar_layout_width) && (pointer_y >= header_height) && - (pointer_y <= height - mui->nav_bar_layout_height)) + (pointer_y <= height - mui->nav_bar_layout_height - mui->status_bar.height)) { /* Check if pointer is within the bounds of the * current entry */ - if ((pointer_y > entry_y) && + if ((pointer_x > entry_x) && + (pointer_x < (entry_x + node->entry_width)) && + (pointer_y > entry_y) && (pointer_y < (entry_y + node->entry_height))) { /* Pointer selection is always updated */ @@ -2541,6 +3190,7 @@ static void materialui_render(void *data, if (mui->pointer.press_duration >= MENU_INPUT_PRESS_TIME_SHORT) { menu_navigation_set_selection(i); + selection = i; /* Once an entry has been auto selected, disable * touch feedback selection updates until the next @@ -2553,36 +3203,27 @@ static void materialui_render(void *data, } } - /* If this is a playlist and thumbnails are enabled, - * have to load thumbnails for all on-screen entries - * and free thumbnails for all off-screen entries */ - if ((mui->list_view_type != MUI_LIST_VIEW_DEFAULT) && - (mui->list_view_type != MUI_LIST_VIEW_PLAYLIST)) - { - bool on_screen = - first_entry_found && !last_entry_found; - - if (mui->secondary_thumbnail_enabled) - gfx_thumbnail_process_streams( - mui->thumbnail_path_data, mui->playlist, i, - &node->thumbnails.primary, &node->thumbnails.secondary, - on_screen, - thumbnail_upscale_threshold, - network_on_demand_thumbnails); - else - gfx_thumbnail_process_stream( - mui->thumbnail_path_data, GFX_THUMBNAIL_RIGHT, - mui->playlist, i, &node->thumbnails.primary, on_screen, - thumbnail_upscale_threshold, - network_on_demand_thumbnails); - } - else if (last_entry_found) + /* Perform any additional processing required + * for the current entry */ + if (!materialui_render_process_entry( + mui, node, i, selection, + first_entry_found, last_entry_found, + thumbnail_upscale_threshold, + network_on_demand_thumbnails)) break; } menu_entries_ctl(MENU_ENTRIES_CTL_SET_START, &mui->first_onscreen_entry); } +/* ============================== + * materialui_render_menu_entry() START + * ============================== */ + +/* Draws specified menu entry */ + +/* Utility functions */ + enum materialui_entry_value_type materialui_get_entry_value_type( materialui_handle_t *mui, const char *entry_value, bool entry_checked, @@ -2656,11 +3297,12 @@ enum materialui_entry_value_type materialui_get_entry_value_type( static void materialui_render_switch_icon( materialui_handle_t *mui, + materialui_node_t *node, void *userdata, unsigned video_width, unsigned video_height, float y, - unsigned width, unsigned height, int x_offset, + int x_offset, bool on) { unsigned switch_texture_index = on ? @@ -2669,9 +3311,9 @@ static void materialui_render_switch_icon( mui->colors.list_switch_on_background : mui->colors.list_switch_off_background; float *switch_color = on ? mui->colors.list_switch_on : mui->colors.list_switch_off; - int x = - x_offset + (int)width - (int)mui->margin - (int)mui->landscape_entry_margin - - (int)mui->nav_bar_layout_width - (int)mui->icon_size; + int x = x_offset + node->x + node->entry_width - + (int)mui->landscape_optimization.entry_margin - + (int)mui->margin - (int)mui->icon_size; /* Draw background */ if (mui->textures.list[MUI_TEXTURE_SWITCH_BG]) @@ -2683,8 +3325,6 @@ static void materialui_render_switch_icon( mui->textures.list[MUI_TEXTURE_SWITCH_BG], x, y, - width, - height, 0, 1, bg_color); @@ -2699,16 +3339,13 @@ static void materialui_render_switch_icon( mui->textures.list[switch_texture_index], x, y, - width, - height, 0, 1, switch_color); } -/* Draws specified menu entry - * > Used for standard, non-playlist entries - * >> MUI_LIST_VIEW_DEFAULT */ +/* Used for standard, non-playlist entries + * > MUI_LIST_VIEW_DEFAULT */ static void materialui_render_menu_entry_default( materialui_handle_t *mui, void *userdata, @@ -2717,9 +3354,9 @@ static void materialui_render_menu_entry_default( materialui_node_t *node, menu_entry_t *entry, bool entry_selected, + bool entry_is_last, bool touch_feedback_active, unsigned header_height, - unsigned width, unsigned height, int x_offset) { const char *entry_value = NULL; @@ -2729,10 +3366,11 @@ static void materialui_render_menu_entry_default( enum materialui_entry_value_type entry_value_type = MUI_ENTRY_VALUE_NONE; unsigned entry_value_width = 0; enum msg_file_type entry_file_type = FILE_TYPE_NONE; + int entry_x = x_offset + node->x; int entry_y = header_height - mui->scroll_y + node->y; - int entry_margin = (int)mui->margin + (int)mui->landscape_entry_margin; - int usable_width = - (int)width - (int)(mui->margin * 2) - (int)(mui->landscape_entry_margin * 2) - (int)mui->nav_bar_layout_width; + int entry_margin = (int)mui->margin + (int)mui->landscape_optimization.entry_margin; + int usable_width = (int)node->entry_width - + (int)(mui->margin * 2) - (int)(mui->landscape_optimization.entry_margin * 2); int label_y = 0; int value_icon_y = 0; uintptr_t icon_texture = 0; @@ -2779,8 +3417,8 @@ static void materialui_render_menu_entry_default( /* Note that we have to perform a backup check here, * since the 'manual content scan - file extensions' * setting may have a value of 'zip' or '7z' etc, which - * means it would otherwise get incorreclty identified as - * an achive file... */ + * means it would otherwise get incorrectly identified as + * an archive file... */ if (entry_type == FILE_TYPE_CARCHIVE) icon_texture = mui->textures.list[MUI_TEXTURE_ARCHIVE]; break; @@ -2800,10 +3438,8 @@ static void materialui_render_menu_entry_default( video_height, mui->icon_size, (uintptr_t)icon_texture, - x_offset + (int)mui->landscape_entry_margin, + entry_x + (int)mui->landscape_optimization.entry_margin, entry_y + (node->entry_height / 2.0f) - (mui->icon_size / 2.0f), - width, - height, 0, 1, mui->colors.list_icon); @@ -2853,9 +3489,9 @@ static void materialui_render_menu_entry_default( * early as they are scrolled upwards beyond the top edge * of the screen */ gfx_display_draw_text(mui->font_data.hint.font, wrapped_sublabel, - x_offset + entry_margin, + entry_x + entry_margin, sublabel_y, - width, height, + video_width, video_height, (entry_selected || touch_feedback_active) ? mui->colors.list_hint_text_highlighted : mui->colors.list_hint_text, TEXT_ALIGN_LEFT, 1.0f, false, 0, draw_text_outside || (sublabel_y < 0)); @@ -2934,9 +3570,9 @@ static void materialui_render_menu_entry_default( /* Draw value string */ gfx_display_draw_text(mui->font_data.list.font, value_buf, - x_offset + value_x_offset + (int)width - (int)mui->margin - (int)mui->landscape_entry_margin - (int)mui->nav_bar_layout_width, + entry_x + value_x_offset + node->entry_width - (int)mui->margin - (int)mui->landscape_optimization.entry_margin, label_y, - width, height, + video_width, video_height, (entry_selected || touch_feedback_active) ? mui->colors.list_text_highlighted : mui->colors.list_text, TEXT_ALIGN_RIGHT, 1.0f, false, 0, draw_text_outside); @@ -2944,17 +3580,15 @@ static void materialui_render_menu_entry_default( break; case MUI_ENTRY_VALUE_SWITCH_ON: { - materialui_render_switch_icon( - mui, userdata, video_width, - video_height, value_icon_y, width, height, x_offset, true); + materialui_render_switch_icon(mui, node, userdata, + video_width, video_height, value_icon_y, x_offset, true); entry_value_width = mui->icon_size; } break; case MUI_ENTRY_VALUE_SWITCH_OFF: { - materialui_render_switch_icon( - mui, userdata, video_width, - video_height, value_icon_y, width, height, x_offset, false); + materialui_render_switch_icon(mui, node, userdata, + video_width, video_height, value_icon_y, x_offset, false); entry_value_width = mui->icon_size; } break; @@ -2968,10 +3602,8 @@ static void materialui_render_menu_entry_default( video_height, mui->icon_size, mui->textures.list[MUI_TEXTURE_CHECKMARK], - x_offset + (int)width - (int)mui->margin - (int)mui->landscape_entry_margin - (int)mui->nav_bar_layout_width - (int)mui->icon_size, + entry_x + node->entry_width - (int)mui->margin - (int)mui->landscape_optimization.entry_margin - (int)mui->icon_size, value_icon_y, - width, - height, 0, 1, mui->colors.list_switch_on); @@ -3023,9 +3655,9 @@ static void materialui_render_menu_entry_default( /* Draw label string */ gfx_display_draw_text(mui->font_data.list.font, label_buf, - x_offset + (int)mui->ticker_x_offset + entry_margin, + (int)mui->ticker_x_offset + entry_x + entry_margin, label_y, - width, height, + video_width, video_height, (entry_selected || touch_feedback_active) ? mui->colors.list_text_highlighted : mui->colors.list_text, TEXT_ALIGN_LEFT, 1.0f, false, 0, draw_text_outside); @@ -3033,13 +3665,12 @@ static void materialui_render_menu_entry_default( } } -/* Draws specified menu entry - * > Used for playlist 'list view' (with and without +/* Used for playlist 'list view' (with and without * thumbnails) entries - * >> MUI_LIST_VIEW_PLAYLIST - * >> MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_SMALL - * >> MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_MEDIUM - * >> MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_LARGE */ + * > MUI_LIST_VIEW_PLAYLIST + * > MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_SMALL + * > MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_MEDIUM + * > MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_LARGE */ static void materialui_render_menu_entry_playlist_list( materialui_handle_t *mui, void *userdata, @@ -3048,17 +3679,17 @@ static void materialui_render_menu_entry_playlist_list( materialui_node_t *node, menu_entry_t *entry, bool entry_selected, + bool entry_is_last, bool touch_feedback_active, unsigned header_height, - unsigned width, unsigned height, int x_offset) { const char *entry_label = NULL; const char *entry_sublabel = NULL; + int entry_x = x_offset + node->x; int entry_y = header_height - mui->scroll_y + node->y; - int entry_margin = (int)mui->margin + (int)mui->landscape_entry_margin; - int usable_width = - (int)width - (int)(mui->margin * 2) - (int)(mui->landscape_entry_margin * 2) - (int)mui->nav_bar_layout_width; + int entry_margin = (int)mui->margin; + int usable_width = (int)node->entry_width - (int)(mui->margin * 2); int label_y = 0; bool draw_text_outside = (x_offset != 0); @@ -3077,15 +3708,24 @@ static void materialui_render_menu_entry_playlist_list( menu_entry_get_rich_label(entry, &entry_label); menu_entry_get_sublabel(entry, &entry_sublabel); + /* If thumbnails are *not* enabled, increase entry + * margin and decrease usable width by landscape + * optimisation margin */ + if (mui->list_view_type == MUI_LIST_VIEW_PLAYLIST) + { + entry_margin += (int)mui->landscape_optimization.entry_margin; + usable_width -= (int)(mui->landscape_optimization.entry_margin * 2); + } /* Draw entry thumbnail(s) * > Has to be done first, since it affects the left * hand margin size and total width for label + * sublabel text */ - if (mui->list_view_type != MUI_LIST_VIEW_PLAYLIST) + else { int thumbnail_margin = 0; - float thumbnail_y = - (float)entry_y + ((float)node->entry_height / 2.0f) - ((float)mui->thumbnail_height_max / 2.0f); + float thumbnail_y = (float)entry_y + + ((float)node->entry_height / 2.0f) - + ((float)mui->thumbnail_height_max / 2.0f); /* When using portrait display orientations with * secondary thumbnails enabled, have to add a @@ -3099,13 +3739,9 @@ static void materialui_render_menu_entry_playlist_list( } /* When using landscape display orientations, we * have enough screen space to improve thumbnail - * appearance by adding left/right margins - but - * we only need to do this if landscape optimisations - * are disabled (or landscape_entry_margin is less - * than mui->margin) */ + * appearance by adding left/right margins */ else - if (mui->landscape_entry_margin < mui->margin) - thumbnail_margin = (int)(mui->margin - mui->landscape_entry_margin); + thumbnail_margin = (int)mui->margin; /* Draw primary thumbnail */ materialui_draw_thumbnail( @@ -3114,10 +3750,8 @@ static void materialui_render_menu_entry_playlist_list( userdata, video_width, video_height, - (float)(x_offset + thumbnail_margin + (int)mui->landscape_entry_margin), + (float)(entry_x + thumbnail_margin), thumbnail_y, - width, - height, 1.0f); entry_margin += mui->thumbnail_width_max + thumbnail_margin; @@ -3132,23 +3766,12 @@ static void materialui_render_menu_entry_playlist_list( userdata, video_width, video_height, - (float)(x_offset + (int)width - thumbnail_margin - (int)mui->landscape_entry_margin - - (int)mui->nav_bar_layout_width - (int)mui->thumbnail_width_max), + (float)(entry_x + node->entry_width - thumbnail_margin - (int)mui->thumbnail_width_max), thumbnail_y, - width, - height, 1.0f); usable_width -= mui->thumbnail_width_max + thumbnail_margin; } - /* If there is no secondary thumbnail and landscape - * optimisations are active, must increase usable width - * to balance out the margin of the primary thumbnail - * (since this is effectively left shifted when landscape - * optimisations are active...) */ - else if (mui->landscape_entry_margin > 0) - usable_width += (mui->margin > mui->landscape_entry_margin) ? - (int)mui->landscape_entry_margin : (int)mui->margin; } /* Draw entry sublabel @@ -3186,9 +3809,9 @@ static void materialui_render_menu_entry_playlist_list( * early as they are scrolled upwards beyond the top edge * of the screen */ gfx_display_draw_text(mui->font_data.hint.font, wrapped_sublabel, - x_offset + entry_margin, + entry_x + entry_margin, sublabel_y, - width, height, + video_width, video_height, (entry_selected || touch_feedback_active) ? mui->colors.list_hint_text_highlighted : mui->colors.list_hint_text, TEXT_ALIGN_LEFT, 1.0f, false, 0, draw_text_outside || (sublabel_y < 0)); @@ -3230,9 +3853,9 @@ static void materialui_render_menu_entry_playlist_list( /* Draw label string */ gfx_display_draw_text(mui->font_data.list.font, label_buf, - x_offset + (int)mui->ticker_x_offset + entry_margin, + (int)mui->ticker_x_offset + entry_x + entry_margin, label_y, - width, height, + video_width, video_height, (entry_selected || touch_feedback_active) ? mui->colors.list_text_highlighted : mui->colors.list_text, TEXT_ALIGN_LEFT, 1.0f, false, 0, draw_text_outside); @@ -3246,28 +3869,24 @@ static void materialui_render_menu_entry_playlist_list( * by drawing a divider between entries. This is particularly * beneficial when dual thumbnails are enabled, since it * 'ties' the left/right thumbnails together */ - if ((mui->list_view_type == MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_SMALL) || - (mui->list_view_type == MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_MEDIUM) || - (mui->list_view_type == MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_LARGE)) - { - if (usable_width > 0) - gfx_display_draw_quad( - userdata, - video_width, - video_height, - (float)(x_offset + entry_margin), - entry_y + (float)node->entry_height, - (unsigned)usable_width, - mui->entry_divider_width, - width, - height, - mui->colors.divider); - } + if (!entry_is_last && + (mui->list_view_type != MUI_LIST_VIEW_PLAYLIST) && + (usable_width > 0)) + gfx_display_draw_quad( + userdata, + video_width, + video_height, + (float)(entry_x + entry_margin), + entry_y + (float)node->entry_height, + (unsigned)usable_width, + mui->entry_divider_width, + video_width, + video_height, + mui->colors.entry_divider); } -/* Draws specified menu entry - * > Used for playlist 'dual icon' entries - * >> MUI_LIST_VIEW_PLAYLIST_THUMB_DUAL_ICON */ +/* Used for playlist 'dual icon' entries + * > MUI_LIST_VIEW_PLAYLIST_THUMB_DUAL_ICON */ static void materialui_render_menu_entry_playlist_dual_icon( materialui_handle_t *mui, void *userdata, @@ -3276,16 +3895,15 @@ static void materialui_render_menu_entry_playlist_dual_icon( materialui_node_t *node, menu_entry_t *entry, bool entry_selected, + bool entry_is_last, bool touch_feedback_active, unsigned header_height, - unsigned width, unsigned height, int x_offset) { const char *entry_label = NULL; - int usable_width = - (int)width - (int)(mui->margin * 2) - - (int)(mui->landscape_entry_margin * 2) - (int)mui->nav_bar_layout_width; + float entry_x = (float)x_offset + node->x; float entry_y = (float)header_height - mui->scroll_y + node->y; + int usable_width = (int)node->entry_width - (int)(mui->margin * 2); float thumbnail_y; /* Initial ticker configuration @@ -3304,8 +3922,7 @@ static void materialui_render_menu_entry_playlist_dual_icon( /* Draw thumbnails * > These go at the top of the entry, with a * small vertical margin */ - thumbnail_y = - entry_y + ((float)mui->dip_base_unit_size / 10.0f); + thumbnail_y = entry_y + ((float)mui->dip_base_unit_size / 10.0f); /* > Primary thumbnail */ materialui_draw_thumbnail( @@ -3314,10 +3931,8 @@ static void materialui_render_menu_entry_playlist_dual_icon( userdata, video_width, video_height, - (float)(x_offset + (int)mui->margin + (int)mui->landscape_entry_margin), + entry_x + (float)mui->margin, thumbnail_y, - width, - height, 1.0f); /* > Secondary thumbnail */ @@ -3327,11 +3942,8 @@ static void materialui_render_menu_entry_playlist_dual_icon( userdata, video_width, video_height, - (float)(x_offset + (int)width - (int)mui->margin - (int)mui->landscape_entry_margin - - (int)mui->nav_bar_layout_width - (int)mui->thumbnail_width_max), + entry_x + node->entry_width - (float)mui->margin - (float)mui->thumbnail_width_max, thumbnail_y, - width, - height, 1.0f); /* Draw entry label */ @@ -3383,14 +3995,13 @@ static void materialui_render_menu_entry_playlist_dual_icon( } } - label_x += (float)(x_offset + (int)mui->ticker_x_offset + - (int)mui->margin + (int)mui->landscape_entry_margin); + label_x += (float)mui->ticker_x_offset + entry_x + (float)mui->margin; /* Draw label string */ gfx_display_draw_text(mui->font_data.list.font, label_buf, label_x, label_y, - width, height, + video_width, video_height, (entry_selected || touch_feedback_active) ? mui->colors.list_text_highlighted : mui->colors.list_text, TEXT_ALIGN_LEFT, 1.0f, false, 0, draw_text_outside); @@ -3398,28 +4009,362 @@ static void materialui_render_menu_entry_playlist_dual_icon( } /* Draw divider */ - if (usable_width > 0) + if (!entry_is_last && (usable_width > 0)) gfx_display_draw_quad( userdata, video_width, video_height, - (float)(x_offset + (int)mui->margin + (int)mui->landscape_entry_margin), + entry_x + (float)mui->margin, thumbnail_y + (float)mui->thumbnail_height_max + ((float)mui->dip_base_unit_size / 10.0f) + (float)mui->font_data.list.line_height, (unsigned)usable_width, mui->entry_divider_width, - width, - height, - mui->colors.divider); + video_width, + video_height, + mui->colors.entry_divider); } -static void materialui_render_scrollbar( +/* Used for playlist 'desktop'-layout entries + * > MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP */ +static void materialui_render_menu_entry_playlist_desktop( materialui_handle_t *mui, void *userdata, unsigned video_width, unsigned video_height, - unsigned width, unsigned height) + materialui_node_t *node, + menu_entry_t *entry, + bool entry_selected, + bool entry_is_last, + bool touch_feedback_active, + unsigned header_height, + int x_offset) +{ + const char *entry_label = NULL; + int entry_x = x_offset + node->x; + int entry_y = header_height - mui->scroll_y + node->y; + int divider_y = entry_y + (float)node->entry_height; + int entry_margin = (int)mui->margin; + int usable_width = node->entry_width - (int)(mui->margin * 2); + /* Entry label is drawn at the vertical centre + * of the current node */ + int label_y = entry_y + (node->entry_height / 2.0f) + + mui->font_data.list.line_centre_offset; + bool draw_text_outside = (x_offset != 0); + bool draw_divider = !entry_is_last; + + /* Read entry parameters */ + menu_entry_get_rich_label(entry, &entry_label); + + /* Draw entry label */ + if (!string_is_empty(entry_label)) + { + char label_buf[255]; + + label_buf[0] = '\0'; + + if (usable_width > 0) + { + /* Apply ticker */ + if (mui->use_smooth_ticker) + { + mui->ticker_smooth.font = mui->font_data.list.font; + mui->ticker_smooth.selected = entry_selected; + mui->ticker_smooth.field_width = (unsigned)usable_width; + mui->ticker_smooth.src_str = entry_label; + mui->ticker_smooth.dst_str = label_buf; + mui->ticker_smooth.dst_str_len = sizeof(label_buf); + + gfx_animation_ticker_smooth(&mui->ticker_smooth); + } + else + { + mui->ticker.selected = entry_selected; + mui->ticker.s = label_buf; + mui->ticker.len = (size_t)(usable_width / mui->font_data.list.glyph_width); + mui->ticker.str = entry_label; + + gfx_animation_ticker(&mui->ticker); + } + + /* Draw text */ + gfx_display_draw_text(mui->font_data.list.font, label_buf, + (int)mui->ticker_x_offset + entry_x + entry_margin, + label_y, + video_width, video_height, + (entry_selected || touch_feedback_active) ? + mui->colors.list_text_highlighted : mui->colors.list_text, + TEXT_ALIGN_LEFT, 1.0f, false, 0, draw_text_outside); + } + } + + /* Draw divider + * > To prevent any ugly alignment issues, we + * only draw a divider if its bottom edge is + * more than two times the divider thickness from + * the top edge of the status bar... */ + draw_divider = draw_divider && (usable_width > 0) && + (mui->status_bar.enabled ? + ((divider_y + (mui->entry_divider_width * 2)) < + (video_height - mui->nav_bar_layout_height - mui->status_bar.height)) : + true); + + if (draw_divider) + gfx_display_draw_quad( + userdata, + video_width, + video_height, + (float)entry_x, + (float)divider_y, + (unsigned)node->entry_width, + mui->entry_divider_width, + video_width, + video_height, + mui->colors.entry_divider); +} + +static void (*materialui_render_menu_entry)( + materialui_handle_t *mui, + void *userdata, + unsigned video_width, + unsigned video_height, + materialui_node_t *node, + menu_entry_t *entry, + bool entry_selected, + bool entry_is_last, + bool touch_feedback_active, + unsigned header_height, + int x_offset) = materialui_render_menu_entry_default; + +/* ============================== + * materialui_render_menu_entry() END + * ============================== */ + +/* ============================== + * materialui_render_selected_entry_aux() START + * ============================== */ + +/* Draws any auxiliary items required for the + * currently selected menu entry */ + +/* Used for 'desktop'-layout playlist displays. + * Draws thumbnails + metadata for currently + * selected item. + * > MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP */ +static void materialui_render_selected_entry_aux_playlist_desktop( + materialui_handle_t *mui, void *userdata, + unsigned video_width, unsigned video_height, + unsigned header_height, int x_offset, + file_list_t *list, size_t selection) +{ + materialui_node_t *node = (materialui_node_t*)file_list_get_userdata_at_offset(list, selection); + float background_x = (float)(x_offset + (int)mui->landscape_optimization.border_width); + float background_y = (float)header_height; + /* Note: If landscape optimisations are enabled, + * need to allow space for a second divider at + * the left hand edge of the sidebar */ + int background_width = mui->thumbnail_width_max + (mui->margin * 2) + + (mui->entry_divider_width * (mui->landscape_optimization.enabled ? + 2 : 1)); + int background_height = (int)video_height - (int)header_height - + (int)mui->nav_bar_layout_height - (int)mui->status_bar.height; + float thumbnail_x = background_x + (float)mui->margin + + (mui->landscape_optimization.enabled ? mui->entry_divider_width : 0); + float thumbnail_y = background_y + (float)mui->margin; + + /* Sanity check */ + if ((background_width <= 0) || + (background_height <= 0)) + return; + + /* Draw sidebar background + * > Surface */ + gfx_display_draw_quad( + userdata, + video_width, + video_height, + background_x, + background_y, + (unsigned)background_width, + (unsigned)background_height, + video_width, + video_height, + mui->colors.side_bar_background); + + /* > Divider */ + gfx_display_draw_quad( + userdata, + video_width, + video_height, + background_x + (float)background_width - (float)mui->entry_divider_width, + background_y, + mui->entry_divider_width, + (unsigned)background_height, + video_width, + video_height, + mui->colors.entry_divider); + + /* > Additional divider */ + if (mui->landscape_optimization.enabled) + gfx_display_draw_quad( + userdata, + video_width, + video_height, + background_x, + background_y, + mui->entry_divider_width, + (unsigned)background_height, + video_width, + video_height, + mui->colors.entry_divider); + + /* Draw thumbnails */ + + /* > Primary */ + if (node) + materialui_draw_thumbnail( + mui, + &node->thumbnails.primary, + userdata, + video_width, + video_height, + thumbnail_x, + thumbnail_y, + 1.0f); + + /* > Secondary */ + if (node) + materialui_draw_thumbnail( + mui, + &node->thumbnails.secondary, + userdata, + video_width, + video_height, + thumbnail_x, + thumbnail_y + (float)mui->thumbnail_height_max + (float)mui->margin, + 1.0f); + + /* Draw status bar */ + if (mui->status_bar.enabled) + { + float status_bar_x = background_x; + float status_bar_y = (float)(video_height - mui->nav_bar_layout_height - mui->status_bar.height); + int status_bar_width = (int)video_width - (int)(mui->landscape_optimization.border_width * 2) - + (int)mui->nav_bar_layout_width; + int text_width = status_bar_width - (int)(mui->margin * 2); + + /* Sanity check */ + if (status_bar_width <= 0) + return; + + /* Status bar overlaps list entries + * > Must flush list font before attempting + * to draw it */ + materialui_font_flush(video_width, video_height, &mui->font_data.list); + + /* Background + * > Surface */ + gfx_display_draw_quad( + userdata, + video_width, + video_height, + status_bar_x, + status_bar_y, + (unsigned)status_bar_width, + mui->status_bar.height, + video_width, + video_height, + mui->colors.status_bar_background); + + /* > Shadow + * (For symmetry, header and status bar + * shadows have the same height) */ + gfx_display_draw_quad( + userdata, + video_width, + video_height, + status_bar_x, + status_bar_y, + (unsigned)status_bar_width, + mui->header_shadow_height, + video_width, + video_height, + mui->colors.status_bar_shadow); + + /* Text */ + if ((text_width > 0) && !string_is_empty(mui->status_bar.str)) + { + bool draw_text_outside = (x_offset != 0); + uint32_t text_color = mui->colors.status_bar_text; + float text_x = 0.0f; + char metadata_buf[MENU_SUBLABEL_MAX_LENGTH]; + + metadata_buf[0] = '\0'; + + /* Set text opacity */ + text_color = (text_color & 0xFFFFFF00) | + (unsigned)((255.0f * mui->transition_alpha * mui->status_bar.alpha) + 0.5f); + + /* Apply ticker */ + if (mui->use_smooth_ticker) + { + mui->ticker_smooth.font = mui->font_data.hint.font; + mui->ticker_smooth.selected = true; + mui->ticker_smooth.field_width = (unsigned)text_width; + mui->ticker_smooth.src_str = mui->status_bar.str; + mui->ticker_smooth.dst_str = metadata_buf; + mui->ticker_smooth.dst_str_len = sizeof(metadata_buf); + + gfx_animation_ticker_smooth(&mui->ticker_smooth); + + /* If ticker is inactive, centre the text */ + if (!gfx_animation_ticker_smooth(&mui->ticker_smooth)) + text_x = (float)(text_width - mui->ticker_str_width) / 2.0f; + } + else + { + mui->ticker.selected = true; + mui->ticker.s = metadata_buf; + mui->ticker.len = (size_t)(text_width / mui->font_data.hint.glyph_width); + mui->ticker.str = mui->status_bar.str; + + /* If ticker is inactive, centre the text */ + if (!gfx_animation_ticker(&mui->ticker)) + { + int str_width = (int)(utf8len(metadata_buf) * + mui->font_data.hint.glyph_width); + + text_x = (float)(text_width - str_width) / 2.0f; + } + } + + text_x += (float)mui->ticker_x_offset + status_bar_x + (float)mui->margin; + + /* Draw metadata string */ + gfx_display_draw_text(mui->font_data.hint.font, metadata_buf, + text_x, + status_bar_y + ((float)mui->status_bar.height * 0.5f) + + (float)mui->font_data.hint.line_centre_offset, + video_width, video_height, + text_color, + TEXT_ALIGN_LEFT, 1.0f, false, 0, draw_text_outside); + } + } +} + +static void (*materialui_render_selected_entry_aux)( + materialui_handle_t *mui, void *userdata, + unsigned video_width, unsigned video_height, + unsigned header_height, int x_offset, + file_list_t *list, size_t selection) = NULL; + +/* ============================== + * materialui_render_selected_entry_aux() END + * ============================== */ + +static void materialui_render_scrollbar( + materialui_handle_t *mui, void *userdata, + unsigned video_width, unsigned video_height) { /* Do nothing if scrollbar is disabled */ if (!mui->scrollbar.active) @@ -3434,16 +4379,15 @@ static void materialui_render_scrollbar( mui->scrollbar.y, mui->scrollbar.width, mui->scrollbar.height, - width, height, + video_width, + video_height, mui->colors.scrollbar); } /* Draws current menu list */ static void materialui_render_menu_list( - materialui_handle_t *mui, - void *userdata, + materialui_handle_t *mui, void *userdata, unsigned video_width, unsigned video_height, - unsigned width, unsigned height, int x_offset) { size_t i; @@ -3458,6 +4402,10 @@ static void materialui_render_menu_list( !mui->show_fullscreen_thumbnails && (mui->touch_feedback_alpha >= 0.5f) && (mui->touch_feedback_selection == menu_input_get_pointer_selection()); + bool entry_value_enabled = (mui->list_view_type == MUI_LIST_VIEW_DEFAULT); + bool entry_sublabel_enabled = + (mui->list_view_type != MUI_LIST_VIEW_PLAYLIST_THUMB_DUAL_ICON) && + (mui->list_view_type != MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP); list = menu_entries_get_selection_buf_ptr(0); if (!list) @@ -3470,6 +4418,7 @@ static void materialui_render_menu_list( for (i = first_entry; i <= last_entry; i++) { bool entry_selected = (selection == i); + bool entry_is_last = (i == last_entry); bool touch_feedback_active = touch_feedback_enabled && (mui->touch_feedback_selection == i); materialui_node_t *node = (materialui_node_t*)file_list_get_userdata_at_offset(list, i); menu_entry_t entry; @@ -3481,82 +4430,38 @@ static void materialui_render_menu_list( /* Get current entry */ menu_entry_init(&entry); entry.path_enabled = false; - entry.value_enabled = (mui->list_view_type == MUI_LIST_VIEW_DEFAULT); - entry.sublabel_enabled = (mui->list_view_type != MUI_LIST_VIEW_PLAYLIST_THUMB_DUAL_ICON); + entry.value_enabled = entry_value_enabled; + entry.sublabel_enabled = entry_sublabel_enabled; menu_entry_get(&entry, 0, i, NULL, true); - /* Render label, value, and associated icons - * TODO/FIXME: Yes, I know this is ugly... - * Once we refactor the code to enable alternative - * non-list-type view modes (e.g. grid, coverflow), - * this sort of thing will be handled via function - * pointers (we'll need these in several places: - * handling pointer input, loading thumbnails, - * menu drawing, selection highlight drawing, - * etc.). Until then, a simple switch (and a bunch - * of duplicated code in the two render_menu_entry - * functions) will suffice... */ - switch (mui->list_view_type) - { - case MUI_LIST_VIEW_PLAYLIST: - case MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_SMALL: - case MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_MEDIUM: - case MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_LARGE: - materialui_render_menu_entry_playlist_list( - mui, - userdata, - video_width, - video_height, - node, - &entry, - entry_selected, - touch_feedback_active, - header_height, - width, - height, - x_offset); - break; - case MUI_LIST_VIEW_PLAYLIST_THUMB_DUAL_ICON: - materialui_render_menu_entry_playlist_dual_icon( - mui, - userdata, - video_width, - video_height, - node, - &entry, - entry_selected, - touch_feedback_active, - header_height, - width, - height, - x_offset); - break; - case MUI_LIST_VIEW_DEFAULT: - default: - materialui_render_menu_entry_default( - mui, - userdata, - video_width, - video_height, - node, - &entry, - entry_selected, - touch_feedback_active, - header_height, - width, - height, - x_offset); - break; - } + /* Render entry: label, value + associated icons */ + materialui_render_menu_entry( + mui, + userdata, + video_width, + video_height, + node, + &entry, + entry_selected, + entry_is_last, + touch_feedback_active, + header_height, + x_offset); } + /* Draw any auxiliary items required for the + * currently selected entry */ + if (materialui_render_selected_entry_aux) + materialui_render_selected_entry_aux( + mui, userdata, + video_width, video_height, + header_height, x_offset, + list, selection); + /* Draw scrollbar */ materialui_render_scrollbar( - mui, - userdata, - video_width, - video_height, - width, height); + mui, userdata, + video_width, video_height); } static size_t materialui_list_get_size(void *data, enum menu_list_type type) @@ -3651,16 +4556,15 @@ static void materialui_render_landscape_border( void *userdata, unsigned video_width, unsigned video_height, - unsigned width, unsigned height, unsigned header_height, int x_offset) + unsigned header_height, int x_offset) { - if (mui->landscape_entry_margin > mui->margin) + if (mui->landscape_optimization.enabled) { - unsigned border_width = mui->landscape_entry_margin - mui->margin; - unsigned border_height = height - header_height - mui->nav_bar_layout_height; + unsigned border_height = video_height - header_height - mui->nav_bar_layout_height; int left_x = x_offset; - int right_x = - x_offset + (int)width - (int)mui->landscape_entry_margin + - (int)mui->margin - (int)mui->nav_bar_layout_width; + int right_x = x_offset + (int)video_width - + (int)mui->nav_bar_layout_width - + (int)mui->landscape_optimization.border_width; int y = (int)header_height; /* Draw left border */ @@ -3670,10 +4574,10 @@ static void materialui_render_landscape_border( video_height, left_x, y, - border_width, + mui->landscape_optimization.border_width, border_height, - width, - height, + video_width, + video_height, mui->colors.landscape_border_shadow_left); /* Draw right border */ @@ -3683,20 +4587,18 @@ static void materialui_render_landscape_border( video_height, right_x, y, - border_width, + mui->landscape_optimization.border_width, border_height, - width, - height, + video_width, + video_height, mui->colors.landscape_border_shadow_right); } } static void materialui_render_selection_highlight( - materialui_handle_t *mui, - void *userdata, - unsigned video_width, - unsigned video_height, - unsigned width, unsigned height, unsigned header_height, int x_offset, + materialui_handle_t *mui, void *userdata, + unsigned video_width, unsigned video_height, + unsigned header_height, int x_offset, size_t selection, float *color) { /* Only draw highlight if selection is onscreen */ @@ -3704,19 +4606,10 @@ static void materialui_render_selection_highlight( { file_list_t *list = NULL; materialui_node_t *node = NULL; - int highlight_x = x_offset; - int highlight_y = 0; - int highlight_width = (int)width - (int)mui->nav_bar_layout_width; - int highlight_height = 0; - - /* If landscape optimisations are enabled/active, - * adjust highlight layout */ - if (mui->landscape_entry_margin > 0) - { - highlight_x += (int)mui->landscape_entry_margin - (int)mui->margin; - highlight_width -= (int)(2 * mui->landscape_entry_margin) - (int)(2 * mui->margin); - highlight_width = (highlight_width < 0) ? 0 : highlight_width; - } + int highlight_x; + int highlight_y; + int highlight_width; + int highlight_height; list = menu_entries_get_selection_buf_ptr(0); if (!list) @@ -3727,11 +4620,13 @@ static void materialui_render_selection_highlight( return; /* Now we have a valid node, can determine - * highlight y position and height... - * > Note: We round y position down and add 1 to + * highlight position and size... + * > Note: We round x/y position down and add 1 to * the height in order to avoid obvious 'seams' * when entries have dividers (rounding errors * would otherwise cause 1px vertical gaps) */ + highlight_x = (int)(x_offset + node->x); + highlight_width = (int)(node->entry_width + 0.5f); highlight_y = (int)((float)header_height - mui->scroll_y + node->y); highlight_height = (int)(node->entry_height + 1.5f); @@ -3744,8 +4639,8 @@ static void materialui_render_selection_highlight( highlight_y, (unsigned)highlight_width, (unsigned)highlight_height, - width, - height, + video_width, + video_height, color); } } @@ -3754,7 +4649,7 @@ static void materialui_render_entry_touch_feedback( materialui_handle_t *mui, void *userdata, unsigned video_width, unsigned video_height, - unsigned width, unsigned height, unsigned header_height, int x_offset, + unsigned header_height, int x_offset, size_t current_selection) { /* Check whether pointer is currently @@ -3770,10 +4665,10 @@ static void materialui_render_entry_touch_feedback( * currently selected for feedback animations */ if (pointer_active) pointer_active = (mui->touch_feedback_selection == menu_input_get_pointer_selection()) && - (mui->pointer.x > mui->landscape_entry_margin) && - (mui->pointer.x < width - mui->landscape_entry_margin - mui->nav_bar_layout_width) && + (mui->pointer.x > mui->landscape_optimization.border_width) && + (mui->pointer.x < video_width - mui->landscape_optimization.border_width - mui->nav_bar_layout_width) && (mui->pointer.y >= header_height) && - (mui->pointer.y <= height - mui->nav_bar_layout_height); + (mui->pointer.y <= video_height - mui->nav_bar_layout_height - mui->status_bar.height); /* Touch feedback highlight fades in when pointer * is held stationary on a menu entry */ @@ -3815,7 +4710,7 @@ static void materialui_render_entry_touch_feedback( /* Draw highlight */ materialui_render_selection_highlight( mui, userdata, video_width, video_height, - width, height, header_height, x_offset, + header_height, x_offset, mui->touch_feedback_selection, higlight_color); } @@ -3824,13 +4719,12 @@ static void materialui_render_entry_touch_feedback( static void materialui_render_header( materialui_handle_t *mui, void *userdata, - unsigned video_width, unsigned video_height, - unsigned width, unsigned height) + unsigned video_width, unsigned video_height) { char menu_title_buf[255]; settings_t *settings = config_get_ptr(); size_t menu_title_margin = 0; - int usable_sys_bar_width = (int)width - (int)mui->nav_bar_layout_width; + int usable_sys_bar_width = (int)video_width - (int)mui->nav_bar_layout_width; int usable_title_bar_width = usable_sys_bar_width; size_t sys_bar_battery_width = 0; size_t sys_bar_clock_width = 0; @@ -3860,10 +4754,10 @@ static void materialui_render_header( video_height, 0, mui->sys_bar_height + mui->title_bar_height, - width, + video_width, mui->header_shadow_height, - width, - height, + video_width, + video_height, mui->colors.header_shadow); /* > Title bar background */ @@ -3873,10 +4767,10 @@ static void materialui_render_header( video_height, 0, 0, - width, + video_width, mui->sys_bar_height + mui->title_bar_height, - width, - height, + video_width, + video_height, mui->colors.title_bar_background); /* > System bar background */ @@ -3886,10 +4780,10 @@ static void materialui_render_header( video_height, 0, 0, - width, + video_width, mui->sys_bar_height, - width, - height, + video_width, + video_height, mui->colors.sys_bar_background); /* System bar items */ @@ -3962,14 +4856,12 @@ static void materialui_render_header( video_height, mui->sys_bar_icon_size, (uintptr_t)texture_battery, - (int)width - ( + (int)video_width - ( (int)mui->sys_bar_cache.battery_percent_width + (int)mui->sys_bar_margin + (int)mui->sys_bar_icon_size + (int)mui->nav_bar_layout_width), 0, - width, - height, 0, 1, mui->colors.sys_bar_icon); @@ -3977,9 +4869,9 @@ static void materialui_render_header( /* Draw percent text */ gfx_display_draw_text(mui->font_data.hint.font, mui->sys_bar_cache.battery_percent_str, - (int)width - ((int)mui->sys_bar_cache.battery_percent_width + (int)mui->sys_bar_margin + (int)mui->nav_bar_layout_width), + (int)video_width - ((int)mui->sys_bar_cache.battery_percent_width + (int)mui->sys_bar_margin + (int)mui->nav_bar_layout_width), sys_bar_text_y, - width, height, mui->colors.sys_bar_text, TEXT_ALIGN_LEFT, 1.0f, false, 0, false); + video_width, video_height, mui->colors.sys_bar_text, TEXT_ALIGN_LEFT, 1.0f, false, 0, false); sys_bar_battery_width = mui->sys_bar_cache.battery_percent_width + mui->sys_bar_margin + mui->sys_bar_icon_size; @@ -4030,12 +4922,12 @@ static void materialui_render_header( gfx_display_draw_text(mui->font_data.hint.font, mui->sys_bar_cache.timedate_str, - (int)width - ( + (int)video_width - ( (int)sys_bar_clock_width + (int)sys_bar_battery_width + (int)mui->nav_bar_layout_width), sys_bar_text_y, - width, height, mui->colors.sys_bar_text, + video_width, video_height, mui->colors.sys_bar_text, TEXT_ALIGN_LEFT, 1.0f, false, 0, false); usable_sys_bar_width -= sys_bar_clock_width; @@ -4082,7 +4974,7 @@ static void materialui_render_header( gfx_display_draw_text(mui->font_data.hint.font, core_title_buf, (int)mui->ticker_x_offset + (int)mui->sys_bar_margin, sys_bar_text_y, - width, height, mui->colors.sys_bar_text, TEXT_ALIGN_LEFT, 1.0f, false, 0, false); + video_width, video_height, mui->colors.sys_bar_text, TEXT_ALIGN_LEFT, 1.0f, false, 0, false); } /* Title bar items */ @@ -4102,8 +4994,6 @@ static void materialui_render_header( mui->textures.list[MUI_TEXTURE_BACK], 0, (int)mui->sys_bar_height, - width, - height, 0, 1, mui->colors.header_icon); @@ -4120,10 +5010,8 @@ static void materialui_render_header( video_height, mui->icon_size, mui->textures.list[MUI_TEXTURE_SEARCH], - (int)width - (int)mui->icon_size - (int)mui->nav_bar_layout_width, + (int)video_width - (int)mui->icon_size - (int)mui->nav_bar_layout_width, (int)mui->sys_bar_height, - width, - height, 0, 1, mui->colors.header_icon); @@ -4142,10 +5030,8 @@ static void materialui_render_header( video_height, mui->icon_size, mui->textures.list[MUI_TEXTURE_SWITCH_VIEW], - (int)width - (2 * (int)mui->icon_size) - (int)mui->nav_bar_layout_width, + (int)video_width - (2 * (int)mui->icon_size) - (int)mui->nav_bar_layout_width, (int)mui->sys_bar_height, - width, - height, 0, 1, mui->colors.header_icon); @@ -4232,30 +5118,29 @@ static void materialui_render_header( gfx_display_draw_text(mui->font_data.title.font, menu_title_buf, title_x, (int)(mui->sys_bar_height + (mui->title_bar_height / 2.0f) + mui->font_data.title.line_centre_offset), - width, height, mui->colors.header_text, TEXT_ALIGN_LEFT, 1.0f, false, 0, false); + video_width, video_height, mui->colors.header_text, TEXT_ALIGN_LEFT, 1.0f, false, 0, false); } -/* Use seperate functions for bottom/right navigation +/* Use separate functions for bottom/right navigation * bars. This involves substantial code duplication, but if * we try to handle this with a single function then * things get incredibly messy and inefficient... */ static void materialui_render_nav_bar_bottom( materialui_handle_t *mui, void *userdata, - unsigned video_width, unsigned video_height, - unsigned width, unsigned height) + unsigned video_width, unsigned video_height) { unsigned i; - unsigned nav_bar_width = width; + unsigned nav_bar_width = video_width; unsigned nav_bar_height = mui->nav_bar.width; int nav_bar_x = 0; - int nav_bar_y = (int)height - (int)mui->nav_bar.width; + int nav_bar_y = (int)video_height - (int)mui->nav_bar.width; unsigned num_tabs = mui->nav_bar.num_menu_tabs + MUI_NAV_BAR_NUM_ACTION_TABS; - float tab_width = (float)width / (float)num_tabs; + float tab_width = (float)video_width / (float)num_tabs; unsigned tab_width_int = (unsigned)(tab_width + 0.5f); unsigned selection_marker_width = tab_width_int; unsigned selection_marker_height = mui->nav_bar.selection_marker_width; - int selection_marker_y = (int)height - (int)mui->nav_bar.selection_marker_width; + int selection_marker_y = (int)video_height - (int)mui->nav_bar.selection_marker_width; /* Draw navigation bar background */ @@ -4268,8 +5153,8 @@ static void materialui_render_nav_bar_bottom( nav_bar_y, nav_bar_width, nav_bar_height, - width, - height, + video_width, + video_height, mui->colors.nav_bar_background); /* > Divider */ @@ -4281,8 +5166,8 @@ static void materialui_render_nav_bar_bottom( nav_bar_y, nav_bar_width, mui->nav_bar.divider_width, - width, - height, + video_width, + video_height, mui->colors.divider); /* Draw tabs */ @@ -4296,8 +5181,6 @@ static void materialui_render_nav_bar_bottom( mui->textures.list[mui->nav_bar.back_tab.texture_index], (int)((0.5f * tab_width) - ((float)mui->icon_size / 2.0f)), nav_bar_y, - width, - height, 0, 1, mui->nav_bar.back_tab.enabled ? @@ -4312,8 +5195,6 @@ static void materialui_render_nav_bar_bottom( mui->textures.list[mui->nav_bar.resume_tab.texture_index], (int)((((float)num_tabs - 0.5f) * tab_width) - ((float)mui->icon_size / 2.0f)), nav_bar_y, - width, - height, 0, 1, mui->nav_bar.resume_tab.enabled ? @@ -4335,8 +5216,6 @@ static void materialui_render_nav_bar_bottom( mui->textures.list[tab->texture_index], (((float)i + 1.5f) * tab_width) - ((float)mui->icon_size / 2.0f), nav_bar_y, - width, - height, 0, 1, draw_color); @@ -4350,8 +5229,8 @@ static void materialui_render_nav_bar_bottom( selection_marker_y, selection_marker_width, selection_marker_height, - width, - height, + video_width, + video_height, draw_color); } } @@ -4360,20 +5239,19 @@ static void materialui_render_nav_bar_right( materialui_handle_t *mui, void *userdata, unsigned video_width, - unsigned video_height, - unsigned width, unsigned height) + unsigned video_height) { unsigned i; unsigned nav_bar_width = mui->nav_bar.width; - unsigned nav_bar_height = height; - int nav_bar_x = (int)width - (int)mui->nav_bar.width; + unsigned nav_bar_height = video_height; + int nav_bar_x = (int)video_width - (int)mui->nav_bar.width; int nav_bar_y = 0; unsigned num_tabs = mui->nav_bar.num_menu_tabs + MUI_NAV_BAR_NUM_ACTION_TABS; - float tab_height = (float)height / (float)num_tabs; + float tab_height = (float)video_height / (float)num_tabs; unsigned tab_height_int = (unsigned)(tab_height + 0.5f); unsigned selection_marker_width = mui->nav_bar.selection_marker_width; unsigned selection_marker_height = tab_height_int; - int selection_marker_x = (int)width - (int)mui->nav_bar.selection_marker_width; + int selection_marker_x = (int)video_width - (int)mui->nav_bar.selection_marker_width; /* Draw navigation bar background */ @@ -4386,8 +5264,8 @@ static void materialui_render_nav_bar_right( nav_bar_y, nav_bar_width, nav_bar_height, - width, - height, + video_width, + video_height, mui->colors.nav_bar_background); /* > Divider */ @@ -4399,8 +5277,8 @@ static void materialui_render_nav_bar_right( nav_bar_y, mui->nav_bar.divider_width, nav_bar_height, - width, - height, + video_width, + video_height, mui->colors.divider); /* Draw tabs */ @@ -4414,8 +5292,6 @@ static void materialui_render_nav_bar_right( mui->textures.list[mui->nav_bar.back_tab.texture_index], nav_bar_x, (int)((((float)num_tabs - 0.5f) * tab_height) - ((float)mui->icon_size / 2.0f)), - width, - height, 0, 1, mui->nav_bar.back_tab.enabled ? @@ -4430,8 +5306,6 @@ static void materialui_render_nav_bar_right( mui->textures.list[mui->nav_bar.resume_tab.texture_index], nav_bar_x, (int)((0.5f * tab_height) - ((float)mui->icon_size / 2.0f)), - width, - height, 0, 1, mui->nav_bar.resume_tab.enabled ? @@ -4453,8 +5327,6 @@ static void materialui_render_nav_bar_right( mui->textures.list[tab->texture_index], nav_bar_x, (((float)i + 1.5f) * tab_height) - ((float)mui->icon_size / 2.0f), - width, - height, 0, 1, draw_color); @@ -4468,8 +5340,8 @@ static void materialui_render_nav_bar_right( (int)((i + 1) * tab_height_int), selection_marker_width, selection_marker_height, - width, - height, + video_width, + video_height, draw_color); } } @@ -4478,15 +5350,13 @@ static void materialui_render_nav_bar( materialui_handle_t *mui, void *userdata, unsigned video_width, - unsigned video_height, - unsigned width, unsigned height) + unsigned video_height) { switch (mui->nav_bar.location) { case MUI_NAV_BAR_LOCATION_RIGHT: materialui_render_nav_bar_right( - mui, userdata, video_width, video_height, - width, height); + mui, userdata, video_width, video_height); break; case MUI_NAV_BAR_LOCATION_HIDDEN: /* Draw nothing */ @@ -4495,8 +5365,7 @@ static void materialui_render_nav_bar( case MUI_NAV_BAR_LOCATION_BOTTOM: default: materialui_render_nav_bar_bottom( - mui, userdata, video_width, video_height, - width, height); + mui, userdata, video_width, video_height); break; } } @@ -4514,8 +5383,14 @@ static bool materialui_get_selected_thumbnails( file_list_t *list = NULL; materialui_node_t *node = NULL; - /* Ensure selection is on screen */ - if (!materialui_entry_onscreen(mui, selection)) + /* Ensure selection is on screen + * > Special case: When viewing 'desktop'-layout + * playlists skip this check, since thumbnails + * for the selected item are always shown via + * the sidebar regardless of whether the current + * selection is on screen */ + if ((mui->list_view_type != MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP) && + !materialui_entry_onscreen(mui, selection)) return false; /* Get currently selected node */ @@ -4661,7 +5536,7 @@ static void materialui_render_fullscreen_thumbnails( materialui_handle_t *mui, void *userdata, unsigned video_width, unsigned video_height, - unsigned width, unsigned height, unsigned header_height, + unsigned header_height, size_t selection) { /* Check whether fullscreen thumbnails are visible */ @@ -4727,8 +5602,8 @@ static void materialui_render_fullscreen_thumbnails( goto error; /* Get dimensions of list view */ - view_width = (int)width - (int)mui->nav_bar_layout_width; - view_height = (int)height - (int)mui->nav_bar_layout_height - (int)header_height; + view_width = (int)video_width - (int)mui->nav_bar_layout_width; + view_height = (int)video_height - (int)mui->nav_bar_layout_height - (int)header_height; /* Check screen orientation * > When using portrait layouts, primary is shown @@ -4870,8 +5745,8 @@ static void materialui_render_fullscreen_thumbnails( header_height, (unsigned)view_width, (unsigned)view_height, - width, - height, + video_width, + video_height, mui->colors.screen_fade); /* Draw thumbnails @@ -4889,8 +5764,8 @@ static void materialui_render_fullscreen_thumbnails( ((thumbnail_box_height - (int)primary_thumbnail_draw_height) >> 1), (unsigned)primary_thumbnail_draw_width + mui->margin, (unsigned)primary_thumbnail_draw_height + mui->margin, - width, - height, + video_width, + video_height, mui->colors.surface_background); /* Thumbnail */ @@ -4923,8 +5798,8 @@ static void materialui_render_fullscreen_thumbnails( ((thumbnail_box_height - (int)secondary_thumbnail_draw_height) >> 1), (unsigned)secondary_thumbnail_draw_width + mui->margin, (unsigned)secondary_thumbnail_draw_height + mui->margin, - width, - height, + video_width, + video_height, mui->colors.surface_background); /* Thumbnail */ @@ -4976,12 +5851,12 @@ static void materialui_colors_set_transition_alpha(materialui_handle_t *mui) gfx_display_set_alpha(mui->colors.list_switch_off, alpha); gfx_display_set_alpha(mui->colors.list_switch_off_background, alpha); gfx_display_set_alpha(mui->colors.scrollbar, alpha); - gfx_display_set_alpha(mui->colors.missing_thumbnail_icon, alpha); + gfx_display_set_alpha(mui->colors.entry_divider, alpha); /* Landscape border shadow only fades if: * - Landscape border is shown * - We are currently performing a slide animation */ - if ((mui->landscape_entry_margin != 0) && + if (mui->landscape_optimization.enabled && (mui->transition_x_offset != 0.0f)) { float border_shadow_alpha = @@ -4992,6 +5867,20 @@ static void materialui_colors_set_transition_alpha(materialui_handle_t *mui) mui->colors.landscape_border_shadow_right[3] = border_shadow_alpha; mui->colors.landscape_border_shadow_right[11] = border_shadow_alpha; } + + /* Sidebar and status bar only fade if we are + * currently viewing a playlist 'desktop'-layout */ + if (mui->list_view_type == MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP) + { + float status_bar_shadow_alpha = + mui->colors.status_bar_shadow_opacity * alpha; + + gfx_display_set_alpha(mui->colors.side_bar_background, alpha); + gfx_display_set_alpha(mui->colors.status_bar_background, alpha); + + mui->colors.status_bar_shadow[11] = status_bar_shadow_alpha; + mui->colors.status_bar_shadow[15] = status_bar_shadow_alpha; + } } } @@ -5015,12 +5904,12 @@ static void materialui_colors_reset_transition_alpha(materialui_handle_t *mui) gfx_display_set_alpha(mui->colors.list_switch_off, 1.0f); gfx_display_set_alpha(mui->colors.list_switch_off_background, 1.0f); gfx_display_set_alpha(mui->colors.scrollbar, 1.0f); - gfx_display_set_alpha(mui->colors.missing_thumbnail_icon, 1.0f); + gfx_display_set_alpha(mui->colors.entry_divider, 1.0f); /* Landscape border shadow only fades if: * - Landscape border is shown * - We are currently performing a slide animation */ - if ((mui->landscape_entry_margin != 0) && + if (mui->landscape_optimization.enabled && (mui->transition_x_offset != 0.0f)) { float border_shadow_alpha = @@ -5031,6 +5920,20 @@ static void materialui_colors_reset_transition_alpha(materialui_handle_t *mui) mui->colors.landscape_border_shadow_right[3] = border_shadow_alpha; mui->colors.landscape_border_shadow_right[11] = border_shadow_alpha; } + + /* Sidebar and status bar only fade if we are + * currently viewing a playlist 'desktop'-layout */ + if (mui->list_view_type == MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP) + { + float status_bar_shadow_alpha = + mui->colors.status_bar_shadow_opacity; + + gfx_display_set_alpha(mui->colors.side_bar_background, 1.0f); + gfx_display_set_alpha(mui->colors.status_bar_background, 1.0f); + + mui->colors.status_bar_shadow[11] = status_bar_shadow_alpha; + mui->colors.status_bar_shadow[15] = status_bar_shadow_alpha; + } } } @@ -5043,17 +5946,15 @@ static void materialui_update_scrollbar( /* Do nothing if scrollbar is disabled */ if (mui->scrollbar.active) { - int view_height = (int)height - (int)header_height - (int)mui->nav_bar_layout_height; - int y_max = view_height + (int)header_height - (int)(mui->scrollbar.width + mui->scrollbar.height); + int view_height = (int)height - (int)header_height - + (int)mui->nav_bar_layout_height - (int)mui->status_bar.height; + int y_max = view_height + (int)header_height - + (int)(mui->scrollbar.width + mui->scrollbar.height); /* Get X position */ - mui->scrollbar.x = x_offset + (int)width - (int)mui->scrollbar.width - (int)mui->nav_bar_layout_width; - - /* > Scrollbar must be offset by the current - * landscape border width when landscape optimisations - * are enabled */ - if (mui->landscape_entry_margin > mui->margin) - mui->scrollbar.x -= (int)mui->landscape_entry_margin - (int)mui->margin; + mui->scrollbar.x = x_offset + (int)width - (int)mui->scrollbar.width - + (int)mui->landscape_optimization.border_width - + (int)mui->nav_bar_layout_width; /* Get Y position */ mui->scrollbar.y = (int)header_height + (int)(mui->scroll_y * (float)view_height / mui->content_height); @@ -5082,8 +5983,6 @@ static void materialui_frame(void *data, video_frame_info_t *video_info) float menu_wallpaper_opacity = video_info->menu_wallpaper_opacity; float menu_framebuffer_opacity = video_info->menu_framebuffer_opacity; void *userdata = video_info->userdata; - unsigned width = video_info->width; - unsigned height = video_info->height; unsigned video_width = video_info->width; unsigned video_height = video_info->height; unsigned @@ -5094,16 +5993,12 @@ static void materialui_frame(void *data, video_frame_info_t *video_info) if (!mui) return; - gfx_display_set_viewport(width, height); + gfx_display_set_viewport(video_width, video_height); /* Clear text */ - font_driver_bind_block(mui->font_data.title.font, &mui->font_data.title.raster_block); - font_driver_bind_block(mui->font_data.list.font, &mui->font_data.list.raster_block); - font_driver_bind_block(mui->font_data.hint.font, &mui->font_data.hint.raster_block); - - mui->font_data.title.raster_block.carr.coords.vertices = 0; - mui->font_data.list.raster_block.carr.coords.vertices = 0; - mui->font_data.hint.raster_block.carr.coords.vertices = 0; + materialui_font_bind(&mui->font_data.title); + materialui_font_bind(&mui->font_data.list); + materialui_font_bind(&mui->font_data.hint); /* Update theme colours, if required */ if (mui->color_theme != materialui_color_theme) @@ -5135,32 +6030,31 @@ static void materialui_frame(void *data, video_frame_info_t *video_info) /* Get x offset for list items, required by * menu transition 'slide' animations */ - list_x_offset = (int)(mui->transition_x_offset * (float)((int)width - (int)mui->nav_bar_layout_width)); + list_x_offset = (int)(mui->transition_x_offset * (float)((int)video_width - (int)mui->nav_bar_layout_width)); /* Draw background */ materialui_render_background(mui, userdata, video_width, video_height, libretro_running, menu_wallpaper_opacity, - menu_framebuffer_opacity - ); + menu_framebuffer_opacity); /* Draw landscape border * (does nothing in portrait mode, or if landscape * optimisations are disabled) */ - materialui_render_landscape_border( - mui, userdata, - video_width, - video_height, - width, height, header_height, list_x_offset); + materialui_render_landscape_border(mui, userdata, + video_width, video_height, + header_height, list_x_offset); /* Draw 'highlighted entry' selection box */ materialui_render_selection_highlight( - mui, userdata, video_width, video_height, width, height, header_height, list_x_offset, selection, + mui, userdata, video_width, video_height, + header_height, list_x_offset, selection, mui->colors.list_highlighted_background); /* Draw 'short press' touch feedback highlight */ materialui_render_entry_touch_feedback( - mui, userdata, video_width, video_height, width, height, header_height, list_x_offset, selection); + mui, userdata, video_width, video_height, + header_height, list_x_offset, selection); /* Draw menu list * > Must update scrollbar draw position before @@ -5169,42 +6063,33 @@ static void materialui_frame(void *data, video_frame_info_t *video_info) * like this because we need to track its * position in order to enable fast navigation * via scrollbar 'dragging' */ - materialui_update_scrollbar(mui, width, height, header_height, list_x_offset); - materialui_render_menu_list(mui, - userdata, - video_width, video_height, - width, height, list_x_offset); + materialui_update_scrollbar(mui, video_width, video_height, header_height, list_x_offset); + materialui_render_menu_list(mui, userdata, + video_width, video_height, list_x_offset); /* Flush first layer of text * > Menu list only uses list and hint fonts */ - font_driver_flush(width, height, mui->font_data.list.font); - font_driver_flush(width, height, mui->font_data.hint.font); - - mui->font_data.list.raster_block.carr.coords.vertices = 0; - mui->font_data.hint.raster_block.carr.coords.vertices = 0; + materialui_font_flush(video_width, video_height, &mui->font_data.list); + materialui_font_flush(video_width, video_height, &mui->font_data.hint); /* Draw fullscreen thumbnails, if currently active * > Must be done *after* we flush the first layer * of text */ - materialui_render_fullscreen_thumbnails( - mui, userdata, video_width, - video_height, width, height, header_height, selection); + materialui_render_fullscreen_thumbnails(mui, userdata, + video_width, video_height, header_height, selection); /* Draw title + system bar */ - materialui_render_header(mui, userdata, video_width, - video_height, width, height); + materialui_render_header(mui, userdata, + video_width, video_height); /* Draw navigation bar */ materialui_render_nav_bar(mui, userdata, - video_width, video_height, width, height); + video_width, video_height); /* Flush second layer of text * > Title + system bar only use title and hint fonts */ - font_driver_flush(width, height, mui->font_data.title.font); - font_driver_flush(width, height, mui->font_data.hint.font); - - mui->font_data.title.raster_block.carr.coords.vertices = 0; - mui->font_data.hint.raster_block.carr.coords.vertices = 0; + materialui_font_flush(video_width, video_height, &mui->font_data.title); + materialui_font_flush(video_width, video_height, &mui->font_data.hint); /* Handle onscreen keyboard */ if (menu_input_dialog_get_display_kb()) @@ -5222,13 +6107,16 @@ static void materialui_frame(void *data, video_frame_info_t *video_info) userdata, video_width, video_height, - 0, 0, width, height, width, height, mui->colors.screen_fade); + 0, 0, + video_width, video_height, + video_width, video_height, + mui->colors.screen_fade); /* Draw message box */ snprintf(msg, sizeof(msg), "%s\n%s", label, str); materialui_render_messagebox(mui, userdata, video_width, video_height, - height / 4, msg); + video_height / 4, msg); /* Draw onscreen keyboard */ gfx_display_draw_keyboard( @@ -5243,8 +6131,7 @@ static void materialui_frame(void *data, video_frame_info_t *video_info) /* Flush message box & osk text * > Message box & osk only use list font */ - font_driver_flush(width, height, mui->font_data.list.font); - mui->font_data.list.raster_block.carr.coords.vertices = 0; + materialui_font_flush(video_width, video_height, &mui->font_data.list); } /* Draw message box */ @@ -5257,18 +6144,20 @@ static void materialui_frame(void *data, video_frame_info_t *video_info) userdata, video_width, video_height, - 0, 0, width, height, width, height, mui->colors.screen_fade); + 0, 0, + video_width, video_height, + video_width, video_height, + mui->colors.screen_fade); /* Draw message box */ materialui_render_messagebox(mui, userdata, video_width, video_height, - height / 2, mui->msgbox); + video_height / 2, mui->msgbox); mui->msgbox[0] = '\0'; /* Flush message box text * > Message box only uses list font */ - font_driver_flush(width, height, mui->font_data.list.font); - mui->font_data.list.raster_block.carr.coords.vertices = 0; + materialui_font_flush(video_width, video_height, &mui->font_data.list); } /* Draw mouse cursor */ @@ -5293,8 +6182,8 @@ static void materialui_frame(void *data, video_frame_info_t *video_info) mui->textures.list[MUI_TEXTURE_POINTER], mui->pointer.x, mui->pointer.y, - width, - height); + video_width, + video_height); } /* Undo any transparency adjustments caused @@ -5302,11 +6191,11 @@ static void materialui_frame(void *data, video_frame_info_t *video_info) materialui_colors_reset_transition_alpha(mui); /* Unbind fonts */ - font_driver_bind_block(mui->font_data.title.font, NULL); - font_driver_bind_block(mui->font_data.list.font, NULL); - font_driver_bind_block(mui->font_data.hint.font, NULL); + materialui_font_unbind(&mui->font_data.title); + materialui_font_unbind(&mui->font_data.list); + materialui_font_unbind(&mui->font_data.hint); - gfx_display_unset_viewport(width, height); + gfx_display_unset_viewport(video_width, video_height); } /* Determines current list view type, based on @@ -5371,6 +6260,9 @@ static void materialui_set_list_view_type( case MATERIALUI_THUMBNAIL_VIEW_LANDSCAPE_LIST_LARGE: mui->list_view_type = MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_LARGE; break; + case MATERIALUI_THUMBNAIL_VIEW_LANDSCAPE_DESKTOP: + mui->list_view_type = MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP; + break; case MATERIALUI_THUMBNAIL_VIEW_LANDSCAPE_DISABLED: default: mui->list_view_type = MUI_LIST_VIEW_PLAYLIST; @@ -5379,6 +6271,45 @@ static void materialui_set_list_view_type( } } } + + /* List view type has changed -> assign + * relevant function pointers */ + switch (mui->list_view_type) + { + case MUI_LIST_VIEW_PLAYLIST: + materialui_compute_entries_box = materialui_compute_entries_box_playlist_list; + materialui_render_process_entry = materialui_render_process_entry_default; + materialui_render_menu_entry = materialui_render_menu_entry_playlist_list; + materialui_render_selected_entry_aux = NULL; + break; + case MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_SMALL: + case MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_MEDIUM: + case MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_LARGE: + materialui_compute_entries_box = materialui_compute_entries_box_playlist_list; + materialui_render_process_entry = materialui_render_process_entry_playlist_thumb_list; + materialui_render_menu_entry = materialui_render_menu_entry_playlist_list; + materialui_render_selected_entry_aux = NULL; + break; + case MUI_LIST_VIEW_PLAYLIST_THUMB_DUAL_ICON: + materialui_compute_entries_box = materialui_compute_entries_box_playlist_dual_icon; + materialui_render_process_entry = materialui_render_process_entry_playlist_dual_icon; + materialui_render_menu_entry = materialui_render_menu_entry_playlist_dual_icon; + materialui_render_selected_entry_aux = NULL; + break; + case MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP: + materialui_compute_entries_box = materialui_compute_entries_box_playlist_desktop; + materialui_render_process_entry = materialui_render_process_entry_playlist_desktop; + materialui_render_menu_entry = materialui_render_menu_entry_playlist_desktop; + materialui_render_selected_entry_aux = materialui_render_selected_entry_aux_playlist_desktop; + break; + case MUI_LIST_VIEW_DEFAULT: + default: + materialui_compute_entries_box = materialui_compute_entries_box_default; + materialui_render_process_entry = materialui_render_process_entry_default; + materialui_render_menu_entry = materialui_render_menu_entry_default; + materialui_render_selected_entry_aux = NULL; + break; + } } /* Determines whether landscape optimisations should @@ -5387,8 +6318,6 @@ static void materialui_set_list_view_type( static void materialui_set_landscape_optimisations_enable( materialui_handle_t *mui) { - bool optimize_landscape_layout = false; - /* In landscape orientations, menu lists are too wide * (to the extent that they are rather uncomfortable * to look at...) @@ -5397,7 +6326,9 @@ static void materialui_set_landscape_optimisations_enable( * the screen */ /* Disable optimisations by default */ - mui->landscape_entry_margin = 0; + mui->landscape_optimization.enabled = false; + mui->landscape_optimization.border_width = 0; + mui->landscape_optimization.entry_margin = 0; /* Early out if current orientation is portrait */ if (mui->is_portrait) @@ -5408,7 +6339,7 @@ static void materialui_set_landscape_optimisations_enable( switch (mui->last_landscape_layout_optimization) { case MATERIALUI_LANDSCAPE_LAYOUT_OPTIMIZATION_ALWAYS: - optimize_landscape_layout = true; + mui->landscape_optimization.enabled = true; break; case MATERIALUI_LANDSCAPE_LAYOUT_OPTIMIZATION_EXCLUDE_THUMBNAIL_VIEWS: @@ -5418,12 +6349,13 @@ static void materialui_set_landscape_optimisations_enable( case MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_MEDIUM: case MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_LARGE: case MUI_LIST_VIEW_PLAYLIST_THUMB_DUAL_ICON: - optimize_landscape_layout = false; + case MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP: + mui->landscape_optimization.enabled = false; break; case MUI_LIST_VIEW_PLAYLIST: case MUI_LIST_VIEW_DEFAULT: default: - optimize_landscape_layout = true; + mui->landscape_optimization.enabled = true; break; } @@ -5431,12 +6363,12 @@ static void materialui_set_landscape_optimisations_enable( case MATERIALUI_LANDSCAPE_LAYOUT_OPTIMIZATION_DISABLED: default: - optimize_landscape_layout = false; + mui->landscape_optimization.enabled = false; break; } - /* Calculate landscape entry margin size, if required */ - if (optimize_landscape_layout) + /* Calculate landscape border size, if required */ + if (mui->landscape_optimization.enabled) { /* After testing various approaches, it seems that * simply enforcing a 4:3 aspect ratio produces the @@ -5446,9 +6378,87 @@ static void materialui_set_landscape_optimisations_enable( ((float)(mui->last_width - mui->nav_bar_layout_width) - (base_aspect * (float)mui->last_height)) / 2.0f; - /* Note: Want to round down here */ if (landscape_margin > 1.0f) - mui->landscape_entry_margin = (unsigned)landscape_margin; + { + float entry_margin = 0.0f; + float border_width = 0.0f; + + /* When landscape optimisations are active, + * we increase the effective width of the list + * view by up to 'mui->margin', and any remaining + * 'landscape_margin' space is filled with a + * (shadow gradient) border */ + entry_margin = (landscape_margin >= (float)mui->margin) ? + (float)mui->margin : landscape_margin; + border_width = landscape_margin - entry_margin; + + /* Note: In all cases, we want to round down + * when converting these to integers */ + mui->landscape_optimization.entry_margin = (unsigned)entry_margin; + mui->landscape_optimization.border_width = (unsigned)border_width; + } + /* If margin is less than 1px, disable optimisations */ + else + mui->landscape_optimization.enabled = false; + } +} + +/* Initialises status bar, determining current + * enable state based on view mode and user + * configuration */ +static void materialui_status_bar_init( + materialui_handle_t *mui, settings_t *settings) +{ + bool playlist_show_sublabels = settings->bools.playlist_show_sublabels; + gfx_animation_ctx_tag alpha_tag = (uintptr_t)&mui->status_bar.alpha; + + /* Kill any existing fade in animation */ + if (mui->status_bar.enabled || + (mui->status_bar.alpha > 0.0f)) + gfx_animation_kill_by_tag(&alpha_tag); + + /* Reset base parameters */ + mui->status_bar.cached = false; + mui->status_bar.last_selected = 0; + mui->status_bar.delay_timer = 0.0f; + mui->status_bar.alpha = 0.0f; + mui->status_bar.height = 0; + mui->status_bar.str[0] = '\0'; + mui->status_bar.runtime_fallback_str[0] = '\0'; + mui->status_bar.last_played_fallback_str[0] = '\0'; + + /* Determine enable state */ + mui->status_bar.enabled = + (mui->list_view_type == MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP) && + playlist_show_sublabels; + + if (mui->status_bar.enabled) + { + int n; + + /* Determine status bar height */ + mui->status_bar.height = (unsigned)(((float)mui->font_data.hint.line_height * 1.6f) + 0.5f); + + /* Cache fallback runtime/last played strings + * (Why do we do this here instead of once in + * materialui_init()? Because re-caching the + * values each time allows us to handle changes + * in user interface language settings) */ + n = snprintf(mui->status_bar.runtime_fallback_str, + sizeof(mui->status_bar.runtime_fallback_str), "%s %s", + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_RUNTIME), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED)); + + if ((n < 0) || (n >= 255)) + n = 0; /* Silence GCC warnings... */ + + n = snprintf(mui->status_bar.last_played_fallback_str, + sizeof(mui->status_bar.last_played_fallback_str), "%s %s", + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED)); + + if ((n < 0) || (n >= 255)) + n = 0; /* Silence GCC warnings... */ } } @@ -5522,22 +6532,59 @@ static void materialui_set_thumbnail_dimensions(materialui_handle_t *mui) * and either side of thumbnails) */ int usable_width = (int)mui->last_width - (int)(mui->margin * 3) - - (int)(mui->landscape_entry_margin * 2) - (int)mui->nav_bar_layout_width; + (int)(mui->landscape_optimization.border_width * 2) - + (int)mui->nav_bar_layout_width; - /* > Sanity check */ + /* Sanity check */ if (usable_width < 2) { mui->thumbnail_width_max = 0; mui->thumbnail_height_max = 0; } + else + { + /* Get maximum thumbnail width */ + mui->thumbnail_width_max = (usable_width >> 1); - /* > Get maximum thumbnail width */ - mui->thumbnail_width_max = (usable_width >> 1); + /* Set thumbnail height based on max width */ + mui->thumbnail_height_max = + (unsigned)(((float)mui->thumbnail_width_max * + (1.0f / MUI_THUMBNAIL_DEFAULT_ASPECT_RATIO)) + 0.5f); + } + } + break; - /* > Set thumbnail height based on max width */ - mui->thumbnail_height_max = - (unsigned)(((float)mui->thumbnail_width_max * - (1.0f / MUI_THUMBNAIL_DEFAULT_ASPECT_RATIO)) + 0.5f); + case MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP: + { + /* This view shows two thumbnail icons + * for the selected entry, one below the + * other across the full height of the + * list area */ + + /* > Get total usable height + * (list view height minus vertical padding + * between thumbnails minus status bar height) */ + unsigned header_height = gfx_display_get_header_height(); + int usable_height = (int)mui->last_height - (int)header_height - + (int)(mui->margin * 3) - (int)mui->nav_bar_layout_height - + (int)mui->status_bar.height; + + /* Sanity check */ + if (usable_height < 2) + { + mui->thumbnail_width_max = 0; + mui->thumbnail_height_max = 0; + } + else + { + /* Get maximum thumbnail height */ + mui->thumbnail_height_max = (usable_height >> 1); + + /* Set thumbnail width based on max height */ + mui->thumbnail_width_max = + (unsigned)(((float)mui->thumbnail_height_max * + MUI_THUMBNAIL_DEFAULT_ASPECT_RATIO) + 0.5f); + } } break; @@ -5620,7 +6667,8 @@ static void materialui_set_secondary_thumbnail_enable( { int usable_width = 0; int thumbnail_margin = 0; - bool menu_materialui_dual_thumbnail_list_view_enable = settings->bools.menu_materialui_dual_thumbnail_list_view_enable; + bool menu_materialui_dual_thumbnail_list_view_enable = + settings->bools.menu_materialui_dual_thumbnail_list_view_enable; /* Disable by default */ mui->secondary_thumbnail_enabled = false; @@ -5640,9 +6688,9 @@ static void materialui_set_secondary_thumbnail_enable( * width to display them */ /* > Get total usable width */ - usable_width = - (int)mui->last_width - (int)(mui->margin * 2) - - (int)(mui->landscape_entry_margin * 2) - (int)mui->nav_bar_layout_width; + usable_width = (int)mui->last_width - (int)(mui->margin * 2) - + (int)(mui->landscape_optimization.border_width * 2) - + (int)mui->nav_bar_layout_width; /* > Account for additional padding (margins) when * using portrait orientations */ @@ -5651,8 +6699,7 @@ static void materialui_set_secondary_thumbnail_enable( /* > Account for additional padding (margins) when * using landscape orientations */ else - if (mui->landscape_entry_margin < mui->margin) - thumbnail_margin = (int)(mui->margin - mui->landscape_entry_margin); + thumbnail_margin = (int)mui->margin; /* > Get remaining (text) width after drawing * primary + secondary thumbnails */ @@ -5666,6 +6713,7 @@ static void materialui_set_secondary_thumbnail_enable( } break; case MUI_LIST_VIEW_PLAYLIST_THUMB_DUAL_ICON: + case MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP: /* List view requires secondary thumbnails * > Attempt to force enable, but set * mui->secondary_thumbnail_enabled to 'true' @@ -5702,6 +6750,7 @@ static void materialui_update_list_view(materialui_handle_t *mui) settings->uints.menu_materialui_thumbnail_view_portrait, settings->uints.menu_materialui_thumbnail_view_landscape); materialui_set_landscape_optimisations_enable(mui); + materialui_status_bar_init(mui, settings); materialui_set_thumbnail_dimensions(mui); materialui_set_secondary_thumbnail_enable(mui, settings); @@ -6005,12 +7054,22 @@ static void *materialui_init(void **userdata, bool video_is_threaded) /* Set thumbnail fade duration to default */ gfx_thumbnail_set_fade_duration(-1.0f); + /* Enable fade in animation for missing thumbnails */ + gfx_thumbnail_set_fade_missing(true); + /* Ensure that fullscreen thumbnails are inactive */ mui->show_fullscreen_thumbnails = false; mui->fullscreen_thumbnail_selection = 0; mui->fullscreen_thumbnail_alpha = 0.0f; mui->fullscreen_thumbnail_label[0] = '\0'; + /* Ensure status bar has sane initial values */ + mui->status_bar.enabled = false; + mui->status_bar.height = 0; + mui->status_bar.str[0] = '\0'; + mui->status_bar.runtime_fallback_str[0] = '\0'; + mui->status_bar.last_played_fallback_str[0] = '\0'; + gfx_animation_set_update_time_cb(materialui_menu_animation_update_time); return menu; @@ -7289,7 +8348,7 @@ static int materialui_pointer_down(void *userdata, /* Check whether pointer down event is within * vertical list region */ if ((y < header_height) || - (y > height - mui->nav_bar_layout_height)) + (y > height - mui->nav_bar_layout_height - mui->status_bar.height)) return 0; /* Determine horizontal width of scrollbar @@ -7301,12 +8360,12 @@ static int materialui_pointer_down(void *userdata, * screen width), need to increase 'grab box' size * (otherwise the active region is too close to the * navigation bar) */ - if (!mui->is_portrait) + if (!mui->is_portrait && mui->last_auto_rotate_nav_bar) { - if (mui->landscape_entry_margin <= mui->margin) + if (mui->landscape_optimization.border_width <= mui->margin) drag_margin_horz += (int)mui->margin; - else if (mui->landscape_entry_margin <= 2 * mui->margin) - drag_margin_horz += (int)((2 * mui->margin) - mui->landscape_entry_margin); + else if (mui->landscape_optimization.border_width <= 2 * mui->margin) + drag_margin_horz += (int)((2 * mui->margin) - mui->landscape_optimization.entry_margin); } /* Check whether pointer X position is within @@ -7364,7 +8423,8 @@ static int materialui_pointer_up_swipe_horz_plain_list( else { float content_height_fraction = mui->content_height * 0.1f; - float display_height = (int)height - (int)header_height - (int)mui->nav_bar_layout_height; + float display_height = (int)height - (int)header_height - + (int)mui->nav_bar_layout_height - (int)mui->status_bar.height; float scroll_offset = (display_height > content_height_fraction) ? display_height : content_height_fraction; @@ -7655,10 +8715,49 @@ static int materialui_pointer_up(void *userdata, return materialui_menu_entry_action(mui, entry, selection, MENU_ACTION_CANCEL); } /* Tap/press menu item: Activate and/or select item */ - else if ((ptr < entries_end) && - (x > mui->landscape_entry_margin) && - (x < width - mui->landscape_entry_margin - mui->nav_bar_layout_width)) + else if ((y < height - mui->nav_bar_layout_height - mui->status_bar.height) && + (ptr < entries_end) && + (x > mui->landscape_optimization.border_width) && + (x < width - mui->landscape_optimization.border_width - mui->nav_bar_layout_width)) { + file_list_t *list = NULL; + materialui_node_t *node = NULL; + int entry_x; + int entry_y; + + /* Special case: If we are currently viewing + * a 'desktop'-layout playlist, pressing the + * sidebar toggles fullscreen thumbnails */ + if ((mui->list_view_type == MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP) && + (x < mui->landscape_optimization.border_width + mui->thumbnail_width_max + (mui->margin * 2))) + { + materialui_show_fullscreen_thumbnails(mui, selection); + break; + } + + /* Get node (entry) associated with current + * pointer item */ + list = menu_entries_get_selection_buf_ptr(0); + if (!list) + break; + + node = (materialui_node_t*)file_list_get_userdata_at_offset(list, ptr); + if (!node) + break; + + /* Get pointer item x/y position */ + entry_x = (int)node->x; + entry_y = (int)((float)header_height - mui->scroll_y + node->y); + + /* Check if pointer location is within the + * bounds of the pointer item */ + if ((x < entry_x) || + (x > (entry_x + node->entry_width)) || + (y < entry_y) || + (y > (entry_y + node->entry_height))) + break; + + /* Pointer input is valid - perform action */ if (gesture == MENU_INPUT_GESTURE_TAP) { /* A 'tap' always produces a menu action */ @@ -7803,8 +8902,10 @@ static void materialui_list_insert( node->has_icon = false; node->icon_texture_index = 0; + node->entry_width = 0.0f; node->entry_height = 0.0f; node->text_height = 0.0f; + node->x = 0.0f; node->y = 0.0f; if (!thumbnail_reset) @@ -8342,6 +9443,8 @@ static void materialui_get_thumbnail_system(void *userdata, char *s, size_t len) static void materialui_refresh_thumbnail_image(void *userdata, unsigned i) { materialui_handle_t *mui = (materialui_handle_t*)userdata; + size_t selection = menu_navigation_get_selection(); + bool refresh_enabled = false; if (!mui) return; @@ -8352,9 +9455,16 @@ static void materialui_refresh_thumbnail_image(void *userdata, unsigned i) (mui->list_view_type == MUI_LIST_VIEW_PLAYLIST)) return; - /* Only refresh thumbnails if the current entry is - * on-screen */ - if (materialui_entry_onscreen(mui, (size_t)i)) + /* Only refresh thumbnails if: + * - This is *not* a 'desktop'-layout playlist and + * the current entry is on-screen + * - This *is* a 'desktop'-layout playlist and current + * entry is selected */ + refresh_enabled = (mui->list_view_type == MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP) ? + (i == selection) : + materialui_entry_onscreen(mui, (size_t)i); + + if (refresh_enabled) { file_list_t *list = menu_entries_get_selection_buf_ptr(0); materialui_node_t *node = NULL; diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 35ee3b66f0..af435345ec 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -195,6 +195,7 @@ static void *ozone_init(void **userdata, bool video_is_threaded) gfx_thumbnail_set_stream_delay(-1.0f); gfx_thumbnail_set_fade_duration(-1.0f); + gfx_thumbnail_set_fade_missing(false); ozone_sidebar_update_collapse(ozone, false); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 9aa8f4d8cb..38f198701c 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -5380,6 +5380,7 @@ static void *xmb_init(void **userdata, bool video_is_threaded) gfx_thumbnail_set_stream_delay(-1.0f); gfx_thumbnail_set_fade_duration(-1.0f); + gfx_thumbnail_set_fade_missing(false); xmb->use_ps3_layout = xmb_use_ps3_layout(settings, width, height); xmb->last_use_ps3_layout = xmb->use_ps3_layout; diff --git a/menu/menu_defines.h b/menu/menu_defines.h index 166bd6ba59..58c294c581 100644 --- a/menu/menu_defines.h +++ b/menu/menu_defines.h @@ -205,6 +205,7 @@ enum materialui_thumbnail_view_landscape MATERIALUI_THUMBNAIL_VIEW_LANDSCAPE_LIST_SMALL, MATERIALUI_THUMBNAIL_VIEW_LANDSCAPE_LIST_MEDIUM, MATERIALUI_THUMBNAIL_VIEW_LANDSCAPE_LIST_LARGE, + MATERIALUI_THUMBNAIL_VIEW_LANDSCAPE_DESKTOP, MATERIALUI_THUMBNAIL_VIEW_LANDSCAPE_LAST }; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 58ebff44f6..5764bacf92 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -4133,6 +4133,11 @@ static void setting_get_string_representation_uint_materialui_menu_thumbnail_vie msg_hash_to_str( MENU_ENUM_LABEL_VALUE_MATERIALUI_THUMBNAIL_VIEW_LANDSCAPE_LIST_LARGE), len); break; + case MATERIALUI_THUMBNAIL_VIEW_LANDSCAPE_DESKTOP: + strlcpy(s, + msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_MATERIALUI_THUMBNAIL_VIEW_LANDSCAPE_DESKTOP), len); + break; default: break; } diff --git a/msg_hash.h b/msg_hash.h index 5c68f629fc..98d28d8847 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -660,6 +660,7 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_MATERIALUI_THUMBNAIL_VIEW_LANDSCAPE_LIST_SMALL, MENU_ENUM_LABEL_VALUE_MATERIALUI_THUMBNAIL_VIEW_LANDSCAPE_LIST_MEDIUM, MENU_ENUM_LABEL_VALUE_MATERIALUI_THUMBNAIL_VIEW_LANDSCAPE_LIST_LARGE, + MENU_ENUM_LABEL_VALUE_MATERIALUI_THUMBNAIL_VIEW_LANDSCAPE_DESKTOP, MENU_LABEL(MATERIALUI_LANDSCAPE_LAYOUT_OPTIMIZATION), MENU_ENUM_LABEL_VALUE_MATERIALUI_LANDSCAPE_LAYOUT_OPTIMIZATION_DISABLED, diff --git a/runtime_file.c b/runtime_file.c index bd096dce82..db17eace70 100644 --- a/runtime_file.c +++ b/runtime_file.c @@ -1020,7 +1020,7 @@ void runtime_update_playlist( runtime_log_t *runtime_log = NULL; const struct playlist_entry *entry = NULL; struct playlist_entry update_entry = {0}; -#if defined(HAVE_MENU) && defined(HAVE_OZONE) +#if defined(HAVE_MENU) && (defined(HAVE_OZONE) || defined(HAVE_MATERIALUI)) const char *menu_ident = menu_driver_ident(); #endif @@ -1078,15 +1078,20 @@ void runtime_update_playlist( free(runtime_log); } -#if defined(HAVE_MENU) && defined(HAVE_OZONE) - /* Ozone requires runtime/last played strings to be - * populated even when no runtime is recorded */ - if (string_is_equal(menu_ident, "ozone")) +#if defined(HAVE_MENU) && (defined(HAVE_OZONE) || defined(HAVE_MATERIALUI)) + /* Ozone and GLUI require runtime/last played strings + * to be populated even when no runtime is recorded */ + if (update_entry.runtime_status != PLAYLIST_RUNTIME_VALID) { - if (update_entry.runtime_status != PLAYLIST_RUNTIME_VALID) + if (string_is_equal(menu_ident, "ozone") || + string_is_equal(menu_ident, "glui")) { runtime_log_get_runtime_str(NULL, runtime_str, sizeof(runtime_str)); runtime_log_get_last_played_str(NULL, last_played_str, sizeof(last_played_str), timedate_style); + + /* While runtime data does not exist, the playlist + * entry does now contain valid information... */ + update_entry.runtime_status = PLAYLIST_RUNTIME_VALID; } } #endif From 7a3ddcd77d819bb3a35ccaa3180deef982bdd5ef Mon Sep 17 00:00:00 2001 From: barbudreadmon Date: Sat, 9 May 2020 17:15:45 +0200 Subject: [PATCH 017/192] (glcore) switch to glcore video driver when requested fix #10486 --- retroarch.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/retroarch.c b/retroarch.c index be36eaf141..99991e3454 100644 --- a/retroarch.c +++ b/retroarch.c @@ -22363,21 +22363,20 @@ bool video_driver_is_threaded(void) return video_driver_is_threaded_internal(); } -#ifdef HAVE_VULKAN +#if defined(HAVE_VULKAN) static bool hw_render_context_is_vulkan(enum retro_hw_context_type type) { return type == RETRO_HW_CONTEXT_VULKAN; } #endif -#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL_CORE) +#if defined(HAVE_OPENGL) static bool hw_render_context_is_gl(enum retro_hw_context_type type) { switch (type) { case RETRO_HW_CONTEXT_OPENGL: case RETRO_HW_CONTEXT_OPENGLES2: - case RETRO_HW_CONTEXT_OPENGL_CORE: case RETRO_HW_CONTEXT_OPENGLES3: case RETRO_HW_CONTEXT_OPENGLES_VERSION: return true; @@ -22389,6 +22388,13 @@ static bool hw_render_context_is_gl(enum retro_hw_context_type type) } #endif +#if defined(HAVE_OPENGL_CORE) +static bool hw_render_context_is_glcore(enum retro_hw_context_type type) +{ + return type == RETRO_HW_CONTEXT_OPENGL_CORE; +} +#endif + bool *video_driver_get_threaded(void) { #if defined(__MACH__) && defined(__APPLE__) @@ -23702,6 +23708,23 @@ static bool video_driver_find_driver(void) } #endif +#if defined(HAVE_OPENGL_CORE) + if (hwr && hw_render_context_is_glcore(hwr->context_type)) + { + RARCH_LOG("[Video]: Using HW render, OpenGL core driver forced.\n"); + if (!string_is_equal(settings->arrays.video_driver, "glcore")) + { + RARCH_LOG("[Video]: \"%s\" saved as cached driver.\n", settings->arrays.video_driver); + strlcpy(cached_video_driver, settings->arrays.video_driver, + sizeof(cached_video_driver)); + configuration_set_string(settings, + settings->arrays.video_driver, + "glcore"); + } + current_video = &video_gl_core; + } +#endif + if (current_video) return true; } From 1e6ccb2310e1cd6a3924be080c4576fd4ba1fe80 Mon Sep 17 00:00:00 2001 From: Christoffer Tibell Date: Sat, 9 May 2020 23:14:30 +0200 Subject: [PATCH 018/192] Use GenericName correctly in desktop entry --- retroarch.desktop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroarch.desktop b/retroarch.desktop index 7a0307ad9d..8f2e329acc 100644 --- a/retroarch.desktop +++ b/retroarch.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Version=1.0 Name=RetroArch -GenericName=RetroArch +GenericName=Frontend for the libretro API Type=Application Comment=Frontend for emulators, game engines and media players Comment[ru]=Графический интерфейс для эмуляторов, игровых движков и медиаплееров From 3ad4b057f96013ef585715e14de1b217377c100c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 10 May 2020 00:57:59 +0200 Subject: [PATCH 019/192] Go back to 1.8.4 netcode --- Makefile.common | 1 + griffin/griffin.c | 1 + network/netplay/netplay.h | 26 + network/netplay/netplay_frontend.c | 1618 +++++++++++++++++++++++++++ network/netplay/netplay_handshake.c | 95 +- network/netplay/netplay_init.c | 6 +- network/netplay/netplay_io.c | 19 +- network/netplay/netplay_private.h | 13 +- network/netplay/netplay_sync.c | 26 +- retroarch.c | 1606 +------------------------- 10 files changed, 1742 insertions(+), 1669 deletions(-) create mode 100644 network/netplay/netplay_frontend.c diff --git a/Makefile.common b/Makefile.common index bd82ed4b89..43d9cf8c6f 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1830,6 +1830,7 @@ ifeq ($(HAVE_NETWORKING), 1) # Netplay DEFINES += -DHAVE_NETWORK_CMD OBJ += network/netplay/netplay_delta.o \ + network/netplay/netplay_frontend.o \ network/netplay/netplay_handshake.o \ network/netplay/netplay_init.o \ network/netplay/netplay_io.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index b002383690..5a49927fda 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -1205,6 +1205,7 @@ NETPLAY #ifdef HAVE_NETWORKING #include "../network/netplay/netplay_delta.c" #include "../network/netplay/netplay_handshake.c" +#include "../network/netplay/netplay_frontend.c" #include "../network/netplay/netplay_init.c" #include "../network/netplay/netplay_io.c" #include "../network/netplay/netplay_keyboard.c" diff --git a/network/netplay/netplay.h b/network/netplay/netplay.h index 74b43a3259..b7da64ffe3 100644 --- a/network/netplay/netplay.h +++ b/network/netplay/netplay.h @@ -86,6 +86,32 @@ enum rarch_netplay_share_analog_preference RARCH_NETPLAY_SHARE_ANALOG_LAST }; +int16_t input_state_net(unsigned port, unsigned device, + unsigned idx, unsigned id); + +void video_frame_net(const void *data, unsigned width, + unsigned height, size_t pitch); + +void audio_sample_net(int16_t left, int16_t right); + +size_t audio_sample_batch_net(const int16_t *data, size_t frames); + +bool init_netplay_deferred(const char* server, unsigned port); + +/** + * init_netplay + * @direct_host : Host to connect to directly, if applicable (client only) + * @server : server address to connect to (client only) + * @port : TCP port to host on/connect to + * + * Initializes netplay. + * + * If netplay is already initialized, will return false (0). + * + * Returns: true (1) if successful, otherwise false (0). + **/ +bool init_netplay(void *direct_host, const char *server, unsigned port); + void deinit_netplay(void); bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data); diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c new file mode 100644 index 0000000000..9ece3fb050 --- /dev/null +++ b/network/netplay/netplay_frontend.c @@ -0,0 +1,1618 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2017 - Daniel De Matteis + * Copyright (C) 2016-2017 - Gregor Richards + * + * 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 "../../version.h" + +#include +#include +#include +#include +#include + +#ifdef HAVE_DISCORD +#include +#endif + +#include + +#include "netplay_discovery.h" +#include "netplay_private.h" + +#include "../../configuration.h" +#include "../../frontend/frontend_driver.h" +#include "../../tasks/task_content.h" +#include "../../tasks/tasks_internal.h" +#include "../../file_path_special.h" +#include "../../paths.h" +#include "../../command.h" +#include "../../dynamic.h" +#include "../../retroarch.h" + +/* Only used before init_netplay */ +static bool netplay_enabled = false; +static bool netplay_is_client = false; + +/* Used while Netplay is running */ +static netplay_t *netplay_data = NULL; + +/* Used to avoid recursive netplay calls */ +static bool in_netplay = false; + +/* Used for deferred netplay initialization */ +static bool netplay_client_deferred = false; +static char server_address_deferred[512] = ""; +static unsigned server_port_deferred = 0; + +/* Used */ +static int reannounce = 0; +static bool is_mitm = false; + +static bool netplay_disconnect(netplay_t *netplay); + +#ifdef HAVE_DISCORD +/* TODO/FIXME - global */ +extern bool discord_is_inited; +#endif + +/** + * netplay_is_alive: + * @netplay : pointer to netplay object + * + * Checks if input port/index is controlled by netplay or not. + * + * Returns: true (1) if alive, otherwise false (0). + **/ +static bool netplay_is_alive(netplay_t *netplay) +{ + if (!netplay) + return false; + return (netplay->is_server) || + (!netplay->is_server && netplay->self_mode >= NETPLAY_CONNECTION_CONNECTED); +} + +/** + * netplay_should_skip: + * @netplay : pointer to netplay object + * + * If we're fast-forward replaying to resync, check if we + * should actually show frame. + * + * Returns: bool (1) if we should skip this frame, otherwise + * false (0). + **/ +static bool netplay_should_skip(netplay_t *netplay) +{ + if (!netplay) + return false; + return netplay->is_replay && (netplay->self_mode >= NETPLAY_CONNECTION_CONNECTED); +} + +/** + * netplay_can_poll + * + * Just a frontend for netplay->can_poll that handles netplay==NULL + */ +static bool netplay_can_poll(netplay_t *netplay) +{ + if (!netplay) + return false; + return netplay->can_poll; +} + +/** + * get_self_input_state: + * @netplay : pointer to netplay object + * + * Grab our own input state and send this frame's input state (self and remote) + * over the network + * + * Returns: true (1) if successful, otherwise false (0). + */ +static bool get_self_input_state(netplay_t *netplay) +{ + unsigned i; + struct delta_frame *ptr = &netplay->buffer[netplay->self_ptr]; + netplay_input_state_t istate = NULL; + uint32_t devices, used_devices = 0, devi, dev_type, local_device; + + if (!netplay_delta_frame_ready(netplay, ptr, netplay->self_frame_count)) + return false; + + /* We've already read this frame! */ + if (ptr->have_local) + return true; + + devices = netplay->self_devices; + used_devices = 0; + + for (devi = 0; devi < MAX_INPUT_DEVICES; devi++) + { + if (!(devices & (1<config_devices[devi]&RETRO_DEVICE_MASK; + + for (local_device = 0; local_device < MAX_INPUT_DEVICES; local_device++) + { + if (used_devices & (1<config_devices[local_device]&RETRO_DEVICE_MASK) == dev_type) + break; + } + + if (local_device == MAX_INPUT_DEVICES) + local_device = 0; + used_devices |= (1<real_input[devi], + /* If we're a slave, we write our own input to MAX_CLIENTS to keep it separate */ + (netplay->self_mode==NETPLAY_CONNECTION_SLAVE)?MAX_CLIENTS:netplay->self_client_num, + netplay_expected_input_size(netplay, 1 << devi), + true, false); + if (!istate) + continue; /* FIXME: More severe? */ + + /* First frame we always give zero input since relying on + * input from first frame screws up when we use -F 0. */ + if (!input_driver_is_libretro_input_blocked() && netplay->self_frame_count > 0) + { + uint32_t *state = istate->data; + retro_input_state_t cb = netplay->cbs.state_cb; + unsigned dtype = netplay->config_devices[devi]&RETRO_DEVICE_MASK; + + switch (dtype) + { + case RETRO_DEVICE_ANALOG: + for (i = 0; i < 2; i++) + { + int16_t tmp_x = cb(local_device, + RETRO_DEVICE_ANALOG, (unsigned)i, 0); + int16_t tmp_y = cb(local_device, + RETRO_DEVICE_ANALOG, (unsigned)i, 1); + state[1 + i] = (uint16_t)tmp_x | (((uint16_t)tmp_y) << 16); + } + /* no break */ + + case RETRO_DEVICE_JOYPAD: + for (i = 0; i <= RETRO_DEVICE_ID_JOYPAD_R3; i++) + { + int16_t tmp = cb(local_device, + RETRO_DEVICE_JOYPAD, 0, (unsigned)i); + state[0] |= tmp ? 1 << i : 0; + } + break; + + case RETRO_DEVICE_MOUSE: + case RETRO_DEVICE_LIGHTGUN: + { + int16_t tmp_x = cb(local_device, dtype, 0, 0); + int16_t tmp_y = cb(local_device, dtype, 0, 1); + state[1] = (uint16_t)tmp_x | (((uint16_t)tmp_y) << 16); + for (i = 2; + i <= (unsigned)((dtype == RETRO_DEVICE_MOUSE) ? + RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN : + RETRO_DEVICE_ID_LIGHTGUN_START); + i++) + { + int16_t tmp = cb(local_device, dtype, 0, + (unsigned) i); + state[0] |= tmp ? 1 << i : 0; + } + break; + } + + case RETRO_DEVICE_KEYBOARD: + { + unsigned key, word = 0, bit = 1; + for (key = 1; key < NETPLAY_KEY_LAST; key++) + { + state[word] |= + cb(local_device, RETRO_DEVICE_KEYBOARD, 0, netplay_key_ntoh(key)) ? + (1U << bit) : 0; + bit++; + if (bit >= 32) + { + bit = 0; + word++; + if (word >= istate->size) + break; + } + } + break; + } + } + } + } + + ptr->have_local = true; + if (netplay->self_mode == NETPLAY_CONNECTION_PLAYING) + { + ptr->have_real[netplay->self_client_num] = true; + netplay->read_ptr[netplay->self_client_num] = NEXT_PTR(netplay->self_ptr); + netplay->read_frame_count[netplay->self_client_num] = netplay->self_frame_count + 1; + } + + /* And send this input to our peers */ + for (i = 0; i < netplay->connections_size; i++) + { + struct netplay_connection *connection = &netplay->connections[i]; + if (connection->active && connection->mode >= NETPLAY_CONNECTION_CONNECTED) + netplay_send_cur_input(netplay, &netplay->connections[i]); + } + + /* Handle any delayed state changes */ + if (netplay->is_server) + netplay_delayed_state_change(netplay); + + return true; +} + +bool init_netplay_deferred(const char* server, unsigned port) +{ + if (!string_is_empty(server) && port != 0) + { + strlcpy(server_address_deferred, server, sizeof(server_address_deferred)); + server_port_deferred = port; + netplay_client_deferred = true; + } + else + netplay_client_deferred = false; + return netplay_client_deferred; +} + +/** + * netplay_poll: + * @netplay : pointer to netplay object + * + * Polls network to see if we have anything new. If our + * network buffer is full, we simply have to block + * for new input data. + * + * Returns: true (1) if successful, otherwise false (0). + **/ +static bool netplay_poll(netplay_t *netplay) +{ + int res; + uint32_t client; + size_t i; + + netplay->can_poll = false; + + if (!get_self_input_state(netplay)) + goto catastrophe; + + /* If we're not connected, we're done */ + if (netplay->self_mode == NETPLAY_CONNECTION_NONE) + return true; + + /* Read Netplay input, block if we're configured to stall for input every + * frame */ + netplay_update_unread_ptr(netplay); + if (netplay->stateless_mode && + (netplay->connected_players>1) && + netplay->unread_frame_count <= netplay->run_frame_count) + res = netplay_poll_net_input(netplay, true); + else + res = netplay_poll_net_input(netplay, false); + if (res == -1) + goto catastrophe; + + /* Resolve and/or simulate the input if we don't have real input */ + netplay_resolve_input(netplay, netplay->run_ptr, false); + + /* Handle any slaves */ + if (netplay->is_server && netplay->connected_slaves) + netplay_handle_slaves(netplay); + + netplay_update_unread_ptr(netplay); + + /* Figure out how many frames of input latency we should be using to hide + * network latency */ + if (netplay->frame_run_time_avg || netplay->stateless_mode) + { + /* FIXME: Using fixed 60fps for this calculation */ + unsigned frames_per_frame = netplay->frame_run_time_avg ? + (16666 / netplay->frame_run_time_avg) : + 0; + unsigned frames_ahead = (netplay->run_frame_count > netplay->unread_frame_count) ? + (netplay->run_frame_count - netplay->unread_frame_count) : + 0; + settings_t *settings = config_get_ptr(); + int input_latency_frames_min = settings->uints.netplay_input_latency_frames_min - + (settings->bools.run_ahead_enabled ? settings->uints.run_ahead_frames : 0); + int input_latency_frames_max = input_latency_frames_min + settings->uints.netplay_input_latency_frames_range; + + /* Assume we need a couple frames worth of time to actually run the + * current frame */ + if (frames_per_frame > 2) + frames_per_frame -= 2; + else + frames_per_frame = 0; + + /* Shall we adjust our latency? */ + if (netplay->stateless_mode) + { + /* In stateless mode, we adjust up if we're "close" and down if we + * have a lot of slack */ + if (netplay->input_latency_frames < input_latency_frames_min || + (netplay->unread_frame_count == netplay->run_frame_count + 1 && + netplay->input_latency_frames < input_latency_frames_max)) + netplay->input_latency_frames++; + else if (netplay->input_latency_frames > input_latency_frames_max || + (netplay->unread_frame_count > netplay->run_frame_count + 2 && + netplay->input_latency_frames > input_latency_frames_min)) + netplay->input_latency_frames--; + } + else if (netplay->input_latency_frames < input_latency_frames_min || + (frames_per_frame < frames_ahead && + netplay->input_latency_frames < input_latency_frames_max)) + { + /* We can't hide this much network latency with replay, so hide some + * with input latency */ + netplay->input_latency_frames++; + } + else if (netplay->input_latency_frames > input_latency_frames_max || + (frames_per_frame > frames_ahead + 2 && + netplay->input_latency_frames > input_latency_frames_min)) + { + /* We don't need this much latency (any more) */ + netplay->input_latency_frames--; + } + } + + /* If we're stalled, consider unstalling */ + switch (netplay->stall) + { + case NETPLAY_STALL_RUNNING_FAST: + { + if (netplay->unread_frame_count + NETPLAY_MAX_STALL_FRAMES - 2 + > netplay->self_frame_count) + { + netplay->stall = NETPLAY_STALL_NONE; + for (i = 0; i < netplay->connections_size; i++) + { + struct netplay_connection *connection = &netplay->connections[i]; + if (connection->active && connection->stall) + connection->stall = NETPLAY_STALL_NONE; + } + } + break; + } + + case NETPLAY_STALL_SPECTATOR_WAIT: + if (netplay->self_mode == NETPLAY_CONNECTION_PLAYING || netplay->unread_frame_count > netplay->self_frame_count) + netplay->stall = NETPLAY_STALL_NONE; + break; + + case NETPLAY_STALL_INPUT_LATENCY: + /* Just let it recalculate momentarily */ + netplay->stall = NETPLAY_STALL_NONE; + break; + + case NETPLAY_STALL_SERVER_REQUESTED: + /* See if the stall is done */ + if (netplay->connections[0].stall_frame == 0) + { + /* Stop stalling! */ + netplay->connections[0].stall = NETPLAY_STALL_NONE; + netplay->stall = NETPLAY_STALL_NONE; + } + else + netplay->connections[0].stall_frame--; + break; + case NETPLAY_STALL_NO_CONNECTION: + /* We certainly haven't fixed this */ + break; + default: /* not stalling */ + break; + } + + /* If we're not stalled, consider stalling */ + if (!netplay->stall) + { + /* Have we not read enough latency frames? */ + if (netplay->self_mode == NETPLAY_CONNECTION_PLAYING && + netplay->connected_players && + netplay->run_frame_count + netplay->input_latency_frames > netplay->self_frame_count) + { + netplay->stall = NETPLAY_STALL_INPUT_LATENCY; + netplay->stall_time = 0; + } + + /* Are we too far ahead? */ + if (netplay->unread_frame_count + NETPLAY_MAX_STALL_FRAMES + <= netplay->self_frame_count) + { + netplay->stall = NETPLAY_STALL_RUNNING_FAST; + netplay->stall_time = cpu_features_get_time_usec(); + + /* Figure out who to blame */ + if (netplay->is_server) + { + for (client = 1; client < MAX_CLIENTS; client++) + { + struct netplay_connection *connection; + if (!(netplay->connected_players & (1<read_frame_count[client] > netplay->unread_frame_count) + continue; + connection = &netplay->connections[client-1]; + if (connection->active && + connection->mode == NETPLAY_CONNECTION_PLAYING) + { + connection->stall = NETPLAY_STALL_RUNNING_FAST; + connection->stall_time = netplay->stall_time; + } + } + } + + } + + /* If we're a spectator, are we ahead at all? */ + if (!netplay->is_server && + (netplay->self_mode == NETPLAY_CONNECTION_SPECTATING || + netplay->self_mode == NETPLAY_CONNECTION_SLAVE) && + netplay->unread_frame_count <= netplay->self_frame_count) + { + netplay->stall = NETPLAY_STALL_SPECTATOR_WAIT; + netplay->stall_time = cpu_features_get_time_usec(); + } + } + + /* If we're stalling, consider disconnection */ + if (netplay->stall && netplay->stall_time) + { + retro_time_t now = cpu_features_get_time_usec(); + + /* Don't stall out while they're paused */ + if (netplay->remote_paused) + netplay->stall_time = now; + else if (now - netplay->stall_time >= + (netplay->is_server ? MAX_SERVER_STALL_TIME_USEC : + MAX_CLIENT_STALL_TIME_USEC)) + { + /* Stalled out! */ + if (netplay->is_server) + { + bool fixed = false; + for (i = 0; i < netplay->connections_size; i++) + { + struct netplay_connection *connection = &netplay->connections[i]; + if (connection->active && + connection->mode == NETPLAY_CONNECTION_PLAYING && + connection->stall) + { + netplay_hangup(netplay, connection); + fixed = true; + } + } + + if (fixed) + { + /* Not stalled now :) */ + netplay->stall = NETPLAY_STALL_NONE; + return true; + } + } + else + goto catastrophe; + return false; + } + } + + return true; + +catastrophe: + for (i = 0; i < netplay->connections_size; i++) + netplay_hangup(netplay, &netplay->connections[i]); + return false; +} + +/** + * input_poll_net + * + * Poll the network if necessary. + */ +void input_poll_net(void) +{ + netplay_t *netplay = netplay_data; + if (!netplay_should_skip(netplay) && netplay_can_poll(netplay)) + netplay_poll(netplay); +} + +/* Netplay polling callbacks */ +void video_frame_net(const void *data, unsigned width, + unsigned height, size_t pitch) +{ + netplay_t *netplay = netplay_data; + if (!netplay_should_skip(netplay)) + netplay->cbs.frame_cb(data, width, height, pitch); +} + +void audio_sample_net(int16_t left, int16_t right) +{ + netplay_t *netplay = netplay_data; + if (!netplay_should_skip(netplay) && !netplay->stall) + netplay->cbs.sample_cb(left, right); +} + +size_t audio_sample_batch_net(const int16_t *data, size_t frames) +{ + netplay_t *netplay = netplay_data; + if (!netplay_should_skip(netplay) && !netplay->stall) + return netplay->cbs.sample_batch_cb(data, frames); + return frames; +} + +static int16_t netplay_input_state(netplay_t *netplay, + unsigned port, unsigned device, + unsigned idx, unsigned id) +{ + size_t ptr = netplay->is_replay ? + netplay->replay_ptr : netplay->run_ptr; + struct delta_frame *delta; + netplay_input_state_t istate; + + const uint32_t *curr_input_state = NULL; + + if (port >= MAX_INPUT_DEVICES) + return 0; + + /* If the port doesn't seem to correspond to the device, "correct" it. This + * is common with devices that typically only have one instance, such as + * keyboards, mice and lightguns. */ + if (device != RETRO_DEVICE_JOYPAD && + (netplay->config_devices[port]&RETRO_DEVICE_MASK) != device) + { + for (port = 0; port < MAX_INPUT_DEVICES; port++) + { + if ((netplay->config_devices[port]&RETRO_DEVICE_MASK) == device) + break; + } + if (port == MAX_INPUT_DEVICES) + return 0; + } + + delta = &netplay->buffer[ptr]; + istate = delta->resolved_input[port]; + if (!istate || !istate->used) + return 0; + + if (istate->size == 0) + return 0; + curr_input_state = istate->data; + + switch (device) + { + case RETRO_DEVICE_JOYPAD: + if (id == RETRO_DEVICE_ID_JOYPAD_MASK) + return curr_input_state[0]; + return ((1 << id) & curr_input_state[0]) ? 1 : 0; + + case RETRO_DEVICE_ANALOG: + { + uint32_t state; + if (istate->size != 3) + return 0; + state = curr_input_state[1 + idx]; + return (int16_t)(uint16_t)(state >> (id * 16)); + } + + case RETRO_DEVICE_MOUSE: + case RETRO_DEVICE_LIGHTGUN: + if (istate->size != 2) + return 0; + if (id <= RETRO_DEVICE_ID_MOUSE_Y) + return (int16_t)(uint16_t)(curr_input_state[1] >> (id * 16)); + return ((1 << id) & curr_input_state[0]) ? 1 : 0; + case RETRO_DEVICE_KEYBOARD: + { + unsigned word, bit; + unsigned key = netplay_key_hton(id); + if (key == NETPLAY_KEY_UNKNOWN) + return 0; + word = key / 32; + bit = key % 32; + if (word <= istate->size) + return ((1U<len == 0) + { + free(task_data); + return; + } + + buf = (char*)calloc(1, data->len + 1); + + memcpy(buf, data->data, data->len); + + lines = string_split(buf, "\n"); + + if (lines->size == 0) + { + string_list_free(lines); + free(buf); + free(task_data); + return; + } + + memset(host_room, 0, sizeof(*host_room)); + + for (i = 0; i < lines->size; i++) + { + const char *line = lines->elems[i].data; + + if (!string_is_empty(line)) + { + struct string_list *kv = string_split(line, "="); + const char *key = NULL; + const char *val = NULL; + + if (!kv) + continue; + + if (kv->size != 2) + { + string_list_free(kv); + continue; + } + + key = kv->elems[0].data; + val = kv->elems[1].data; + + if (string_is_equal(key, "id")) + sscanf(val, "%i", &host_room->id); + if (string_is_equal(key, "username")) + strlcpy(host_room->nickname, val, sizeof(host_room->nickname)); + if (string_is_equal(key, "ip")) + strlcpy(host_room->address, val, sizeof(host_room->address)); + if (string_is_equal(key, "mitm_ip")) + { + mitm_ip = strdup(val); + strlcpy(host_room->mitm_address, val, sizeof(host_room->mitm_address)); + } + if (string_is_equal(key, "port")) + sscanf(val, "%i", &host_room->port); + if (string_is_equal(key, "mitm_port")) + { + mitm_port = strdup(val); + sscanf(mitm_port, "%i", &host_room->mitm_port); + } + if (string_is_equal(key, "core_name")) + strlcpy(host_room->corename, val, sizeof(host_room->corename)); + if (string_is_equal(key, "frontend")) + strlcpy(host_room->frontend, val, sizeof(host_room->frontend)); + if (string_is_equal(key, "core_version")) + strlcpy(host_room->coreversion, val, sizeof(host_room->coreversion)); + if (string_is_equal(key, "game_name")) + strlcpy(host_room->gamename, val, sizeof(host_room->gamename)); + if (string_is_equal(key, "game_crc")) + sscanf(val, "%08d", &host_room->gamecrc); + if (string_is_equal(key, "host_method")) + sscanf(val, "%i", &host_room->host_method); + if (string_is_equal(key, "has_password")) + { + if (string_is_equal_noncase(val, "true") || string_is_equal(val, "1")) + host_room->has_password = true; + else + host_room->has_password = false; + } + if (string_is_equal(key, "has_spectate_password")) + { + if (string_is_equal_noncase(val, "true") || string_is_equal(val, "1")) + host_room->has_spectate_password = true; + else + host_room->has_spectate_password = false; + } + if (string_is_equal(key, "fixed")) + { + if (string_is_equal_noncase(val, "true") || string_is_equal(val, "1")) + host_room->fixed = true; + else + host_room->fixed = false; + } + if (string_is_equal(key, "retroarch_version")) + strlcpy(host_room->retroarch_version, val, sizeof(host_room->retroarch_version)); + if (string_is_equal(key, "country")) + strlcpy(host_room->country, val, sizeof(host_room->country)); + + string_list_free(kv); + } + } + + if (mitm_ip && mitm_port) + { + ip_len = (unsigned)strlen(mitm_ip); + port_len = (unsigned)strlen(mitm_port); + + /* Enable Netplay client mode */ + if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) + { + command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); + is_mitm = true; + host_room->host_method = NETPLAY_HOST_METHOD_MITM; + } + + netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL); + + host_string = (char*)calloc(1, ip_len + port_len + 2); + + memcpy(host_string, mitm_ip, ip_len); + memcpy(host_string + ip_len, "|", 1); + memcpy(host_string + ip_len + 1, mitm_port, port_len); + + /* Enable Netplay */ + command_event(CMD_EVENT_NETPLAY_INIT_DIRECT_DEFERRED, (void*)host_string); + command_event(CMD_EVENT_NETPLAY_INIT, (void*)host_string); + + free(host_string); + } + +#ifdef HAVE_DISCORD + if (discord_is_inited) + { + discord_userdata_t userdata; + userdata.status = DISCORD_PRESENCE_NETPLAY_HOSTING; + command_event(CMD_EVENT_DISCORD_UPDATE, &userdata); + } +#endif + + string_list_free(lines); + free(buf); + free(task_data); + if (mitm_ip) + free(mitm_ip); + if (mitm_port) + free(mitm_port); + } + + return; +} + +static void netplay_announce(void) +{ + char buf[4600]; + char frontend_architecture[PATH_MAX_LENGTH]; + char frontend_architecture_tmp[PATH_MAX_LENGTH]; + const frontend_ctx_driver_t *frontend_drv = NULL; + char url[2048] = "http://lobby.libretro.com/add/"; + char *username = NULL; + char *corename = NULL; + char *gamename = NULL; + char *subsystemname = NULL; + char *coreversion = NULL; + char *frontend_ident = NULL; + settings_t *settings = config_get_ptr(); + struct retro_system_info *system = runloop_get_libretro_system_info(); + uint32_t content_crc = content_get_crc(); + struct string_list *subsystem = path_get_subsystem_list(); + + buf[0] = '\0'; + + if (subsystem) + { + unsigned i; + + for (i = 0; i < subsystem->size; i++) + { + strlcat(buf, path_basename(subsystem->elems[i].data), sizeof(buf)); + if (i < subsystem->size - 1) + strlcat(buf, "|", sizeof(buf)); + } + net_http_urlencode(&gamename, buf); + net_http_urlencode(&subsystemname, path_get(RARCH_PATH_SUBSYSTEM)); + content_crc = 0; + } + else + { + net_http_urlencode(&gamename, + !string_is_empty(path_basename(path_get(RARCH_PATH_BASENAME))) ? + path_basename(path_get(RARCH_PATH_BASENAME)) : "N/A"); + net_http_urlencode(&subsystemname, "N/A"); + } + + frontend_drv = + (const frontend_ctx_driver_t*)frontend_driver_get_cpu_architecture_str( + frontend_architecture_tmp, sizeof(frontend_architecture_tmp)); + snprintf(frontend_architecture, sizeof(frontend_architecture), "%s %s", + frontend_drv->ident, frontend_architecture_tmp); + +#ifdef HAVE_DISCORD + if (discord_is_ready()) + net_http_urlencode(&username, discord_get_own_username()); + else +#endif + net_http_urlencode(&username, settings->paths.username); + net_http_urlencode(&corename, system->library_name); + net_http_urlencode(&coreversion, system->library_version); + net_http_urlencode(&frontend_ident, frontend_architecture); + + buf[0] = '\0'; + + snprintf(buf, sizeof(buf), "username=%s&core_name=%s&core_version=%s&" + "game_name=%s&game_crc=%08X&port=%d&mitm_server=%s" + "&has_password=%d&has_spectate_password=%d&force_mitm=%d" + "&retroarch_version=%s&frontend=%s&subsystem_name=%s", + username, corename, coreversion, gamename, content_crc, + settings->uints.netplay_port, + settings->arrays.netplay_mitm_server, + *settings->paths.netplay_password ? 1 : 0, + *settings->paths.netplay_spectate_password ? 1 : 0, + settings->bools.netplay_use_mitm_server, + PACKAGE_VERSION, frontend_architecture, subsystemname); + task_push_http_post_transfer(url, buf, true, NULL, netplay_announce_cb, NULL); + + if (username) + free(username); + if (corename) + free(corename); + if (gamename) + free(gamename); + if (coreversion) + free(coreversion); + if (frontend_ident) + free(frontend_ident); +} + +int16_t input_state_net(unsigned port, unsigned device, + unsigned idx, unsigned id) +{ + netplay_t *netplay = netplay_data; + if (netplay_is_alive(netplay)) + return netplay_input_state(netplay, port, device, idx, id); + return netplay->cbs.state_cb(port, device, idx, id); +} +/* ^^^ Netplay polling callbacks */ + +/** + * netplay_command: + * @netplay : pointer to netplay object + * @cmd : command to send + * @data : data to send as argument + * @sz : size of data + * @command_str : name of action + * @success_msg : message to display upon success + * + * Sends a single netplay command and waits for response. Only actually used + * for player flipping. FIXME: Should probably just be removed. + */ +bool netplay_command(netplay_t* netplay, struct netplay_connection *connection, + enum netplay_cmd cmd, void* data, size_t sz, const char* command_str, + const char* success_msg) +{ + retro_assert(netplay); + + if (!netplay_send_raw_cmd(netplay, connection, cmd, data, sz)) + return false; + + runloop_msg_queue_push(success_msg, 1, 180, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + + return true; +} + +/** +* netplay_frontend_paused + * @netplay : pointer to netplay object + * @paused : true if frontend is paused + * + * Inform Netplay of the frontend's pause state (paused or otherwise) + */ +static void netplay_frontend_paused(netplay_t *netplay, bool paused) +{ + size_t i; + uint32_t paused_ct; + + /* Nothing to do if we already knew this */ + if (netplay->local_paused == paused) + return; + + netplay->local_paused = paused; + + /* Communicating this is a bit odd: If exactly one other connection is + * paused, then we must tell them that we're unpaused, as from their + * perspective we are. If more than one other connection is paused, then our + * status as proxy means we are NOT unpaused to either of them. */ + paused_ct = 0; + for (i = 0; i < netplay->connections_size; i++) + { + struct netplay_connection *connection = &netplay->connections[i]; + if (connection->active && connection->paused) + paused_ct++; + } + if (paused_ct > 1) + return; + + /* Send our unpaused status. Must send manually because we must immediately + * flush the buffer: If we're paused, we won't be polled. */ + for (i = 0; i < netplay->connections_size; i++) + { + struct netplay_connection *connection = &netplay->connections[i]; + if (connection->active && connection->mode >= NETPLAY_CONNECTION_CONNECTED) + { + if (paused) + netplay_send_raw_cmd(netplay, connection, NETPLAY_CMD_PAUSE, + netplay->nick, NETPLAY_NICK_LEN); + else + netplay_send_raw_cmd(netplay, connection, NETPLAY_CMD_RESUME, + NULL, 0); + + /* We're not going to be polled, so we need to flush this command now */ + netplay_send_flush(&connection->send_packet_buffer, connection->fd, true); + } + } +} + +/** + * netplay_pre_frame: + * @netplay : pointer to netplay object + * + * Pre-frame for Netplay. + * Call this before running retro_run(). + * + * Returns: true (1) if the frontend is cleared to emulate the frame, false (0) + * if we're stalled or paused + **/ +bool netplay_pre_frame(netplay_t *netplay) +{ + bool sync_stalled = false; + settings_t *settings = config_get_ptr(); + + retro_assert(netplay); + + if (settings->bools.netplay_public_announce) + { + reannounce++; + if ((netplay->is_server || is_mitm) && (reannounce % 600 == 0)) + netplay_announce(); + } + /* Make sure that if announcement is turned on mid-game, it gets announced */ + else + reannounce = -1; + + /* FIXME: This is an ugly way to learn we're not paused anymore */ + if (netplay->local_paused) + netplay_frontend_paused(netplay, false); + + /* Are we ready now? */ + if (netplay->quirks & NETPLAY_QUIRK_INITIALIZATION) + netplay_try_init_serialization(netplay); + + if (netplay->is_server && !settings->bools.netplay_use_mitm_server) + { + /* Advertise our server */ + netplay_lan_ad_server(netplay); + + /* NAT traversal if applicable */ + if (netplay->nat_traversal && + !netplay->nat_traversal_task_oustanding && + netplay->nat_traversal_state.request_outstanding && + !netplay->nat_traversal_state.have_inet4) + { + struct timeval tmptv = {0}; + fd_set fds = netplay->nat_traversal_state.fds; + if (socket_select(netplay->nat_traversal_state.nfds, &fds, NULL, NULL, &tmptv) > 0) + natt_read(&netplay->nat_traversal_state); + +#ifndef HAVE_SOCKET_LEGACY + if (!netplay->nat_traversal_state.request_outstanding || + netplay->nat_traversal_state.have_inet4) + netplay_announce_nat_traversal(netplay); +#endif + } + } + + sync_stalled = !netplay_sync_pre_frame(netplay); + + /* If we're disconnected, deinitialize */ + if (!netplay->is_server && !netplay->connections[0].active) + { + netplay_disconnect(netplay); + return true; + } + + if (sync_stalled || + ((!netplay->is_server || (netplay->connected_players>1)) && + (netplay->stall || netplay->remote_paused))) + { + /* We may have received data even if we're stalled, so run post-frame + * sync */ + netplay_sync_post_frame(netplay, true); + return false; + } + return true; +} + +/** + * netplay_post_frame: + * @netplay : pointer to netplay object + * + * Post-frame for Netplay. + * We check if we have new input and replay from recorded input. + * Call this after running retro_run(). + **/ +void netplay_post_frame(netplay_t *netplay) +{ + size_t i; + retro_assert(netplay); + netplay_update_unread_ptr(netplay); + netplay_sync_post_frame(netplay, false); + + for (i = 0; i < netplay->connections_size; i++) + { + struct netplay_connection *connection = &netplay->connections[i]; + if (connection->active && + !netplay_send_flush(&connection->send_packet_buffer, connection->fd, + false)) + netplay_hangup(netplay, connection); + } + + /* If we're disconnected, deinitialize */ + if (!netplay->is_server && !netplay->connections[0].active) + netplay_disconnect(netplay); +} + +/** + * netplay_force_future + * @netplay : pointer to netplay object + * + * Force netplay to ignore all past input, typically because we've just loaded + * a state or reset. + */ +static void netplay_force_future(netplay_t *netplay) +{ + /* Wherever we're inputting, that's where we consider our state to be loaded */ + netplay->run_ptr = netplay->self_ptr; + netplay->run_frame_count = netplay->self_frame_count; + + /* We need to ignore any intervening data from the other side, + * and never rewind past this */ + netplay_update_unread_ptr(netplay); + + if (netplay->unread_frame_count < netplay->run_frame_count) + { + uint32_t client; + for (client = 0; client < MAX_CLIENTS; client++) + { + if (!(netplay->connected_players & (1<read_frame_count[client] < netplay->run_frame_count) + { + netplay->read_ptr[client] = netplay->run_ptr; + netplay->read_frame_count[client] = netplay->run_frame_count; + } + } + if (netplay->server_frame_count < netplay->run_frame_count) + { + netplay->server_ptr = netplay->run_ptr; + netplay->server_frame_count = netplay->run_frame_count; + } + netplay_update_unread_ptr(netplay); + } + if (netplay->other_frame_count < netplay->run_frame_count) + { + netplay->other_ptr = netplay->run_ptr; + netplay->other_frame_count = netplay->run_frame_count; + } +} + +/** + * netplay_send_savestate + * @netplay : pointer to netplay object + * @serial_info : the savestate being loaded + * @cx : compression type + * @z : compression backend to use + * + * Send a loaded savestate to those connected peers using the given compression + * scheme. + */ +void netplay_send_savestate(netplay_t *netplay, + retro_ctx_serialize_info_t *serial_info, uint32_t cx, + struct compression_transcoder *z) +{ + uint32_t header[4]; + uint32_t rd, wn; + size_t i; + + /* Compress it */ + z->compression_backend->set_in(z->compression_stream, + (const uint8_t*)serial_info->data_const, (uint32_t)serial_info->size); + z->compression_backend->set_out(z->compression_stream, + netplay->zbuffer, (uint32_t)netplay->zbuffer_size); + if (!z->compression_backend->trans(z->compression_stream, true, &rd, + &wn, NULL)) + { + /* Catastrophe! */ + for (i = 0; i < netplay->connections_size; i++) + netplay_hangup(netplay, &netplay->connections[i]); + return; + } + + /* Send it to relevant peers */ + header[0] = htonl(NETPLAY_CMD_LOAD_SAVESTATE); + header[1] = htonl(wn + 2*sizeof(uint32_t)); + header[2] = htonl(netplay->run_frame_count); + header[3] = htonl(serial_info->size); + + for (i = 0; i < netplay->connections_size; i++) + { + struct netplay_connection *connection = &netplay->connections[i]; + if (!connection->active || + connection->mode < NETPLAY_CONNECTION_CONNECTED || + connection->compression_supported != cx) continue; + + if (!netplay_send(&connection->send_packet_buffer, connection->fd, header, + sizeof(header)) || + !netplay_send(&connection->send_packet_buffer, connection->fd, + netplay->zbuffer, wn)) + netplay_hangup(netplay, connection); + } +} + +/** + * netplay_load_savestate + * @netplay : pointer to netplay object + * @serial_info : the savestate being loaded, NULL means + * "load it yourself" + * @save : Whether to save the provided serial_info + * into the frame buffer + * + * Inform Netplay of a savestate load and send it to the other side + **/ +void netplay_load_savestate(netplay_t *netplay, + retro_ctx_serialize_info_t *serial_info, bool save) +{ + retro_ctx_serialize_info_t tmp_serial_info; + + netplay_force_future(netplay); + + /* Record it in our own buffer */ + if (save || !serial_info) + { + if (netplay_delta_frame_ready(netplay, + &netplay->buffer[netplay->run_ptr], netplay->run_frame_count)) + { + if (!serial_info) + { + tmp_serial_info.size = netplay->state_size; + tmp_serial_info.data = netplay->buffer[netplay->run_ptr].state; + if (!core_serialize(&tmp_serial_info)) + return; + tmp_serial_info.data_const = tmp_serial_info.data; + serial_info = &tmp_serial_info; + } + else + { + if (serial_info->size <= netplay->state_size) + memcpy(netplay->buffer[netplay->run_ptr].state, + serial_info->data_const, serial_info->size); + } + } + /* FIXME: This is a critical failure! */ + else + return; + } + + /* Don't send it if we're expected to be desynced */ + if (netplay->desync) + return; + + /* If we can't send it to the peer, loading a state was a bad idea */ + if (netplay->quirks & ( + NETPLAY_QUIRK_NO_SAVESTATES + | NETPLAY_QUIRK_NO_TRANSMISSION)) + return; + + /* Send this to every peer */ + if (netplay->compress_nil.compression_backend) + netplay_send_savestate(netplay, serial_info, 0, &netplay->compress_nil); + if (netplay->compress_zlib.compression_backend) + netplay_send_savestate(netplay, serial_info, NETPLAY_COMPRESSION_ZLIB, + &netplay->compress_zlib); +} + +/** + * netplay_core_reset + * @netplay : pointer to netplay object + * + * Indicate that the core has been reset to netplay peers + **/ +static void netplay_core_reset(netplay_t *netplay) +{ + uint32_t cmd[3]; + size_t i; + + /* Ignore past input */ + netplay_force_future(netplay); + + /* Request that our peers reset */ + cmd[0] = htonl(NETPLAY_CMD_RESET); + cmd[1] = htonl(sizeof(uint32_t)); + cmd[2] = htonl(netplay->self_frame_count); + + for (i = 0; i < netplay->connections_size; i++) + { + struct netplay_connection *connection = &netplay->connections[i]; + if (!connection->active || + connection->mode < NETPLAY_CONNECTION_CONNECTED) continue; + + if (!netplay_send(&connection->send_packet_buffer, connection->fd, cmd, + sizeof(cmd))) + netplay_hangup(netplay, connection); + } +} + +/** + * netplay_settings_share_mode + * + * Get the preferred share mode + */ +uint8_t netplay_settings_share_mode(unsigned share_digital, unsigned share_analog) +{ + if (share_digital || share_analog) + { + uint8_t share_mode = 0; + + switch (share_digital) + { + case RARCH_NETPLAY_SHARE_DIGITAL_OR: + share_mode |= NETPLAY_SHARE_DIGITAL_OR; + break; + case RARCH_NETPLAY_SHARE_DIGITAL_XOR: + share_mode |= NETPLAY_SHARE_DIGITAL_XOR; + break; + case RARCH_NETPLAY_SHARE_DIGITAL_VOTE: + share_mode |= NETPLAY_SHARE_DIGITAL_VOTE; + break; + default: + share_mode |= NETPLAY_SHARE_NO_PREFERENCE; + } + + switch (share_analog) + { + case RARCH_NETPLAY_SHARE_ANALOG_MAX: + share_mode |= NETPLAY_SHARE_ANALOG_MAX; + break; + case RARCH_NETPLAY_SHARE_ANALOG_AVERAGE: + share_mode |= NETPLAY_SHARE_ANALOG_AVERAGE; + break; + default: + share_mode |= NETPLAY_SHARE_NO_PREFERENCE; + } + + return share_mode; + } + return 0; +} + +/** + * netplay_toggle_play_spectate + * + * Toggle between play mode and spectate mode + */ +static void netplay_toggle_play_spectate(netplay_t *netplay) +{ + switch (netplay->self_mode) + { + case NETPLAY_CONNECTION_PLAYING: + case NETPLAY_CONNECTION_SLAVE: + /* Switch to spectator mode immediately */ + netplay->self_mode = NETPLAY_CONNECTION_SPECTATING; + netplay_cmd_mode(netplay, NETPLAY_CONNECTION_SPECTATING); + break; + case NETPLAY_CONNECTION_SPECTATING: + /* Switch only after getting permission */ + netplay_cmd_mode(netplay, NETPLAY_CONNECTION_PLAYING); + break; + default: + break; + } +} + +/** + * netplay_disconnect + * @netplay : pointer to netplay object + * + * Disconnect netplay. + * + * Returns: true (1) if successful. At present, cannot fail. + **/ +static bool netplay_disconnect(netplay_t *netplay) +{ + size_t i; + + if (!netplay) + return true; + for (i = 0; i < netplay->connections_size; i++) + netplay_hangup(netplay, &netplay->connections[i]); + + deinit_netplay(); + +#ifdef HAVE_DISCORD + if (discord_is_inited) + { + discord_userdata_t userdata; + userdata.status = DISCORD_PRESENCE_NETPLAY_NETPLAY_STOPPED; + command_event(CMD_EVENT_DISCORD_UPDATE, &userdata); + } +#endif + return true; +} + +void deinit_netplay(void) +{ + if (netplay_data) + { + netplay_free(netplay_data); + netplay_enabled = false; + netplay_is_client = false; + is_mitm = false; + } + netplay_data = NULL; + core_unset_netplay_callbacks(); +} + +/** + * init_netplay + * @direct_host : Host to connect to directly, if applicable (client only) + * @server : server address to connect to (client only) + * @port : TCP port to host on/connect to + * + * Initializes netplay. + * + * If netplay is already initialized, will return false (0). + * + * Returns: true (1) if successful, otherwise false (0). + **/ +bool init_netplay(void *direct_host, const char *server, unsigned port) +{ + struct retro_callbacks cbs = {0}; + settings_t *settings = config_get_ptr(); + uint64_t serialization_quirks = 0; + uint64_t quirks = 0; + bool _netplay_is_client = netplay_is_client; + bool _netplay_enabled = netplay_enabled; + + if (!_netplay_enabled) + return false; + + core_set_default_callbacks(&cbs); + if (!core_set_netplay_callbacks()) + return false; + + /* Map the core's quirks to our quirks */ + serialization_quirks = core_serialization_quirks(); + if (serialization_quirks & ~((uint64_t) NETPLAY_QUIRK_MAP_UNDERSTOOD)) + { + /* Quirks we don't support! Just disable everything. */ + quirks |= NETPLAY_QUIRK_NO_SAVESTATES; + } + if (serialization_quirks & NETPLAY_QUIRK_MAP_NO_SAVESTATES) + quirks |= NETPLAY_QUIRK_NO_SAVESTATES; + if (serialization_quirks & NETPLAY_QUIRK_MAP_NO_TRANSMISSION) + quirks |= NETPLAY_QUIRK_NO_TRANSMISSION; + if (serialization_quirks & NETPLAY_QUIRK_MAP_INITIALIZATION) + quirks |= NETPLAY_QUIRK_INITIALIZATION; + if (serialization_quirks & NETPLAY_QUIRK_MAP_ENDIAN_DEPENDENT) + quirks |= NETPLAY_QUIRK_ENDIAN_DEPENDENT; + if (serialization_quirks & NETPLAY_QUIRK_MAP_PLATFORM_DEPENDENT) + quirks |= NETPLAY_QUIRK_PLATFORM_DEPENDENT; + + if (_netplay_is_client) + { + RARCH_LOG("[netplay] %s\n", msg_hash_to_str(MSG_CONNECTING_TO_NETPLAY_HOST)); + } + else + { + RARCH_LOG("[netplay] %s\n", msg_hash_to_str(MSG_WAITING_FOR_CLIENT)); + runloop_msg_queue_push( + msg_hash_to_str(MSG_WAITING_FOR_CLIENT), + 0, 180, false, + NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + + if (settings->bools.netplay_public_announce) + netplay_announce(); + } + + netplay_data = (netplay_t*)netplay_new( + _netplay_is_client ? direct_host : NULL, + _netplay_is_client ? (!netplay_client_deferred ? server + : server_address_deferred) : NULL, + _netplay_is_client ? (!netplay_client_deferred ? port + : server_port_deferred ) : (port != 0 ? port : RARCH_DEFAULT_PORT), + settings->bools.netplay_stateless_mode, + settings->ints.netplay_check_frames, + &cbs, + settings->bools.netplay_nat_traversal && !settings->bools.netplay_use_mitm_server, +#ifdef HAVE_DISCORD + discord_get_own_username() ? discord_get_own_username() : +#endif + settings->paths.username, + quirks); + + if (netplay_data) + { + if (netplay_data->is_server && !settings->bools.netplay_start_as_spectator) + netplay_toggle_play_spectate(netplay_data); + return true; + } + + RARCH_WARN("%s\n", msg_hash_to_str(MSG_NETPLAY_FAILED)); + + runloop_msg_queue_push( + msg_hash_to_str(MSG_NETPLAY_FAILED), + 0, 180, false, + NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + return false; +} + +/** + * netplay_driver_ctl + * + * Frontend access to Netplay functionality + */ +bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data) +{ + netplay_t *netplay = netplay_data; + bool ret = true; + + if (in_netplay) + return true; + in_netplay = true; + + if (!netplay) + { + switch (state) + { + case RARCH_NETPLAY_CTL_ENABLE_SERVER: + netplay_enabled = true; + netplay_is_client = false; + goto done; + + case RARCH_NETPLAY_CTL_ENABLE_CLIENT: + netplay_enabled = true; + netplay_is_client = true; + break; + + case RARCH_NETPLAY_CTL_DISABLE: + netplay_enabled = false; +#ifdef HAVE_DISCORD + if (discord_is_inited) + { + discord_userdata_t userdata; + userdata.status = DISCORD_PRESENCE_NETPLAY_NETPLAY_STOPPED; + command_event(CMD_EVENT_DISCORD_UPDATE, &userdata); + } +#endif + goto done; + + case RARCH_NETPLAY_CTL_IS_ENABLED: + ret = netplay_enabled; + goto done; + + case RARCH_NETPLAY_CTL_IS_REPLAYING: + case RARCH_NETPLAY_CTL_IS_DATA_INITED: + ret = false; + goto done; + + case RARCH_NETPLAY_CTL_IS_SERVER: + ret = netplay_enabled && !netplay_is_client; + goto done; + + case RARCH_NETPLAY_CTL_IS_CONNECTED: + ret = false; + goto done; + + default: + goto done; + } + } + + switch (state) + { + case RARCH_NETPLAY_CTL_ENABLE_SERVER: + case RARCH_NETPLAY_CTL_ENABLE_CLIENT: + case RARCH_NETPLAY_CTL_IS_DATA_INITED: + goto done; + case RARCH_NETPLAY_CTL_DISABLE: + ret = false; + goto done; + case RARCH_NETPLAY_CTL_IS_ENABLED: + goto done; + case RARCH_NETPLAY_CTL_IS_REPLAYING: + ret = netplay->is_replay; + goto done; + case RARCH_NETPLAY_CTL_IS_SERVER: + ret = netplay_enabled && !netplay_is_client; + goto done; + case RARCH_NETPLAY_CTL_IS_CONNECTED: + ret = netplay->is_connected; + goto done; + case RARCH_NETPLAY_CTL_POST_FRAME: + netplay_post_frame(netplay); + break; + case RARCH_NETPLAY_CTL_PRE_FRAME: + ret = netplay_pre_frame(netplay); + goto done; + case RARCH_NETPLAY_CTL_GAME_WATCH: + netplay_toggle_play_spectate(netplay); + break; + case RARCH_NETPLAY_CTL_PAUSE: + netplay_frontend_paused(netplay, true); + break; + case RARCH_NETPLAY_CTL_UNPAUSE: + netplay_frontend_paused(netplay, false); + break; + case RARCH_NETPLAY_CTL_LOAD_SAVESTATE: + netplay_load_savestate(netplay, (retro_ctx_serialize_info_t*)data, true); + break; + case RARCH_NETPLAY_CTL_RESET: + netplay_core_reset(netplay); + break; + case RARCH_NETPLAY_CTL_DISCONNECT: + ret = netplay_disconnect(netplay); + goto done; + case RARCH_NETPLAY_CTL_FINISHED_NAT_TRAVERSAL: + netplay->nat_traversal_task_oustanding = false; +#ifndef HAVE_SOCKET_LEGACY + netplay_announce_nat_traversal(netplay); +#endif + goto done; + case RARCH_NETPLAY_CTL_DESYNC_PUSH: + netplay->desync++; + break; + case RARCH_NETPLAY_CTL_DESYNC_POP: + if (netplay->desync) + { + netplay->desync--; + if (!netplay->desync) + netplay_load_savestate(netplay, NULL, true); + } + break; + default: + case RARCH_NETPLAY_CTL_NONE: + ret = false; + } + +done: + in_netplay = false; + return ret; +} diff --git a/network/netplay/netplay_handshake.c b/network/netplay/netplay_handshake.c index d77656aa4c..e6494ecad1 100644 --- a/network/netplay/netplay_handshake.c +++ b/network/netplay/netplay_handshake.c @@ -94,11 +94,15 @@ void netplay_log_connection(const struct sockaddr_storage *their_addr, } if (str) + { snprintf(s, len, msg_hash_to_str(MSG_GOT_CONNECTION_FROM_NAME), nick, str); + } else + { snprintf(s, len, msg_hash_to_str(MSG_GOT_CONNECTION_FROM), nick); + } } #else @@ -195,12 +199,11 @@ static uint32_t simple_rand_uint32(void) * Initialize our handshake and send the first part of the handshake protocol. */ bool netplay_handshake_init_send(netplay_t *netplay, - struct netplay_connection *connection, - const char *netplay_password, - const char *netplay_spectate_password) + struct netplay_connection *connection) { uint32_t header[6]; - unsigned conn_salt = 0; + unsigned conn_salt = 0; + settings_t *settings = config_get_ptr(); header[0] = htonl(netplay_magic); header[1] = htonl(netplay_platform_magic()); @@ -210,8 +213,8 @@ bool netplay_handshake_init_send(netplay_t *netplay, header[5] = htonl(netplay_impl_magic()); if (netplay->is_server && - (netplay_password[0] || - netplay_spectate_password[0])) + (settings->paths.netplay_password[0] || + settings->paths.netplay_spectate_password[0])) { /* Demand a password */ if (simple_rand_next == 1) @@ -493,7 +496,7 @@ static void netplay_handshake_ready(netplay_t *netplay, * * Send an INFO command. */ -static bool netplay_handshake_info(netplay_t *netplay, +bool netplay_handshake_info(netplay_t *netplay, struct netplay_connection *connection) { struct info_buf_s info_buf; @@ -542,7 +545,7 @@ static bool netplay_handshake_info(netplay_t *netplay, * * Send a SYNC command. */ -static bool netplay_handshake_sync(netplay_t *netplay, +bool netplay_handshake_sync(netplay_t *netplay, struct netplay_connection *connection) { /* If we're the server, now we send sync info */ @@ -687,11 +690,8 @@ static bool netplay_handshake_sync(netplay_t *netplay, * Data receiver for the second stage of handshake, receiving the other side's * nickname. */ -static bool netplay_handshake_pre_nick(netplay_t *netplay, - struct netplay_connection *connection, bool *had_input, - const char *netplay_password, - const char *netplay_spectate_password - ) +bool netplay_handshake_pre_nick(netplay_t *netplay, + struct netplay_connection *connection, bool *had_input) { struct nick_buf_s nick_buf; ssize_t recvd; @@ -724,9 +724,11 @@ static bool netplay_handshake_pre_nick(netplay_t *netplay, if (netplay->is_server) { + settings_t *settings = config_get_ptr(); + /* There's a password, so just put them in PRE_PASSWORD mode */ - if ( netplay_password[0] || - netplay_spectate_password[0]) + if ( settings->paths.netplay_password[0] || + settings->paths.netplay_spectate_password[0]) connection->mode = NETPLAY_CONNECTION_PRE_PASSWORD; else { @@ -751,10 +753,8 @@ static bool netplay_handshake_pre_nick(netplay_t *netplay, * Data receiver for the third, optional stage of server handshake, receiving * the password and sending core/content info. */ -static bool netplay_handshake_pre_password(netplay_t *netplay, - struct netplay_connection *connection, bool *had_input, - const char *netplay_password, - const char *netplay_spectate_password) +bool netplay_handshake_pre_password(netplay_t *netplay, + struct netplay_connection *connection, bool *had_input) { struct password_buf_s password_buf; char password[8+NETPLAY_PASS_LEN]; /* 8 for salt */ @@ -762,6 +762,7 @@ static bool netplay_handshake_pre_password(netplay_t *netplay, ssize_t recvd; char msg[512]; bool correct = false; + settings_t *settings = config_get_ptr(); msg[0] = '\0'; @@ -788,10 +789,10 @@ static bool netplay_handshake_pre_password(netplay_t *netplay, correct = false; snprintf(password, sizeof(password), "%08X", connection->salt); - if (netplay_password[0]) + if (settings->paths.netplay_password[0]) { strlcpy(password + 8, - netplay_password, sizeof(password)-8); + settings->paths.netplay_password, sizeof(password)-8); sha256_hash(hash, (uint8_t *) password, strlen(password)); @@ -801,10 +802,10 @@ static bool netplay_handshake_pre_password(netplay_t *netplay, connection->can_play = true; } } - if (netplay_spectate_password[0]) + if (settings->paths.netplay_spectate_password[0]) { strlcpy(password + 8, - netplay_spectate_password, sizeof(password)-8); + settings->paths.netplay_spectate_password, sizeof(password)-8); sha256_hash(hash, (uint8_t *) password, strlen(password)); @@ -832,7 +833,7 @@ static bool netplay_handshake_pre_password(netplay_t *netplay, * Data receiver for the third stage of server handshake, receiving * the password. */ -static bool netplay_handshake_pre_info(netplay_t *netplay, +bool netplay_handshake_pre_info(netplay_t *netplay, struct netplay_connection *connection, bool *had_input) { struct info_buf_s info_buf; @@ -936,9 +937,8 @@ static bool netplay_handshake_pre_info(netplay_t *netplay, * Data receiver for the client's third handshake stage, receiving the * synchronization information. */ -static bool netplay_handshake_pre_sync(netplay_t *netplay, - struct netplay_connection *connection, bool *had_input, - bool netplay_start_as_spectator) +bool netplay_handshake_pre_sync(netplay_t *netplay, + struct netplay_connection *connection, bool *had_input) { uint32_t cmd[2]; uint32_t new_frame_count, client_num; @@ -1069,8 +1069,7 @@ static bool netplay_handshake_pre_sync(netplay_t *netplay, snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_NETPLAY_CHANGED_NICK), netplay->nick); RARCH_LOG("%s\n", msg); - runloop_msg_queue_push(msg, 1, 180, false, NULL, - MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + runloop_msg_queue_push(msg, 1, 180, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); } /* Now check the SRAM */ @@ -1103,8 +1102,7 @@ static bool netplay_handshake_pre_sync(netplay_t *netplay, uint32_t quickbuf; while (remote_sram_size > 0) { - RECV(&quickbuf, (remote_sram_size > sizeof(uint32_t)) - ? sizeof(uint32_t) : remote_sram_size) + RECV(&quickbuf, (remote_sram_size > sizeof(uint32_t)) ? sizeof(uint32_t) : remote_sram_size) { RARCH_ERR("%s\n", msg_hash_to_str(MSG_FAILED_TO_RECEIVE_SRAM_DATA_FROM_HOST)); @@ -1125,15 +1123,18 @@ static bool netplay_handshake_pre_sync(netplay_t *netplay, #endif /* We're ready! */ - *had_input = true; + *had_input = true; netplay->self_mode = NETPLAY_CONNECTION_SPECTATING; - connection->mode = NETPLAY_CONNECTION_PLAYING; + connection->mode = NETPLAY_CONNECTION_PLAYING; netplay_handshake_ready(netplay, connection); netplay_recv_flush(&connection->recv_packet_buffer); /* Ask to switch to playing mode if we should */ - if (!netplay_start_as_spectator) - return netplay_cmd_mode(netplay, NETPLAY_CONNECTION_PLAYING); + { + settings_t *settings = config_get_ptr(); + if (!settings->bools.netplay_start_as_spectator) + return netplay_cmd_mode(netplay, NETPLAY_CONNECTION_PLAYING); + } return true; } @@ -1146,7 +1147,7 @@ static bool netplay_handshake_pre_sync(netplay_t *netplay, bool netplay_handshake(netplay_t *netplay, struct netplay_connection *connection, bool *had_input) { - bool ret = false; + bool ret = false; switch (connection->mode) { @@ -1154,32 +1155,16 @@ bool netplay_handshake(netplay_t *netplay, ret = netplay_handshake_init(netplay, connection, had_input); break; case NETPLAY_CONNECTION_PRE_NICK: - { - settings_t *settings = config_get_ptr(); - ret = netplay_handshake_pre_nick(netplay, connection, had_input, - settings->paths.netplay_password, - settings->paths.netplay_spectate_password - ); - } + ret = netplay_handshake_pre_nick(netplay, connection, had_input); break; case NETPLAY_CONNECTION_PRE_PASSWORD: - { - settings_t *settings = config_get_ptr(); - ret = netplay_handshake_pre_password(netplay, connection, had_input, - settings->paths.netplay_password, - settings->paths.netplay_spectate_password - ); - } + ret = netplay_handshake_pre_password(netplay, connection, had_input); break; case NETPLAY_CONNECTION_PRE_INFO: ret = netplay_handshake_pre_info(netplay, connection, had_input); break; case NETPLAY_CONNECTION_PRE_SYNC: - { - settings_t *settings = config_get_ptr(); - ret = netplay_handshake_pre_sync(netplay, connection, had_input, - settings->bools.netplay_start_as_spectator); - } + ret = netplay_handshake_pre_sync(netplay, connection, had_input); break; case NETPLAY_CONNECTION_NONE: default: diff --git a/network/netplay/netplay_init.c b/network/netplay/netplay_init.c index 35f3e304ab..3b506097bd 100644 --- a/network/netplay/netplay_init.c +++ b/network/netplay/netplay_init.c @@ -418,8 +418,6 @@ static bool netplay_init_buffers(netplay_t *netplay) netplay_t *netplay_new(void *direct_host, const char *server, uint16_t port, bool stateless_mode, int check_frames, const struct retro_callbacks *cb, bool nat_traversal, const char *nick, - const char *netplay_password, - const char *netplay_spectate_password, uint64_t quirks) { netplay_t *netplay = (netplay_t*)calloc(1, sizeof(*netplay)); @@ -489,9 +487,7 @@ netplay_t *netplay_new(void *direct_host, const char *server, uint16_t port, else { /* Start our handshake */ - netplay_handshake_init_send(netplay, &netplay->connections[0], - netplay_password, - netplay_spectate_password); + netplay_handshake_init_send(netplay, &netplay->connections[0]); netplay->connections[0].mode = NETPLAY_CONNECTION_INIT; netplay->self_mode = NETPLAY_CONNECTION_INIT; diff --git a/network/netplay/netplay_io.c b/network/netplay/netplay_io.c index 6ff14f7f53..526d5cd4e6 100644 --- a/network/netplay/netplay_io.c +++ b/network/netplay/netplay_io.c @@ -730,20 +730,20 @@ static void handle_play_spectate(netplay_t *netplay, uint32_t client_num, case NETPLAY_CMD_PLAY: { uint32_t mode, devices = 0, device; - uint8_t share_mode = 0; - bool slave = false; + uint8_t share_mode; + bool slave = false; settings_t *settings = config_get_ptr(); if (cmd_size != sizeof(uint32_t) || !in_payload) return; - mode = ntohl(in_payload[0]); + mode = ntohl(in_payload[0]); /* Check the requested mode */ - slave = (mode & NETPLAY_CMD_PLAY_BIT_SLAVE)?true:false; - share_mode = (mode>>16) & 0xFF; + slave = (mode&NETPLAY_CMD_PLAY_BIT_SLAVE)?true:false; + share_mode = (mode>>16)&0xFF; /* And the requested devices */ - devices = mode & 0xFFFF; + devices = mode&0xFFFF; /* Check if their slave mode request corresponds with what we allow */ if (connection) @@ -964,8 +964,8 @@ static bool netplay_get_cmd(netplay_t *netplay, return false; RECV(&client_num, sizeof(client_num)) return false; - frame_num = ntohl(frame_num); - client_num = ntohl(client_num); + frame_num = ntohl(frame_num); + client_num = ntohl(client_num); client_num &= 0xFFFF; if (netplay->is_server) @@ -1246,9 +1246,8 @@ static bool netplay_get_cmd(netplay_t *netplay, if (frame < netplay->self_frame_count) netplay->force_rewind = true; - mode = ntohl(payload[1]); + mode = ntohl(payload[1]); client_num = mode & 0xFFFF; - if (client_num >= MAX_CLIENTS) { RARCH_ERR("Received NETPLAY_CMD_MODE for a higher player number than we support.\n"); diff --git a/network/netplay/netplay_private.h b/network/netplay/netplay_private.h index 0413bc0908..df67ef7d71 100644 --- a/network/netplay/netplay_private.h +++ b/network/netplay/netplay_private.h @@ -723,7 +723,7 @@ uint8_t netplay_settings_share_mode(unsigned share_digital, unsigned share_analo * * Poll the network if necessary. */ -void input_poll_net(netplay_t *netplay); +void input_poll_net(void); /*************************************************************** * NETPLAY-HANDSHAKE.C @@ -735,9 +735,7 @@ void input_poll_net(netplay_t *netplay); * Initialize our handshake and send the first part of the handshake protocol. */ bool netplay_handshake_init_send(netplay_t *netplay, - struct netplay_connection *connection, - const char *netplay_password, - const char *netplay_spectate_password); + struct netplay_connection *connection); /** * netplay_handshake @@ -790,8 +788,6 @@ bool netplay_wait_and_init_serialization(netplay_t *netplay); netplay_t *netplay_new(void *direct_host, const char *server, uint16_t port, bool stateless_mode, int check_frames, const struct retro_callbacks *cb, bool nat_traversal, const char *nick, - const char *netplay_password, - const char *netplay_spectate_password, uint64_t quirks); /** @@ -969,10 +965,7 @@ bool netplay_resolve_input(netplay_t *netplay, size_t sim_ptr, bool resim); * * Pre-frame for Netplay synchronization. */ -bool netplay_sync_pre_frame(netplay_t *netplay, - const char *netplay_password, - const char *netplay_spectate_password - ); +bool netplay_sync_pre_frame(netplay_t *netplay); /** * netplay_sync_post_frame diff --git a/network/netplay/netplay_sync.c b/network/netplay/netplay_sync.c index 227ca1da7e..7e3beb9f58 100644 --- a/network/netplay/netplay_sync.c +++ b/network/netplay/netplay_sync.c @@ -551,10 +551,7 @@ static void netplay_handle_frame_hash(netplay_t *netplay, * * Pre-frame for Netplay synchronization. */ -bool netplay_sync_pre_frame(netplay_t *netplay, - const char *netplay_password, - const char *netplay_spectate_password - ) +bool netplay_sync_pre_frame(netplay_t *netplay) { retro_ctx_serialize_info_t serial_info; @@ -729,15 +726,14 @@ bool netplay_sync_pre_frame(netplay_t *netplay, goto process; } - netplay_handshake_init_send(netplay, connection, - netplay_password, netplay_spectate_password); + netplay_handshake_init_send(netplay, connection); } } process: netplay->can_poll = true; - input_poll_net(netplay); + input_poll_net(); return (netplay->stall != NETPLAY_STALL_NO_CONNECTION); } @@ -752,7 +748,6 @@ process: void netplay_sync_post_frame(netplay_t *netplay, bool stalled) { uint32_t lo_frame_count, hi_frame_count; - retro_time_t current_time = cpu_features_get_time_usec(); /* Unless we're stalling, we've just finished running a frame */ if (!stalled) @@ -879,14 +874,15 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled) while (netplay->replay_frame_count < netplay->run_frame_count) { - retro_time_t tm; + retro_time_t start, tm; struct delta_frame *ptr = &netplay->buffer[netplay->replay_ptr]; - retro_time_t start = current_time; serial_info.data = ptr->state; serial_info.size = netplay->state_size; serial_info.data_const = NULL; + start = cpu_features_get_time_usec(); + /* Remember the current state */ memset(serial_info.data, 0, serial_info.size); core_serialize(&serial_info); @@ -923,7 +919,7 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled) #endif /* Get our time window */ - tm = current_time - start; + tm = cpu_features_get_time_usec() - start; netplay->frame_run_time_sum -= netplay->frame_run_time[netplay->frame_run_time_ptr]; netplay->frame_run_time[netplay->frame_run_time_ptr] = tm; netplay->frame_run_time_sum += tm; @@ -983,6 +979,7 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled) { if (netplay->self_frame_count + 3 < lo_frame_count) { + retro_time_t cur_time = cpu_features_get_time_usec(); uint32_t cur_behind = lo_frame_count - netplay->self_frame_count; /* We're behind, but we'll only try to catch up if we're actually @@ -990,12 +987,11 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled) if (netplay->catch_up_time == 0) { /* Record our current time to check for catch-up later */ - netplay->catch_up_time = current_time; + netplay->catch_up_time = cur_time; netplay->catch_up_behind = cur_behind; } - else if (current_time - netplay->catch_up_time - > CATCH_UP_CHECK_TIME_USEC) + else if (cur_time - netplay->catch_up_time > CATCH_UP_CHECK_TIME_USEC) { /* Time to check how far behind we are */ if (netplay->catch_up_behind <= cur_behind) @@ -1009,7 +1005,7 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled) else { /* Check again in another period */ - netplay->catch_up_time = current_time; + netplay->catch_up_time = cur_time; netplay->catch_up_behind = cur_behind; } } diff --git a/retroarch.c b/retroarch.c index 99991e3454..f4fc16710c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1276,9 +1276,6 @@ static struct bsv_state bsv_movie_state; /* Forward declarations */ -#ifdef HAVE_NETWORKING -static void netplay_disconnect(netplay_t *netplay); -#endif static void retroarch_core_options_intl_init(const struct retro_core_options_intl *core_options_intl); static void ui_companion_driver_toggle(bool force); @@ -3311,31 +3308,11 @@ static uint64_t runahead_last_frame_count = 0; #if defined(HAVE_NETWORKING) /* NETWORKING GLOBAL VARIABLES */ -/* Used to avoid recursive netplay calls */ -static bool in_netplay = false; - static bool has_set_netplay_mode = false; static bool has_set_netplay_ip_address = false; static bool has_set_netplay_ip_port = false; static bool has_set_netplay_stateless_mode = false; static bool has_set_netplay_check_frames = false; - -/* Only used before init_netplay */ -static bool netplay_enabled = false; -static bool netplay_is_client = false; - -/* Used */ -static bool netplay_is_mitm = false; - -/* Used while Netplay is running */ -static netplay_t *netplay_data = NULL; - -/* Used for deferred netplay initialization */ -static bool netplay_client_deferred = false; -static char server_address_deferred[512] = ""; -static unsigned server_port_deferred = 0; - -#define netplay_driver_ctl_internal(a, b) (in_netplay ? true : netplay_driver_ctl(a, b)) #endif /* INPUT REMOTE GLOBAL VARIABLES */ @@ -4026,1507 +4003,6 @@ static const struct cmd_map map[] = { }; #endif -#ifdef HAVE_NETWORKING -static bool netplay_is_alive(netplay_t *netplay) -{ - if (!netplay) - return false; - return (netplay->is_server) || - (!netplay->is_server && netplay->self_mode >= NETPLAY_CONNECTION_CONNECTED); -} - -/** - * If we're fast-forward replaying to resync, check if we - * should actually show frame. - */ -static bool netplay_should_skip(netplay_t *netplay) -{ - return netplay->is_replay && (netplay->self_mode >= NETPLAY_CONNECTION_CONNECTED); -} - -static bool netplay_get_self_input_state(netplay_t *netplay) -{ - unsigned i; - struct delta_frame *ptr = &netplay->buffer[netplay->self_ptr]; - netplay_input_state_t istate = NULL; - uint32_t devices, used_devices = 0, devi, dev_type, local_device; - - if (!netplay_delta_frame_ready(netplay, ptr, netplay->self_frame_count)) - return false; - - /* We've already read this frame! */ - if (ptr->have_local) - return true; - - devices = netplay->self_devices; - used_devices = 0; - - for (devi = 0; devi < MAX_INPUT_DEVICES; devi++) - { - if (!(devices & (1<config_devices[devi]&RETRO_DEVICE_MASK; - - for (local_device = 0; local_device < MAX_INPUT_DEVICES; local_device++) - { - if (used_devices & (1<config_devices[local_device] & RETRO_DEVICE_MASK) - == dev_type) - break; - } - - if (local_device == MAX_INPUT_DEVICES) - local_device = 0; - used_devices |= (1<real_input[devi], - /* If we're a slave, we write our own input to - * MAX_CLIENTS to keep it separate */ - (netplay->self_mode==NETPLAY_CONNECTION_SLAVE) - ? MAX_CLIENTS - : netplay->self_client_num, - netplay_expected_input_size(netplay, 1 << devi), - true, false); - if (!istate) - continue; /* FIXME: More severe? */ - - /* First frame we always give zero input since relying on - * input from first frame screws up when we use -F 0. */ - if ( !input_driver_is_libretro_input_blocked() - && netplay->self_frame_count > 0) - { - uint32_t *state = istate->data; - retro_input_state_t cb = netplay->cbs.state_cb; - unsigned dtype = netplay->config_devices[devi] & - RETRO_DEVICE_MASK; - - switch (dtype) - { - case RETRO_DEVICE_ANALOG: - for (i = 0; i < 2; i++) - { - int16_t tmp_x = cb(local_device, - RETRO_DEVICE_ANALOG, (unsigned)i, 0); - int16_t tmp_y = cb(local_device, - RETRO_DEVICE_ANALOG, (unsigned)i, 1); - state[1 + i] = (uint16_t)tmp_x | (((uint16_t)tmp_y) << 16); - } - /* no break */ - - case RETRO_DEVICE_JOYPAD: - for (i = 0; i <= RETRO_DEVICE_ID_JOYPAD_R3; i++) - { - int16_t tmp = cb(local_device, - RETRO_DEVICE_JOYPAD, 0, (unsigned)i); - state[0] |= tmp ? 1 << i : 0; - } - break; - - case RETRO_DEVICE_MOUSE: - case RETRO_DEVICE_LIGHTGUN: - { - int16_t tmp_x = cb(local_device, dtype, 0, 0); - int16_t tmp_y = cb(local_device, dtype, 0, 1); - state[1] = (uint16_t)tmp_x | (((uint16_t)tmp_y) << 16); - for (i = 2; - i <= (unsigned)((dtype == RETRO_DEVICE_MOUSE) ? - RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN : - RETRO_DEVICE_ID_LIGHTGUN_START); - i++) - { - int16_t tmp = cb(local_device, dtype, 0, - (unsigned) i); - state[0] |= tmp ? 1 << i : 0; - } - break; - } - - case RETRO_DEVICE_KEYBOARD: - { - unsigned key, word = 0, bit = 1; - for (key = 1; key < NETPLAY_KEY_LAST; key++) - { - state[word] |= - cb(local_device, RETRO_DEVICE_KEYBOARD, - 0, netplay_key_ntoh(key)) ? - (1U << bit) : 0; - bit++; - if (bit >= 32) - { - bit = 0; - word++; - if (word >= istate->size) - break; - } - } - break; - } - } - } - } - - ptr->have_local = true; - if (netplay->self_mode == NETPLAY_CONNECTION_PLAYING) - { - ptr->have_real[netplay->self_client_num] = true; - netplay->read_ptr[netplay->self_client_num] = - NEXT_PTR(netplay->self_ptr); - netplay->read_frame_count[netplay->self_client_num] = - netplay->self_frame_count + 1; - } - - /* And send this input to our peers */ - for (i = 0; i < netplay->connections_size; i++) - { - struct netplay_connection *connection = &netplay->connections[i]; - if ( connection->active && - connection->mode >= NETPLAY_CONNECTION_CONNECTED) - netplay_send_cur_input(netplay, &netplay->connections[i]); - } - - /* Handle any delayed state changes */ - if (netplay->is_server) - netplay_delayed_state_change(netplay); - - return true; -} - -static bool init_netplay_deferred(const char* server, unsigned port) -{ - if (!string_is_empty(server) && port != 0) - { - strlcpy(server_address_deferred, server, - sizeof(server_address_deferred)); - server_port_deferred = port; - netplay_client_deferred = true; - } - else - netplay_client_deferred = false; - return netplay_client_deferred; -} - -static void netplay_poll(netplay_t *netplay) -{ - size_t i; - uint32_t client; - bool blocking = false; - retro_time_t current_time = cpu_features_get_time_usec(); - - /* Grab our own input state and send this frame's input state - * (self and remote) over the network */ - if (!netplay_get_self_input_state(netplay)) - goto catastrophe; - - /* If we're not connected, we're done */ - if (netplay->self_mode == NETPLAY_CONNECTION_NONE) - return; - - /* Read Netplay input, block if we're configured - * to stall for input every frame */ - netplay_update_unread_ptr(netplay); - - blocking = netplay->stateless_mode && - (netplay->connected_players>1) && - netplay->unread_frame_count <= netplay->run_frame_count; - - if (netplay_poll_net_input(netplay, blocking) == -1) - goto catastrophe; - - /* Resolve and/or simulate the input if we don't have real input */ - netplay_resolve_input(netplay, netplay->run_ptr, false); - - /* Handle any slaves */ - if (netplay->is_server && netplay->connected_slaves) - netplay_handle_slaves(netplay); - - netplay_update_unread_ptr(netplay); - - /* Figure out how many frames of input latency we should be using to hide - * network latency */ - if (netplay->frame_run_time_avg || netplay->stateless_mode) - { - /* FIXME: Using fixed 60fps for this calculation */ - unsigned frames_per_frame = netplay->frame_run_time_avg ? - (16666 / netplay->frame_run_time_avg) : - 0; - unsigned frames_ahead = (netplay->run_frame_count > netplay->unread_frame_count) ? - (netplay->run_frame_count - netplay->unread_frame_count) : - 0; - settings_t *settings = configuration_settings; - unsigned netplay_frames_min = settings->uints.netplay_input_latency_frames_min; - unsigned netplay_frames_range = settings->uints.netplay_input_latency_frames_range; - bool runahead_enabled = settings->bools.run_ahead_enabled; - unsigned runahead_frames = settings->uints.run_ahead_frames; - int input_latency_frames_min = netplay_frames_min - - (runahead_enabled ? runahead_frames : 0); - int input_latency_frames_max = input_latency_frames_min + netplay_frames_range; - - /* Assume we need a couple frames worth of time to actually run the - * current frame */ - if (frames_per_frame > 2) - frames_per_frame -= 2; - else - frames_per_frame = 0; - - /* Shall we adjust our latency? */ - if (netplay->stateless_mode) - { - /* In stateless mode, we adjust up if we're "close" and down if we - * have a lot of slack */ - if (netplay->input_latency_frames < input_latency_frames_min || - (netplay->unread_frame_count == netplay->run_frame_count + 1 && - netplay->input_latency_frames < input_latency_frames_max)) - netplay->input_latency_frames++; - else if (netplay->input_latency_frames > input_latency_frames_max || - (netplay->unread_frame_count > netplay->run_frame_count + 2 && - netplay->input_latency_frames > input_latency_frames_min)) - netplay->input_latency_frames--; - } - else if (netplay->input_latency_frames < input_latency_frames_min || - (frames_per_frame < frames_ahead && - netplay->input_latency_frames < input_latency_frames_max)) - { - /* We can't hide this much network latency with replay, so hide some - * with input latency */ - netplay->input_latency_frames++; - } - else if (netplay->input_latency_frames > input_latency_frames_max || - (frames_per_frame > frames_ahead + 2 && - netplay->input_latency_frames > input_latency_frames_min)) - { - /* We don't need this much latency (any more) */ - netplay->input_latency_frames--; - } - } - - /* If we're stalled, consider unstalling */ - switch (netplay->stall) - { - case NETPLAY_STALL_RUNNING_FAST: - { - if (netplay->unread_frame_count + NETPLAY_MAX_STALL_FRAMES - 2 - > netplay->self_frame_count) - { - netplay->stall = NETPLAY_STALL_NONE; - for (i = 0; i < netplay->connections_size; i++) - { - struct netplay_connection *connection = &netplay->connections[i]; - if (connection->active && connection->stall) - connection->stall = NETPLAY_STALL_NONE; - } - } - break; - } - - case NETPLAY_STALL_SPECTATOR_WAIT: - if (netplay->self_mode == NETPLAY_CONNECTION_PLAYING || netplay->unread_frame_count > netplay->self_frame_count) - netplay->stall = NETPLAY_STALL_NONE; - break; - - case NETPLAY_STALL_INPUT_LATENCY: - /* Just let it recalculate momentarily */ - netplay->stall = NETPLAY_STALL_NONE; - break; - - case NETPLAY_STALL_SERVER_REQUESTED: - /* See if the stall is done */ - if (netplay->connections[0].stall_frame == 0) - { - /* Stop stalling! */ - netplay->connections[0].stall = NETPLAY_STALL_NONE; - netplay->stall = NETPLAY_STALL_NONE; - } - else - netplay->connections[0].stall_frame--; - break; - case NETPLAY_STALL_NO_CONNECTION: - default: /* not stalling */ - break; - } - - /* If we're not stalled, consider stalling */ - if (!netplay->stall) - { - /* Have we not read enough latency frames? */ - if (netplay->self_mode == NETPLAY_CONNECTION_PLAYING && - netplay->connected_players && - netplay->run_frame_count + netplay->input_latency_frames > netplay->self_frame_count) - { - netplay->stall = NETPLAY_STALL_INPUT_LATENCY; - netplay->stall_time = 0; - } - - /* Are we too far ahead? */ - if (netplay->unread_frame_count + NETPLAY_MAX_STALL_FRAMES - <= netplay->self_frame_count) - { - netplay->stall = NETPLAY_STALL_RUNNING_FAST; - netplay->stall_time = current_time; - - /* Figure out who to blame */ - if (netplay->is_server) - { - for (client = 1; client < MAX_CLIENTS; client++) - { - struct netplay_connection *connection; - if (!(netplay->connected_players & (1<read_frame_count[client] > - netplay->unread_frame_count) - continue; - connection = &netplay->connections[client-1]; - if (connection->active && - connection->mode == NETPLAY_CONNECTION_PLAYING) - { - connection->stall = NETPLAY_STALL_RUNNING_FAST; - connection->stall_time = netplay->stall_time; - } - } - } - - } - - /* If we're a spectator, are we ahead at all? */ - if (!netplay->is_server && - (netplay->self_mode == NETPLAY_CONNECTION_SPECTATING || - netplay->self_mode == NETPLAY_CONNECTION_SLAVE) && - netplay->unread_frame_count <= netplay->self_frame_count) - { - netplay->stall = NETPLAY_STALL_SPECTATOR_WAIT; - netplay->stall_time = current_time; - } - } - - /* If we're stalling, consider disconnection */ - if (netplay->stall && netplay->stall_time) - { - retro_time_t now = current_time; - - /* Don't stall out while they're paused */ - if (netplay->remote_paused) - netplay->stall_time = now; - else if ( - now - netplay->stall_time >= - (netplay->is_server - ? MAX_SERVER_STALL_TIME_USEC - : MAX_CLIENT_STALL_TIME_USEC) - ) - { - /* Stalled out! */ - if (!netplay->is_server) - goto catastrophe; - - { - bool fixed = false; - for (i = 0; i < netplay->connections_size; i++) - { - struct netplay_connection *connection = &netplay->connections[i]; - if (connection->active && - connection->mode == NETPLAY_CONNECTION_PLAYING && - connection->stall) - { - netplay_hangup(netplay, connection); - fixed = true; - } - } - - if (fixed) - { - /* Not stalled now */ - netplay->stall = NETPLAY_STALL_NONE; - return; - } - } - } - } - - return; - -catastrophe: - for (i = 0; i < netplay->connections_size; i++) - netplay_hangup(netplay, &netplay->connections[i]); -} - -/* Poll the network if necessary */ -void input_poll_net(netplay_t *netplay) -{ - if (!netplay_should_skip(netplay) && netplay->can_poll) - { - netplay->can_poll = false; - - /* Polls network to see if we have anything new. If our - * network buffer is full, we simply have to block - * for new input data. - */ - netplay_poll(netplay); - } -} - -/* Netplay polling callbacks */ -static void video_frame_net(const void *data, unsigned width, - unsigned height, size_t pitch) -{ - netplay_t *netplay = netplay_data; - if (!netplay_should_skip(netplay)) - netplay->cbs.frame_cb(data, width, height, pitch); -} - -static void audio_sample_net(int16_t left, int16_t right) -{ - netplay_t *netplay = netplay_data; - if (!netplay_should_skip(netplay) && !netplay->stall) - netplay->cbs.sample_cb(left, right); -} - -static size_t audio_sample_batch_net(const int16_t *data, size_t frames) -{ - netplay_t *netplay = netplay_data; - if (!netplay_should_skip(netplay) && !netplay->stall) - return netplay->cbs.sample_batch_cb(data, frames); - return frames; -} - -static int16_t netplay_input_state(netplay_t *netplay, - unsigned port, unsigned device, - unsigned idx, unsigned id) -{ - netplay_input_state_t istate; - struct delta_frame *delta = NULL; - const uint32_t *curr_input_state = NULL; - size_t ptr = netplay->is_replay - ? netplay->replay_ptr - : netplay->run_ptr; - - if (port >= MAX_INPUT_DEVICES) - return 0; - - /* If the port doesn't seem to correspond to the device, "correct" it. This - * is common with devices that typically only have one instance, such as - * keyboards, mice and lightguns. */ - if (device != RETRO_DEVICE_JOYPAD && - (netplay->config_devices[port]&RETRO_DEVICE_MASK) != device) - { - for (port = 0; port < MAX_INPUT_DEVICES; port++) - { - if ((netplay->config_devices[port]&RETRO_DEVICE_MASK) == device) - break; - } - if (port == MAX_INPUT_DEVICES) - return 0; - } - - delta = &netplay->buffer[ptr]; - istate = delta->resolved_input[port]; - if (!istate || !istate->used || istate->size == 0) - return 0; - - curr_input_state = istate->data; - - switch (device) - { - case RETRO_DEVICE_JOYPAD: - if (id == RETRO_DEVICE_ID_JOYPAD_MASK) - return curr_input_state[0]; - return ((1 << id) & curr_input_state[0]) ? 1 : 0; - case RETRO_DEVICE_ANALOG: - if (istate->size == 3) - { - uint32_t state = curr_input_state[1 + idx]; - return (int16_t)(uint16_t)(state >> (id * 16)); - } - break; - case RETRO_DEVICE_MOUSE: - case RETRO_DEVICE_LIGHTGUN: - if (istate->size == 2) - { - if (id <= RETRO_DEVICE_ID_MOUSE_Y) - return (int16_t)(uint16_t)(curr_input_state[1] >> (id * 16)); - return ((1 << id) & curr_input_state[0]) ? 1 : 0; - } - break; - case RETRO_DEVICE_KEYBOARD: - { - unsigned key = netplay_key_hton(id); - if (key != NETPLAY_KEY_UNKNOWN) - { - unsigned word = key / 32; - unsigned bit = key % 32; - if (word <= istate->size) - return ((1U<len == 0) - { - free(task_data); - return; - } - - buf = (char*)calloc(1, data->len + 1); - - memcpy(buf, data->data, data->len); - - lines = string_split(buf, "\n"); - - if (lines->size == 0) - { - string_list_free(lines); - free(buf); - free(task_data); - return; - } - - memset(host_room, 0, sizeof(*host_room)); - - for (i = 0; i < lines->size; i++) - { - const char *line = lines->elems[i].data; - - if (!string_is_empty(line)) - { - struct string_list - *kv = string_split(line, "="); - const char *key = NULL; - const char *val = NULL; - - if (!kv) - continue; - - if (kv->size != 2) - { - string_list_free(kv); - continue; - } - - key = kv->elems[0].data; - val = kv->elems[1].data; - - if (string_is_equal(key, "id")) - sscanf(val, "%i", &host_room->id); - if (string_is_equal(key, "username")) - strlcpy(host_room->nickname, val, - sizeof(host_room->nickname)); - if (string_is_equal(key, "ip")) - strlcpy(host_room->address, val, - sizeof(host_room->address)); - if (string_is_equal(key, "mitm_ip")) - { - mitm_ip = strdup(val); - strlcpy(host_room->mitm_address, val, - sizeof(host_room->mitm_address)); - } - if (string_is_equal(key, "port")) - sscanf(val, "%i", &host_room->port); - if (string_is_equal(key, "mitm_port")) - { - mitm_port = strdup(val); - sscanf(mitm_port, "%i", &host_room->mitm_port); - } - if (string_is_equal(key, "core_name")) - strlcpy(host_room->corename, val, - sizeof(host_room->corename)); - if (string_is_equal(key, "frontend")) - strlcpy(host_room->frontend, val, - sizeof(host_room->frontend)); - if (string_is_equal(key, "core_version")) - strlcpy(host_room->coreversion, val, - sizeof(host_room->coreversion)); - if (string_is_equal(key, "game_name")) - strlcpy(host_room->gamename, val, - sizeof(host_room->gamename)); - if (string_is_equal(key, "game_crc")) - sscanf(val, "%08d", &host_room->gamecrc); - if (string_is_equal(key, "host_method")) - sscanf(val, "%i", &host_room->host_method); - if (string_is_equal(key, "has_password")) - { - if ( string_is_equal_noncase(val, "true") - || string_is_equal(val, "1")) - host_room->has_password = true; - else - host_room->has_password = false; - } - if (string_is_equal(key, "has_spectate_password")) - { - if ( string_is_equal_noncase(val, "true") || - string_is_equal(val, "1")) - host_room->has_spectate_password = true; - else - host_room->has_spectate_password = false; - } - if (string_is_equal(key, "fixed")) - { - if ( string_is_equal_noncase(val, "true") - || string_is_equal(val, "1")) - host_room->fixed = true; - else - host_room->fixed = false; - } - if (string_is_equal(key, "retroarch_version")) - strlcpy(host_room->retroarch_version, - val, sizeof(host_room->retroarch_version)); - if (string_is_equal(key, "country")) - strlcpy(host_room->country, - val, sizeof(host_room->country)); - - string_list_free(kv); - } - } - - if (mitm_ip && mitm_port) - { - ip_len = (unsigned)strlen(mitm_ip); - port_len = (unsigned)strlen(mitm_port); - - /* Enable Netplay client mode */ - if (netplay_driver_ctl_internal(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) - { - command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); - netplay_is_mitm = true; - host_room->host_method = NETPLAY_HOST_METHOD_MITM; - } - - if (!in_netplay) - netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL); - - host_string = (char*)calloc(1, ip_len + port_len + 2); - - memcpy(host_string, mitm_ip, ip_len); - memcpy(host_string + ip_len, "|", 1); - memcpy(host_string + ip_len + 1, mitm_port, port_len); - - /* Enable Netplay */ - command_event(CMD_EVENT_NETPLAY_INIT_DIRECT_DEFERRED, - (void*)host_string); - command_event(CMD_EVENT_NETPLAY_INIT, (void*)host_string); - - free(host_string); - } - -#ifdef HAVE_DISCORD - if (discord_is_inited) - { - discord_userdata_t userdata; - userdata.status = DISCORD_PRESENCE_NETPLAY_HOSTING; - command_event(CMD_EVENT_DISCORD_UPDATE, &userdata); - } -#endif - - string_list_free(lines); - free(buf); - free(task_data); - if (mitm_ip) - free(mitm_ip); - if (mitm_port) - free(mitm_port); - } -} - -static void netplay_announce(void) -{ - char buf[4600]; - char frontend_architecture[PATH_MAX_LENGTH]; - char frontend_architecture_tmp[PATH_MAX_LENGTH]; - const frontend_ctx_driver_t *frontend_drv = NULL; - char url[2048] = "http://lobby.libretro.com/add/"; - char *username = NULL; - char *corename = NULL; - char *gamename = NULL; - char *subsystemname = NULL; - char *coreversion = NULL; - char *frontend_ident = NULL; - settings_t *settings = configuration_settings; - struct retro_system_info *system = &runloop_system.info; - uint32_t content_crc = content_get_crc(); - struct string_list *subsystem = path_get_subsystem_list(); - - buf[0] = '\0'; - - if (subsystem) - { - unsigned i; - - for (i = 0; i < subsystem->size; i++) - { - strlcat(buf, path_basename(subsystem->elems[i].data), sizeof(buf)); - if (i < subsystem->size - 1) - strlcat(buf, "|", sizeof(buf)); - } - net_http_urlencode(&gamename, buf); - net_http_urlencode(&subsystemname, path_get(RARCH_PATH_SUBSYSTEM)); - content_crc = 0; - } - else - { - net_http_urlencode(&gamename, - !string_is_empty(path_basename(path_get(RARCH_PATH_BASENAME))) ? - path_basename(path_get(RARCH_PATH_BASENAME)) : "N/A"); - net_http_urlencode(&subsystemname, "N/A"); - } - - frontend_drv = - (const frontend_ctx_driver_t*)frontend_driver_get_cpu_architecture_str( - frontend_architecture_tmp, sizeof(frontend_architecture_tmp)); - snprintf(frontend_architecture, sizeof(frontend_architecture), "%s %s", - frontend_drv->ident, frontend_architecture_tmp); - -#ifdef HAVE_DISCORD - if (discord_is_ready()) - net_http_urlencode(&username, discord_get_own_username()); - else -#endif - net_http_urlencode(&username, settings->paths.username); - net_http_urlencode(&corename, system->library_name); - net_http_urlencode(&coreversion, system->library_version); - net_http_urlencode(&frontend_ident, frontend_architecture); - - buf[0] = '\0'; - - snprintf(buf, sizeof(buf), "username=%s&core_name=%s&core_version=%s&" - "game_name=%s&game_crc=%08X&port=%d&mitm_server=%s" - "&has_password=%d&has_spectate_password=%d&force_mitm=%d" - "&retroarch_version=%s&frontend=%s&subsystem_name=%s", - username, corename, coreversion, gamename, content_crc, - settings->uints.netplay_port, - settings->arrays.netplay_mitm_server, - *settings->paths.netplay_password ? 1 : 0, - *settings->paths.netplay_spectate_password ? 1 : 0, - settings->bools.netplay_use_mitm_server, - PACKAGE_VERSION, frontend_architecture, subsystemname); - task_push_http_post_transfer(url, buf, true, NULL, - netplay_announce_cb, NULL); - - if (username) - free(username); - if (corename) - free(corename); - if (gamename) - free(gamename); - if (coreversion) - free(coreversion); - if (frontend_ident) - free(frontend_ident); -} - -static int16_t input_state_net(unsigned port, unsigned device, - unsigned idx, unsigned id) -{ - netplay_t *netplay = netplay_data; - /* Check if input port/index is controlled by netplay or not. */ - if (netplay_is_alive(netplay)) - return netplay_input_state(netplay, port, device, idx, id); - return netplay->cbs.state_cb(port, device, idx, id); -} - -/* Inform Netplay of the frontend's pause state (paused or otherwise) */ -static void netplay_frontend_paused(netplay_t *netplay, bool paused) -{ - size_t i; - uint32_t paused_ct = 0; - - /* Nothing to do if we already knew this */ - if (netplay->local_paused == paused) - return; - - netplay->local_paused = paused; - - /* Communicating this is a bit odd: If exactly one other connection is - * paused, then we must tell them that we're unpaused, as from their - * perspective we are. If more than one other connection is paused, then our - * status as proxy means we are NOT unpaused to either of them. */ - for (i = 0; i < netplay->connections_size; i++) - { - struct netplay_connection *connection = &netplay->connections[i]; - if (connection->active && connection->paused) - paused_ct++; - } - if (paused_ct > 1) - return; - - /* Send our unpaused status. Must send manually - * because we must immediately flush the buffer: - * If we're paused, we won't be polled. */ - for (i = 0; i < netplay->connections_size; i++) - { - struct netplay_connection *connection = &netplay->connections[i]; - if ( connection->active && - connection->mode >= NETPLAY_CONNECTION_CONNECTED) - { - if (paused) - netplay_send_raw_cmd(netplay, connection, NETPLAY_CMD_PAUSE, - netplay->nick, NETPLAY_NICK_LEN); - else - netplay_send_raw_cmd(netplay, connection, NETPLAY_CMD_RESUME, - NULL, 0); - - /* We're not going to be polled, so we need - * to flush this command now */ - netplay_send_flush(&connection->send_packet_buffer, - connection->fd, true); - } - } -} - -static bool netplay_pre_frame(netplay_t *netplay) -{ - static int reannounce = 0; - bool sync_stalled = false; - settings_t *settings = configuration_settings; - bool netplay_public_announce = settings->bools.netplay_public_announce; - bool netplay_use_mitm_server = settings->bools.netplay_use_mitm_server; - const char *netplay_password = settings->paths.netplay_password; - const char *netplay_spectate_pw = settings->paths.netplay_spectate_password; - - retro_assert(netplay); - - if (netplay_public_announce) - { - reannounce++; - if ((netplay->is_server || netplay_is_mitm) && (reannounce % 600 == 0)) - netplay_announce(); - } - /* Make sure that if announcement is turned on mid-game, it gets announced */ - else - reannounce = -1; - - /* FIXME: This is an ugly way to learn we're not paused anymore */ - if (netplay->local_paused) - netplay_frontend_paused(netplay, false); - - /* Are we ready now? */ - if (netplay->quirks & NETPLAY_QUIRK_INITIALIZATION) - netplay_try_init_serialization(netplay); - - if (netplay->is_server && !netplay_use_mitm_server) - { - /* Advertise our server */ - netplay_lan_ad_server(netplay); - - /* NAT traversal if applicable */ - if (netplay->nat_traversal && - !netplay->nat_traversal_task_oustanding && - netplay->nat_traversal_state.request_outstanding && - !netplay->nat_traversal_state.have_inet4) - { - struct timeval tmptv = {0}; - fd_set fds = netplay->nat_traversal_state.fds; - if (socket_select(netplay->nat_traversal_state.nfds, - &fds, NULL, NULL, &tmptv) > 0) - natt_read(&netplay->nat_traversal_state); - -#ifndef HAVE_SOCKET_LEGACY - if (!netplay->nat_traversal_state.request_outstanding || - netplay->nat_traversal_state.have_inet4) - netplay_announce_nat_traversal(netplay); -#endif - } - } - - sync_stalled = !netplay_sync_pre_frame(netplay, - netplay_password, - netplay_spectate_pw - ); - - /* If we're disconnected, deinitialize */ - if (!netplay->is_server && !netplay->connections[0].active) - { - netplay_disconnect(netplay); - return true; - } - - if (sync_stalled || - ((!netplay->is_server || (netplay->connected_players>1)) && - (netplay->stall || netplay->remote_paused))) - { - /* We may have received data even if we're stalled, - * so run post-frame sync */ - netplay_sync_post_frame(netplay, true); - return false; - } - return true; -} - -static void netplay_post_frame(netplay_t *netplay) -{ - size_t i; - retro_assert(netplay); - netplay_update_unread_ptr(netplay); - netplay_sync_post_frame(netplay, false); - - for (i = 0; i < netplay->connections_size; i++) - { - struct netplay_connection *connection = &netplay->connections[i]; - if (connection->active && - !netplay_send_flush(&connection->send_packet_buffer, - connection->fd, false)) - netplay_hangup(netplay, connection); - } - - /* If we're disconnected, deinitialize */ - if (!netplay->is_server && !netplay->connections[0].active) - netplay_disconnect(netplay); -} - -/** - * netplay_force_future - * @netplay : pointer to netplay object - * - * Force netplay to ignore all past input, typically because - * we've just loaded a state or reset. - */ -static void netplay_force_future(netplay_t *netplay) -{ - /* Wherever we're inputting, that's where we consider our - * state to be loaded */ - netplay->run_ptr = netplay->self_ptr; - netplay->run_frame_count = netplay->self_frame_count; - - /* We need to ignore any intervening data from the other side, - * and never rewind past this */ - netplay_update_unread_ptr(netplay); - - if (netplay->unread_frame_count < netplay->run_frame_count) - { - uint32_t client; - for (client = 0; client < MAX_CLIENTS; client++) - { - if (!(netplay->connected_players & (1<read_frame_count[client] < netplay->run_frame_count) - { - netplay->read_ptr[client] = netplay->run_ptr; - netplay->read_frame_count[client] = netplay->run_frame_count; - } - } - if (netplay->server_frame_count < netplay->run_frame_count) - { - netplay->server_ptr = netplay->run_ptr; - netplay->server_frame_count = netplay->run_frame_count; - } - netplay_update_unread_ptr(netplay); - } - if (netplay->other_frame_count < netplay->run_frame_count) - { - netplay->other_ptr = netplay->run_ptr; - netplay->other_frame_count = netplay->run_frame_count; - } -} - -static void netplay_send_savestate(netplay_t *netplay, - retro_ctx_serialize_info_t *serial_info, uint32_t cx, - struct compression_transcoder *z) -{ - uint32_t header[4]; - uint32_t rd, wn; - size_t i; - - /* Compress it */ - z->compression_backend->set_in(z->compression_stream, - (const uint8_t*)serial_info->data_const, (uint32_t)serial_info->size); - z->compression_backend->set_out(z->compression_stream, - netplay->zbuffer, (uint32_t)netplay->zbuffer_size); - if (!z->compression_backend->trans(z->compression_stream, true, &rd, - &wn, NULL)) - { - /* Catastrophe! */ - for (i = 0; i < netplay->connections_size; i++) - netplay_hangup(netplay, &netplay->connections[i]); - return; - } - - /* Send it to relevant peers */ - header[0] = htonl(NETPLAY_CMD_LOAD_SAVESTATE); - header[1] = htonl(wn + 2*sizeof(uint32_t)); - header[2] = htonl(netplay->run_frame_count); - header[3] = htonl(serial_info->size); - - for (i = 0; i < netplay->connections_size; i++) - { - struct netplay_connection *connection = &netplay->connections[i]; - if (!connection->active || - connection->mode < NETPLAY_CONNECTION_CONNECTED || - connection->compression_supported != cx) - continue; - - if (!netplay_send(&connection->send_packet_buffer, connection->fd, header, - sizeof(header)) || - !netplay_send(&connection->send_packet_buffer, connection->fd, - netplay->zbuffer, wn)) - netplay_hangup(netplay, connection); - } -} - -/** - * netplay_load_savestate - * @netplay : pointer to netplay object - * @serial_info : the savestate being loaded, NULL means - * "load it yourself" - * @save : Whether to save the provided serial_info - * into the frame buffer - * - * Inform Netplay of a savestate load and send it to the other side - **/ -void netplay_load_savestate(netplay_t *netplay, - retro_ctx_serialize_info_t *serial_info, bool save) -{ - retro_ctx_serialize_info_t tmp_serial_info; - - netplay_force_future(netplay); - - /* Record it in our own buffer */ - if (save || !serial_info) - { - /* FIXME: This is a critical failure! */ - if (!netplay_delta_frame_ready(netplay, - &netplay->buffer[netplay->run_ptr], netplay->run_frame_count)) - return; - - if (!serial_info) - { - tmp_serial_info.size = netplay->state_size; - tmp_serial_info.data = netplay->buffer[netplay->run_ptr].state; - if (!core_serialize(&tmp_serial_info)) - return; - tmp_serial_info.data_const = tmp_serial_info.data; - serial_info = &tmp_serial_info; - } - else - { - if (serial_info->size <= netplay->state_size) - memcpy(netplay->buffer[netplay->run_ptr].state, - serial_info->data_const, serial_info->size); - } - } - - /* Don't send it if we're expected to be desynced */ - if (netplay->desync) - return; - - /* If we can't send it to the peer, loading a state was a bad idea */ - if (netplay->quirks & ( - NETPLAY_QUIRK_NO_SAVESTATES - | NETPLAY_QUIRK_NO_TRANSMISSION)) - return; - - /* Send this to every peer - * - * Send a loaded savestate to those connected peers using the - * given compression scheme. - */ - if (netplay->compress_nil.compression_backend) - netplay_send_savestate(netplay, serial_info, 0, &netplay->compress_nil); - if (netplay->compress_zlib.compression_backend) - netplay_send_savestate(netplay, serial_info, NETPLAY_COMPRESSION_ZLIB, - &netplay->compress_zlib); -} - -static void netplay_core_reset(netplay_t *netplay) -{ - uint32_t cmd[3]; - size_t i; - - /* Ignore past input */ - netplay_force_future(netplay); - - /* Request that our peers reset */ - cmd[0] = htonl(NETPLAY_CMD_RESET); - cmd[1] = htonl(sizeof(uint32_t)); - cmd[2] = htonl(netplay->self_frame_count); - - for (i = 0; i < netplay->connections_size; i++) - { - struct netplay_connection *connection = &netplay->connections[i]; - if (!connection->active || - connection->mode < NETPLAY_CONNECTION_CONNECTED) - continue; - - if (!netplay_send(&connection->send_packet_buffer, connection->fd, cmd, - sizeof(cmd))) - netplay_hangup(netplay, connection); - } -} - -/** - * netplay_settings_share_mode - * - * Get the preferred share mode - */ -uint8_t netplay_settings_share_mode(unsigned share_digital, - unsigned share_analog) -{ - if (share_digital || share_analog) - { - uint8_t share_mode = 0; - - switch (share_digital) - { - case RARCH_NETPLAY_SHARE_DIGITAL_OR: - share_mode |= NETPLAY_SHARE_DIGITAL_OR; - break; - case RARCH_NETPLAY_SHARE_DIGITAL_XOR: - share_mode |= NETPLAY_SHARE_DIGITAL_XOR; - break; - case RARCH_NETPLAY_SHARE_DIGITAL_VOTE: - share_mode |= NETPLAY_SHARE_DIGITAL_VOTE; - break; - default: - share_mode |= NETPLAY_SHARE_NO_PREFERENCE; - } - - switch (share_analog) - { - case RARCH_NETPLAY_SHARE_ANALOG_MAX: - share_mode |= NETPLAY_SHARE_ANALOG_MAX; - break; - case RARCH_NETPLAY_SHARE_ANALOG_AVERAGE: - share_mode |= NETPLAY_SHARE_ANALOG_AVERAGE; - break; - default: - share_mode |= NETPLAY_SHARE_NO_PREFERENCE; - } - - return share_mode; - } - return 0; -} - -/* Toggle between play mode and spectate mode */ -static void netplay_toggle_play_spectate(netplay_t *netplay) -{ - switch (netplay->self_mode) - { - case NETPLAY_CONNECTION_PLAYING: - case NETPLAY_CONNECTION_SLAVE: - /* Switch to spectator mode immediately */ - netplay->self_mode = NETPLAY_CONNECTION_SPECTATING; - netplay_cmd_mode(netplay, NETPLAY_CONNECTION_SPECTATING); - break; - case NETPLAY_CONNECTION_SPECTATING: - /* Switch only after getting permission */ - netplay_cmd_mode(netplay, NETPLAY_CONNECTION_PLAYING); - break; - default: - break; - } -} - -static void netplay_disconnect(netplay_t *netplay) -{ - size_t i; - - for (i = 0; i < netplay->connections_size; i++) - netplay_hangup(netplay, &netplay->connections[i]); - - deinit_netplay(); - -#ifdef HAVE_DISCORD - if (discord_is_inited) - { - discord_userdata_t userdata; - userdata.status = DISCORD_PRESENCE_NETPLAY_NETPLAY_STOPPED; - command_event(CMD_EVENT_DISCORD_UPDATE, &userdata); - } -#endif -} - -void deinit_netplay(void) -{ - if (netplay_data) - { - netplay_free(netplay_data); - netplay_enabled = false; - netplay_is_client = false; - netplay_is_mitm = false; - } - netplay_data = NULL; - core_unset_netplay_callbacks(); -} - -/** - * init_netplay - * @direct_host : Host to connect to directly, if applicable (client only) - * @server : server address to connect to (client only) - * @port : TCP port to host on/connect to - * - * Initializes netplay. - * - * If netplay is already initialized, will return false (0). - * - * Returns: true (1) if successful, otherwise false (0). - **/ -static bool init_netplay(void *direct_host, const char *server, unsigned port) -{ - struct retro_callbacks cbs = {0}; - settings_t *settings = configuration_settings; - uint64_t serialization_quirks = 0; - uint64_t quirks = 0; - bool _netplay_is_client = netplay_is_client; - bool _netplay_enabled = netplay_enabled; - const char *username = settings->paths.username; - bool netplay_public_announce = settings->bools.netplay_public_announce; - bool netplay_start_as_spectator = settings->bools.netplay_start_as_spectator; - bool netplay_stateless_mode = settings->bools.netplay_stateless_mode; - bool netplay_nat_traversal = settings->bools.netplay_nat_traversal; - bool netplay_use_mitm_server = settings->bools.netplay_use_mitm_server; - const char *netplay_password = settings->paths.netplay_password; - const char *netplay_spectate_pw = settings->paths.netplay_spectate_password; - int netplay_check_frames = settings->ints.netplay_check_frames; -#ifdef HAVE_DISCORD - const char *discord_username = discord_get_own_username(); - const char *path_username = discord_username - ? discord_username - : username; -#else - const char *path_username = username; -#endif - - if (!_netplay_enabled) - return false; - - core_set_default_callbacks(&cbs); - if (!core_set_netplay_callbacks()) - return false; - - /* Map the core's quirks to our quirks */ - serialization_quirks = core_serialization_quirks(); - if (serialization_quirks & ~((uint64_t) NETPLAY_QUIRK_MAP_UNDERSTOOD)) - { - /* Quirks we don't support! Just disable everything. */ - quirks |= NETPLAY_QUIRK_NO_SAVESTATES; - } - if (serialization_quirks & NETPLAY_QUIRK_MAP_NO_SAVESTATES) - quirks |= NETPLAY_QUIRK_NO_SAVESTATES; - if (serialization_quirks & NETPLAY_QUIRK_MAP_NO_TRANSMISSION) - quirks |= NETPLAY_QUIRK_NO_TRANSMISSION; - if (serialization_quirks & NETPLAY_QUIRK_MAP_INITIALIZATION) - quirks |= NETPLAY_QUIRK_INITIALIZATION; - if (serialization_quirks & NETPLAY_QUIRK_MAP_ENDIAN_DEPENDENT) - quirks |= NETPLAY_QUIRK_ENDIAN_DEPENDENT; - if (serialization_quirks & NETPLAY_QUIRK_MAP_PLATFORM_DEPENDENT) - quirks |= NETPLAY_QUIRK_PLATFORM_DEPENDENT; - - if (_netplay_is_client) - { - RARCH_LOG("[netplay] %s\n", - msg_hash_to_str(MSG_CONNECTING_TO_NETPLAY_HOST)); - } - else - { - RARCH_LOG("[netplay] %s\n", - msg_hash_to_str(MSG_WAITING_FOR_CLIENT)); - runloop_msg_queue_push( - msg_hash_to_str(MSG_WAITING_FOR_CLIENT), - 0, 180, false, - NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); - - if (netplay_public_announce) - netplay_announce(); - } - - netplay_data = (netplay_t*)netplay_new( - _netplay_is_client ? direct_host : NULL, - _netplay_is_client ? (!netplay_client_deferred ? server - : server_address_deferred) : NULL, - _netplay_is_client ? (!netplay_client_deferred ? port - : server_port_deferred ) - : (port != 0 ? port : RARCH_DEFAULT_PORT), - netplay_stateless_mode, - netplay_check_frames, - &cbs, - netplay_nat_traversal - && !netplay_use_mitm_server, - path_username, - netplay_password, - netplay_spectate_pw, - quirks); - - if (netplay_data) - { - if ( netplay_data->is_server && - !netplay_start_as_spectator) - netplay_toggle_play_spectate(netplay_data); - return true; - } - - RARCH_WARN("%s\n", msg_hash_to_str(MSG_NETPLAY_FAILED)); - - runloop_msg_queue_push( - msg_hash_to_str(MSG_NETPLAY_FAILED), - 0, 180, false, - NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); - return false; -} - -/* Frontend access to Netplay functionality */ -bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data) -{ - bool ret = true; - netplay_t *netplay = netplay_data; - - in_netplay = true; - - switch (state) - { - case RARCH_NETPLAY_CTL_ENABLE_SERVER: - if (!netplay) - { - netplay_enabled = true; - netplay_is_client = false; - } - break; - case RARCH_NETPLAY_CTL_ENABLE_CLIENT: - if (!netplay) - { - netplay_enabled = true; - netplay_is_client = true; - } - break; - case RARCH_NETPLAY_CTL_IS_DATA_INITED: - if (!netplay) - ret = false; - break; - case RARCH_NETPLAY_CTL_IS_ENABLED: - if (!netplay) - ret = netplay_enabled; - break; - case RARCH_NETPLAY_CTL_IS_REPLAYING: - if (netplay) - ret = netplay->is_replay; - else - ret = false; - break; - case RARCH_NETPLAY_CTL_DISABLE: - if (netplay) - ret = false; - else - { - netplay_enabled = false; -#ifdef HAVE_DISCORD - if (discord_is_inited) - { - discord_userdata_t userdata; - userdata.status = DISCORD_PRESENCE_NETPLAY_NETPLAY_STOPPED; - command_event(CMD_EVENT_DISCORD_UPDATE, &userdata); - } -#endif - } - break; - case RARCH_NETPLAY_CTL_IS_CONNECTED: - if (netplay) - ret = netplay->is_connected; - else - ret = false; - break; - case RARCH_NETPLAY_CTL_IS_SERVER: - return netplay_enabled && !netplay_is_client; - case RARCH_NETPLAY_CTL_POST_FRAME: - if (netplay) - { - /* We check if we have new input and replay from recorded input. - * Call this after running retro_run(). - */ - netplay_post_frame(netplay); - } - break; - case RARCH_NETPLAY_CTL_PRE_FRAME: - if (netplay) - { - /* - * Call netplay_pre_frame before running retro_run(). - * - * Returns true if the frontend is cleared to - * render the frame, false if we're stalled or paused - */ - ret = netplay_pre_frame(netplay); - } - break; - case RARCH_NETPLAY_CTL_GAME_WATCH: - if (netplay) - netplay_toggle_play_spectate(netplay); - break; - case RARCH_NETPLAY_CTL_PAUSE: - if (netplay) - netplay_frontend_paused(netplay, true); - break; - case RARCH_NETPLAY_CTL_UNPAUSE: - if (netplay) - netplay_frontend_paused(netplay, false); - break; - case RARCH_NETPLAY_CTL_LOAD_SAVESTATE: - if (netplay) - netplay_load_savestate(netplay, - (retro_ctx_serialize_info_t*)data, true); - break; - case RARCH_NETPLAY_CTL_RESET: - /* Indicate that the core has been reset to netplay peers */ - if (netplay) - netplay_core_reset(netplay); - break; - case RARCH_NETPLAY_CTL_DISCONNECT: - if (netplay) - netplay_disconnect(netplay); - break; - case RARCH_NETPLAY_CTL_FINISHED_NAT_TRAVERSAL: - if (netplay) - { - netplay->nat_traversal_task_oustanding = false; -#ifndef HAVE_SOCKET_LEGACY - netplay_announce_nat_traversal(netplay); -#endif - } - break; - case RARCH_NETPLAY_CTL_DESYNC_PUSH: - if (netplay) - netplay->desync++; - break; - case RARCH_NETPLAY_CTL_DESYNC_POP: - if (netplay && netplay->desync) - { - netplay->desync--; - if (!netplay->desync) - netplay_load_savestate(netplay, NULL, true); - } - break; - case RARCH_NETPLAY_CTL_NONE: - if (netplay) - ret = false; - break; - default: - if (netplay) - ret = false; - break; - } - - in_netplay = false; - return ret; -} -#endif - bool retroarch_apply_shader(enum rarch_shader_type type, const char *preset_path, bool message) { #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) @@ -7484,7 +5960,7 @@ static void command_event_init_cheats(void) bool apply_cheats_after_load = settings->bools.apply_cheats_after_load; const char *path_cheat_db = settings->paths.path_cheat_database; #ifdef HAVE_NETWORKING - allow_cheats &= !netplay_driver_ctl_internal( + allow_cheats &= !netplay_driver_ctl( RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL); #endif allow_cheats &= !(bsv_movie_state_handle != NULL); @@ -7515,7 +5991,7 @@ static void command_event_load_auto_state(void) return; #endif #ifdef HAVE_NETWORKING - if (netplay_driver_ctl_internal(RARCH_NETPLAY_CTL_IS_ENABLED, NULL)) + if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL)) return; #endif @@ -8154,8 +6630,7 @@ static void command_event_undo_load_state(char *s, size_t len) } #ifdef HAVE_NETWORKING - if (!in_netplay) - netplay_driver_ctl(RARCH_NETPLAY_CTL_LOAD_SAVESTATE, NULL); + netplay_driver_ctl(RARCH_NETPLAY_CTL_LOAD_SAVESTATE, NULL); #endif strlcpy(s, @@ -8217,8 +6692,7 @@ static bool command_event_main_state(unsigned cmd) #endif ret = true; #ifdef HAVE_NETWORKING - if (!in_netplay) - netplay_driver_ctl(RARCH_NETPLAY_CTL_LOAD_SAVESTATE, NULL); + netplay_driver_ctl(RARCH_NETPLAY_CTL_LOAD_SAVESTATE, NULL); #endif { settings_t *settings = configuration_settings; @@ -8655,8 +7129,7 @@ bool command_event(enum event_command cmd, void *data) rcheevos_reset_game(); #endif #if HAVE_NETWORKING - if (!in_netplay) - netplay_driver_ctl(RARCH_NETPLAY_CTL_RESET, NULL); + netplay_driver_ctl(RARCH_NETPLAY_CTL_RESET, NULL); #endif return false; case CMD_EVENT_SAVE_STATE: @@ -8811,7 +7284,7 @@ bool command_event(enum event_command cmd, void *data) #ifdef HAVE_NETWORKING /* Only enable state manager if netplay is not underway TODO/FIXME: Add a setting for these tweaks */ - if (!netplay_driver_ctl_internal( + if (!netplay_driver_ctl( RARCH_NETPLAY_CTL_IS_ENABLED, NULL)) #endif { @@ -8842,7 +7315,7 @@ bool command_event(enum event_command cmd, void *data) /* Only enable state manager if netplay is not underway TODO/FIXME: Add a setting for these tweaks */ if ( (autosave_interval != 0) - && !netplay_driver_ctl_internal( + && !netplay_driver_ctl( RARCH_NETPLAY_CTL_IS_ENABLED, NULL)) #endif runloop_autosave = autosave_init(); @@ -9347,8 +7820,7 @@ bool command_event(enum event_command cmd, void *data) break; #ifdef HAVE_NETWORKING case CMD_EVENT_NETPLAY_GAME_WATCH: - if (!in_netplay) - netplay_driver_ctl(RARCH_NETPLAY_CTL_GAME_WATCH, NULL); + netplay_driver_ctl(RARCH_NETPLAY_CTL_GAME_WATCH, NULL); break; case CMD_EVENT_NETPLAY_DEINIT: deinit_netplay(); @@ -9465,10 +7937,9 @@ bool command_event(enum event_command cmd, void *data) content_get_status(&contentless, &is_inited); - if (netplay_driver_ctl_internal(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) + if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); - if (!in_netplay) - netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_SERVER, NULL); + netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_SERVER, NULL); /* If we haven't yet started, this will load on its own */ if (!is_inited) @@ -9488,11 +7959,8 @@ bool command_event(enum event_command cmd, void *data) } case CMD_EVENT_NETPLAY_DISCONNECT: { - if (!in_netplay) - { - netplay_driver_ctl(RARCH_NETPLAY_CTL_DISCONNECT, NULL); - netplay_driver_ctl(RARCH_NETPLAY_CTL_DISABLE, NULL); - } + netplay_driver_ctl(RARCH_NETPLAY_CTL_DISCONNECT, NULL); + netplay_driver_ctl(RARCH_NETPLAY_CTL_DISABLE, NULL); { settings_t *settings = configuration_settings; @@ -9510,12 +7978,12 @@ bool command_event(enum event_command cmd, void *data) break; } case CMD_EVENT_NETPLAY_HOST_TOGGLE: - if (netplay_driver_ctl_internal(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) && - netplay_driver_ctl_internal(RARCH_NETPLAY_CTL_IS_SERVER, NULL)) + if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) && + netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER, NULL)) command_event(CMD_EVENT_NETPLAY_DISCONNECT, NULL); - else if (netplay_driver_ctl_internal(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) && - !netplay_driver_ctl_internal(RARCH_NETPLAY_CTL_IS_SERVER, NULL) && - netplay_driver_ctl_internal(RARCH_NETPLAY_CTL_IS_CONNECTED, NULL)) + else if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) && + !netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER, NULL) && + netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_CONNECTED, NULL)) command_event(CMD_EVENT_NETPLAY_DISCONNECT, NULL); else command_event(CMD_EVENT_NETPLAY_ENABLE_HOST, NULL); @@ -11950,7 +10418,7 @@ static bool rarch_environment_cb(unsigned cmd, void *data) const struct retro_audio_callback *cb = (const struct retro_audio_callback*)data; RARCH_LOG("[Environ]: SET_AUDIO_CALLBACK.\n"); #ifdef HAVE_NETWORKING - if (netplay_driver_ctl_internal(RARCH_NETPLAY_CTL_IS_ENABLED, NULL)) + if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL)) return false; #endif if (recording_data) /* A/V sync is a must. */ @@ -11971,7 +10439,7 @@ static bool rarch_environment_cb(unsigned cmd, void *data) #ifdef HAVE_NETWORKING /* retro_run() will be called in very strange and * mysterious ways, have to disable it. */ - if (netplay_driver_ctl_internal(RARCH_NETPLAY_CTL_IS_ENABLED, NULL)) + if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL)) return false; #endif runloop_frame_time = *info; @@ -12473,9 +10941,9 @@ static bool rarch_environment_cb(unsigned cmd, void *data) result |= 8; #endif #ifdef HAVE_NETWORKING - if (netplay_driver_ctl_internal(RARCH_NETPLAY_CTL_IS_REPLAYING, NULL)) + if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_REPLAYING, NULL)) result &= ~(1|2); - if (netplay_driver_ctl_internal(RARCH_NETPLAY_CTL_IS_ENABLED, NULL)) + if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL)) result |= 4; #endif if (data) @@ -27464,8 +25932,7 @@ static void retroarch_parse_input_and_config(int argc, char *argv[]) case 'H': retroarch_override_setting_set( RARCH_OVERRIDE_SETTING_NETPLAY_MODE, NULL); - if (!in_netplay) - netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_SERVER, NULL); + netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_SERVER, NULL); break; case 'C': @@ -27475,9 +25942,7 @@ static void retroarch_parse_input_and_config(int argc, char *argv[]) RARCH_OVERRIDE_SETTING_NETPLAY_MODE, NULL); retroarch_override_setting_set( RARCH_OVERRIDE_SETTING_NETPLAY_IP_ADDRESS, NULL); - if (!in_netplay) - netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL); - + netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL); configuration_set_string(settings, settings->paths.netplay_server, optarg); } @@ -30413,8 +28878,7 @@ int runloop_iterate(void) case RUNLOOP_STATE_POLLED_AND_SLEEP: #ifdef HAVE_NETWORKING /* FIXME: This is an ugly way to tell Netplay this... */ - if (!in_netplay) - netplay_driver_ctl(RARCH_NETPLAY_CTL_PAUSE, NULL); + netplay_driver_ctl(RARCH_NETPLAY_CTL_PAUSE, NULL); #endif #if defined(HAVE_COCOATOUCH) if (!main_ui_companion_is_on_foreground) @@ -30425,19 +28889,15 @@ int runloop_iterate(void) #ifdef HAVE_NETWORKING /* FIXME: This is an ugly way to tell Netplay this... */ if (settings->bools.menu_pause_libretro && - netplay_driver_ctl_internal(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) + netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) ) - { - if (!in_netplay) - netplay_driver_ctl(RARCH_NETPLAY_CTL_PAUSE, NULL); - } + netplay_driver_ctl(RARCH_NETPLAY_CTL_PAUSE, NULL); #endif goto end; case RUNLOOP_STATE_MENU_ITERATE: #ifdef HAVE_NETWORKING /* FIXME: This is an ugly way to tell Netplay this... */ - if (!in_netplay) - netplay_driver_ctl(RARCH_NETPLAY_CTL_PAUSE, NULL); + netplay_driver_ctl(RARCH_NETPLAY_CTL_PAUSE, NULL); #endif return 0; case RUNLOOP_STATE_ITERATE: @@ -30483,7 +28943,7 @@ int runloop_iterate(void) /* Run Ahead Feature replaces the call to core_run in this loop */ bool want_runahead = settings->bools.run_ahead_enabled && run_ahead_num_frames > 0; #ifdef HAVE_NETWORKING - want_runahead = want_runahead && !netplay_driver_ctl_internal(RARCH_NETPLAY_CTL_IS_ENABLED, NULL); + want_runahead = want_runahead && !netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL); #endif if (want_runahead) @@ -30814,7 +29274,7 @@ static bool core_init_libretro_cbs(struct retro_callbacks *cbs) core_set_default_callbacks(cbs); #ifdef HAVE_NETWORKING - if (!netplay_driver_ctl_internal(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) + if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) return true; core_set_netplay_callbacks(); @@ -30987,8 +29447,7 @@ bool core_unserialize(retro_ctx_serialize_info_t *info) return false; #if HAVE_NETWORKING - if (!in_netplay) - netplay_driver_ctl(RARCH_NETPLAY_CTL_LOAD_SAVESTATE, info); + netplay_driver_ctl(RARCH_NETPLAY_CTL_LOAD_SAVESTATE, info); #endif return true; @@ -31048,7 +29507,7 @@ bool core_run(void) bool early_polling = new_poll_type == POLL_TYPE_EARLY; bool late_polling = new_poll_type == POLL_TYPE_LATE; #ifdef HAVE_NETWORKING - bool netplay_preframe = netplay_driver_ctl_internal( + bool netplay_preframe = netplay_driver_ctl( RARCH_NETPLAY_CTL_PRE_FRAME, NULL); if (!netplay_preframe) @@ -31072,8 +29531,7 @@ bool core_run(void) input_driver_poll(); #ifdef HAVE_NETWORKING - if (!in_netplay) - netplay_driver_ctl(RARCH_NETPLAY_CTL_POST_FRAME, NULL); + netplay_driver_ctl(RARCH_NETPLAY_CTL_POST_FRAME, NULL); #endif return true; From 2f3ef75bf6a1a7133122372aa9e2944fac86197a Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sun, 10 May 2020 01:10:45 +0200 Subject: [PATCH 020/192] Remove some unused variables and some style nits --- menu/menu_displaylist.c | 2 -- retroarch.c | 9 ++------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 09186cb435..e791e14b52 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2896,8 +2896,6 @@ static bool menu_displaylist_parse_playlist_manager_settings( const char *playlist_file = NULL; playlist_t *playlist = NULL; const char *menu_driver = menu_driver_ident(); - settings_t *settings = config_get_ptr(); - bool playlist_use_old_format = settings->bools.playlist_use_old_format; if (string_is_empty(playlist_path)) return false; diff --git a/retroarch.c b/retroarch.c index f4fc16710c..2fb60cd4c9 100644 --- a/retroarch.c +++ b/retroarch.c @@ -4536,7 +4536,6 @@ bool ai_service_speech_stop(void) static void task_auto_translate_handler(retro_task_t *task) { - http_transfer_data_t *data = NULL; int* mode_ptr = (int*)task->user_data; if (task_get_cancelled(task)) @@ -4545,20 +4544,16 @@ static void task_auto_translate_handler(retro_task_t *task) if (*mode_ptr == 2) { #ifdef HAVE_ACCESSIBILITY - if (is_narrator_running() == false) - { + if (!is_narrator_running()) goto task_finished; - } #endif } /* Speech Mode */ else if (*mode_ptr == 1) { #ifdef HAVE_AUDIOMIXER - if (is_ai_service_speech_running() == false) - { + if (!is_ai_service_speech_running()) goto task_finished; - } #endif } return; From 1e9b94ded4103b0320919efbf7ded0347adb1f8b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 10 May 2020 05:05:43 +0200 Subject: [PATCH 021/192] Get rid of hash --- menu/cbs/menu_cbs_ok.c | 10 +++++----- msg_hash.h | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 0417ee9350..b6c157d7af 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -4028,11 +4028,11 @@ static void cb_decompressed(retro_task_t *task, if (dec && !err) { - unsigned type_hash = (unsigned)(uintptr_t)user_data; + unsigned enum_idx = (unsigned)(uintptr_t)user_data; - switch (type_hash) + switch (enum_idx) { - case CB_UPDATE_ASSETS: + case MENU_ENUM_LABEL_CB_UPDATE_ASSETS: generic_action_ok_command(CMD_EVENT_REINIT); break; default: @@ -4346,8 +4346,8 @@ void cb_generic_download(retro_task_t *task, decompress_task = (retro_task_t*)task_push_decompress( output_path, dir_path, NULL, NULL, NULL, - cb_decompressed, (void*)(uintptr_t) - msg_hash_calculate(msg_hash_to_str(transf->enum_idx)), + cb_decompressed, + (void*)(uintptr_t)transf->enum_idx, frontend_userdata, false); if (!decompress_task) diff --git a/msg_hash.h b/msg_hash.h index 98d28d8847..5f836ad6d6 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -2809,8 +2809,7 @@ enum msg_hash_enums }; /* Callback strings */ -/* TODO/FIXME - get rid of these two */ -#define CB_UPDATE_ASSETS 0xbf85795eU +/* TODO/FIXME - get rid of this */ #define MENU_LABEL_SCREEN_RESOLUTION 0x5c9b3a58U From a8e39176134d81170bb607628aa620eaefab9e95 Mon Sep 17 00:00:00 2001 From: Autechre Date: Sun, 10 May 2020 07:04:44 +0200 Subject: [PATCH 022/192] Update CHANGES.md --- CHANGES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 42d9fad514..ee88c7245a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,7 @@ # Future +- GLCORE: Switch to glcore video driver when requested by a core +- LINUX/XDG: Use GenericName correctly in desktop entry +- MENU/MATERIALUI: Add desktop-style playlist view mode # 1.8.6 - 3DS: Add IDs for UZEM, TGB Dual, and NeoCD From ba8a07a2b67c3eb0267c8cbe2eb31c6195460463 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 10 May 2020 07:14:10 +0200 Subject: [PATCH 023/192] (Menu driver) Turn some functions into static functions --- menu/menu_driver.c | 166 ++++++++++++++++++++++---------------------- menu/menu_entries.h | 4 -- 2 files changed, 83 insertions(+), 87 deletions(-) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 39e8e23527..5e38dcd3fa 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -75,6 +75,50 @@ typedef struct menu_ctx_load_image enum menu_image_type type; } menu_ctx_load_image_t; +struct menu_list +{ + size_t menu_stack_size; + size_t selection_buf_size; + file_list_t **menu_stack; + file_list_t **selection_buf; +}; + +/* Storage container for current menu datetime + * representation string */ +static char menu_datetime_cache[255] = {0}; + +/* when enabled, on next iteration the 'Quick Menu' list will + * be pushed onto the stack */ +static bool menu_driver_pending_quick_menu = false; + +static bool menu_driver_prevent_populate = false; + +/* The menu driver owns the userdata */ +static bool menu_driver_data_own = false; + +static menu_handle_t *menu_driver_data = NULL; +static const menu_ctx_driver_t *menu_driver_ctx = NULL; +static void *menu_userdata = NULL; + +/* Quick jumping indices with L/R. + * Rebuilt when parsing directory. */ +static size_t scroll_index_list[SCROLL_INDEX_SIZE]; +static unsigned scroll_index_size = 0; +static unsigned scroll_acceleration = 0; +static size_t menu_driver_selection_ptr = 0; + +/* Timers */ +static retro_time_t menu_driver_current_time_us = 0; +static retro_time_t menu_driver_powerstate_last_time_us = 0; +static retro_time_t menu_driver_datetime_last_time_us = 0; + +/* Flagged when menu entries need to be refreshed */ +static bool menu_entries_need_refresh = false; +static bool menu_entries_nonblocking_refresh = false; +static size_t menu_entries_begin = 0; +static rarch_setting_t *menu_entries_list_settings = NULL; +static menu_list_t *menu_entries_list = NULL; + static enum action_iterate_type action_iterate_type(const char *label) { if (string_is_equal(label, "info_screen")) @@ -101,6 +145,45 @@ static enum action_iterate_type action_iterate_type(const char *label) return ITERATE_TYPE_DEFAULT; } +static void get_current_menu_value(char* retstr, size_t max) +{ + const char* entry_label; + menu_entry_t entry; + + menu_driver_selection_ptr = menu_navigation_get_selection(); + menu_entry_init(&entry); + menu_entry_get(&entry, 0, menu_navigation_get_selection(), NULL, true); + menu_entry_get_value(&entry, &entry_label); + + strlcpy(retstr, entry_label, max); +} + +static void get_current_menu_label(char* retstr, size_t max) +{ + const char* entry_label; + menu_entry_t entry; + + menu_driver_selection_ptr = menu_navigation_get_selection(); + menu_entry_init(&entry); + menu_entry_get(&entry, 0, menu_navigation_get_selection(), NULL, true); + menu_entry_get_rich_label(&entry, &entry_label); + + strlcpy(retstr, entry_label, max); +} + + +static void get_current_menu_sublabel(char* retstr, size_t max) +{ + const char* entry_sublabel; + menu_entry_t entry; + + menu_driver_selection_ptr = menu_navigation_get_selection(); + menu_entry_init(&entry); + menu_entry_get(&entry, 0, menu_navigation_get_selection(), NULL, true); + + menu_entry_get_sublabel(&entry, &entry_sublabel); + strlcpy(retstr, entry_sublabel, max); +} /** * menu_iterate: @@ -602,50 +685,6 @@ static const menu_ctx_driver_t *menu_ctx_drivers[] = { NULL }; -/* Storage container for current menu datetime - * representation string */ -static char menu_datetime_cache[255] = {0}; - -/* when enabled, on next iteration the 'Quick Menu' list will - * be pushed onto the stack */ -static bool menu_driver_pending_quick_menu = false; - -static bool menu_driver_prevent_populate = false; - -/* The menu driver owns the userdata */ -static bool menu_driver_data_own = false; - -static menu_handle_t *menu_driver_data = NULL; -static const menu_ctx_driver_t *menu_driver_ctx = NULL; -static void *menu_userdata = NULL; - -/* Quick jumping indices with L/R. - * Rebuilt when parsing directory. */ -static size_t scroll_index_list[SCROLL_INDEX_SIZE]; -static unsigned scroll_index_size = 0; -static unsigned scroll_acceleration = 0; -static size_t menu_driver_selection_ptr = 0; - -/* Timers */ -static retro_time_t menu_driver_current_time_us = 0; -static retro_time_t menu_driver_powerstate_last_time_us = 0; -static retro_time_t menu_driver_datetime_last_time_us = 0; - -/* Flagged when menu entries need to be refreshed */ -static bool menu_entries_need_refresh = false; -static bool menu_entries_nonblocking_refresh = false; -static size_t menu_entries_begin = 0; -static rarch_setting_t *menu_entries_list_settings = NULL; -static menu_list_t *menu_entries_list = NULL; - -struct menu_list -{ - size_t menu_stack_size; - size_t selection_buf_size; - file_list_t **menu_stack; - file_list_t **selection_buf; -}; - menu_handle_t *menu_driver_get_ptr(void) { return menu_driver_data; @@ -3049,42 +3088,3 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) return true; } - -void get_current_menu_value(char* retstr, size_t max) -{ - const char* entry_label; - menu_entry_t entry; - - menu_driver_selection_ptr = menu_navigation_get_selection(); - menu_entry_init(&entry); - menu_entry_get(&entry, 0, menu_navigation_get_selection(), NULL, true); - menu_entry_get_value(&entry, &entry_label); - - strlcpy(retstr, entry_label, max); -} - -void get_current_menu_label(char* retstr, size_t max) -{ - const char* entry_label; - menu_entry_t entry; - - menu_driver_selection_ptr = menu_navigation_get_selection(); - menu_entry_init(&entry); - menu_entry_get(&entry, 0, menu_navigation_get_selection(), NULL, true); - menu_entry_get_rich_label(&entry, &entry_label); - - strlcpy(retstr, entry_label, max); -} - -void get_current_menu_sublabel(char* retstr, size_t max) -{ - const char* entry_sublabel; - menu_entry_t entry; - - menu_driver_selection_ptr = menu_navigation_get_selection(); - menu_entry_init(&entry); - menu_entry_get(&entry, 0, menu_navigation_get_selection(), NULL, true); - - menu_entry_get_sublabel(&entry, &entry_sublabel); - strlcpy(retstr, entry_sublabel, max); -} diff --git a/menu/menu_entries.h b/menu/menu_entries.h index 0ba5038414..41663e28ca 100644 --- a/menu/menu_entries.h +++ b/menu/menu_entries.h @@ -264,10 +264,6 @@ int menu_entry_action( void menu_entry_init(menu_entry_t *entry); -void get_current_menu_value(char* retstr, size_t max); -void get_current_menu_label(char* retstr, size_t max); -void get_current_menu_sublabel(char* retstr, size_t max); - RETRO_END_DECLS #endif From 10e6ea21a3f08a08634ae4994b92d5e7ba56a331 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 10 May 2020 07:17:15 +0200 Subject: [PATCH 024/192] Put this behind HAVE_ACCESSIBILITY ifdef --- menu/menu_driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 5e38dcd3fa..4240436654 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -145,6 +145,7 @@ static enum action_iterate_type action_iterate_type(const char *label) return ITERATE_TYPE_DEFAULT; } +#ifdef HAVE_ACCESSIBILITY static void get_current_menu_value(char* retstr, size_t max) { const char* entry_label; @@ -171,7 +172,6 @@ static void get_current_menu_label(char* retstr, size_t max) strlcpy(retstr, entry_label, max); } - static void get_current_menu_sublabel(char* retstr, size_t max) { const char* entry_sublabel; @@ -184,6 +184,7 @@ static void get_current_menu_sublabel(char* retstr, size_t max) menu_entry_get_sublabel(&entry, &entry_sublabel); strlcpy(retstr, entry_sublabel, max); } +#endif /** * menu_iterate: From e74161bc6cb7c870c47a388ae62ade79ad47da01 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 10 May 2020 08:51:25 +0200 Subject: [PATCH 025/192] Change name of nvdaController.h --- frontend/drivers/platform_win32.c | 2 +- nvdaController.h => nvda_controller.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename nvdaController.h => nvda_controller.h (98%) diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 5223416e8f..611cb6d29a 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -52,7 +52,7 @@ #include "platform_win32.h" #ifdef HAVE_NVDA -#include "../../nvdaController.h" +#include "../../nvda_controller.h" #endif #ifndef SM_SERVERR2 diff --git a/nvdaController.h b/nvda_controller.h similarity index 98% rename from nvdaController.h rename to nvda_controller.h index 78cb0738d0..d2ace11524 100644 --- a/nvdaController.h +++ b/nvda_controller.h @@ -27,7 +27,7 @@ #ifndef __RPCNDR_H_VERSION__ #error this stub requires an updated version of -#endif // __RPCNDR_H_VERSION__ +#endif /* __RPCNDR_H_VERSION__ */ #ifndef __nvdaController_h__ From 3c192419dd8bacbfe9c416ebd147c2082f442f0c Mon Sep 17 00:00:00 2001 From: Tobias Gruetzmacher Date: Sun, 10 May 2020 14:30:30 +0200 Subject: [PATCH 026/192] (WiiU) Fix griffin build --- Makefile.wiiu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.wiiu b/Makefile.wiiu index 96cc10fa2b..0d29bf79b6 100644 --- a/Makefile.wiiu +++ b/Makefile.wiiu @@ -97,7 +97,7 @@ endif OBJ += gfx/drivers/gx2_shaders/snowflake.o ifeq ($(GRIFFIN_BUILD), 1) - OBJ += griffin/griffin.o + OBJ += griffin/griffin.o griffin/griffin_cpp.o INCDIRS += -Ilibretro-common/include/compat/zlib # for stb, libfat, iosuhax From 29929acdbaadf03239b7e2e77284f234591fc1af Mon Sep 17 00:00:00 2001 From: Tobias Gruetzmacher Date: Sun, 10 May 2020 15:13:23 +0200 Subject: [PATCH 027/192] (WiiU) Enable GFX widgets --- Makefile.wiiu | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.wiiu b/Makefile.wiiu index 0d29bf79b6..bb6cedd9d0 100644 --- a/Makefile.wiiu +++ b/Makefile.wiiu @@ -107,7 +107,7 @@ endif INCDIRS += -Ideps/SPIRV-Cross DEFINES += -DHAVE_AUDIOMIXER - DEFINES += -DHAVE_GRIFFIN=1 -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_RGUI -DHAVE_LIBRETRODB + DEFINES += -DHAVE_GRIFFIN=1 -DHAVE_MENU -DHAVE_GFX_WIDGETS -DHAVE_CONFIGFILE -DHAVE_RGUI -DHAVE_LIBRETRODB DEFINES += -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DHAVE_CC_RESAMPLER DEFINES += -DHAVE_SPIRV_CROSS -DHAVE_SLANG DEFINES += -DHAVE_STB_FONT -DHAVE_STB_VORBIS -DHAVE_LANGEXTRA -DHAVE_LIBRETRODB -DHAVE_NETWORKING -DHAVE_NETPLAYDISCOVERY @@ -122,6 +122,7 @@ endif else HAVE_AUDIOMIXER = 1 HAVE_MENU_COMMON = 1 + HAVE_GFX_WIDGETS = 1 HAVE_RTGA = 1 HAVE_RPNG = 1 HAVE_RJPEG = 1 From 9c749f03ebd94cb4e15455b36eb7845357d5a825 Mon Sep 17 00:00:00 2001 From: Autechre Date: Sun, 10 May 2020 15:41:10 +0200 Subject: [PATCH 028/192] Update CHANGES.md --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index ee88c7245a..b6c306d50a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,7 +1,9 @@ # Future +- 3DS: Enable basic networking / cheevos - GLCORE: Switch to glcore video driver when requested by a core - LINUX/XDG: Use GenericName correctly in desktop entry - MENU/MATERIALUI: Add desktop-style playlist view mode +- WIIU: Enable graphics widgets # 1.8.6 - 3DS: Add IDs for UZEM, TGB Dual, and NeoCD From edfafd9fadec57ab66df4f88df5b8c57d95adf42 Mon Sep 17 00:00:00 2001 From: Alex Kornitzer Date: Sun, 10 May 2020 22:20:48 +0100 Subject: [PATCH 029/192] cocoa: fix mouse movement The input driver was using absolute coordinate arithmetic while making use of delta changes for each coordinate, as a result the absolute change netted to zero. This fixes that and tries to mitigate cursor event sync issues (sync issues will require more work). --- input/drivers/cocoa_input.c | 52 +++++++++++++++++++++---------------- ui/drivers/ui_cocoa.m | 4 +-- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index dffe1de7e1..05405f2939 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -192,35 +192,41 @@ static void cocoa_input_poll(void *data) apple->joypad->poll(); if (apple->sec_joypad) apple->sec_joypad->poll(); - - apple->mouse_x_last = apple->mouse_rel_x; - apple->mouse_y_last = apple->mouse_rel_y; } static int16_t cocoa_mouse_state(cocoa_input_data_t *apple, unsigned id) { - switch (id) - { - case RETRO_DEVICE_ID_MOUSE_X: - return apple->mouse_rel_x - apple->mouse_x_last; - case RETRO_DEVICE_ID_MOUSE_Y: - return apple->mouse_rel_y - apple->mouse_y_last; - case RETRO_DEVICE_ID_MOUSE_LEFT: - return apple->mouse_buttons & 1; - case RETRO_DEVICE_ID_MOUSE_RIGHT: - return apple->mouse_buttons & 2; - case RETRO_DEVICE_ID_MOUSE_WHEELUP: - return apple->mouse_wu; - case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: - return apple->mouse_wd; - case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP: - return apple->mouse_wl; - case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN: - return apple->mouse_wr; - } + int16_t val; + switch (id) + { + case RETRO_DEVICE_ID_MOUSE_X: + val = apple->mouse_rel_x; + // NOTE: Because cocoa events are effectively handled async we reset + // the delta which we cumulate on each event + apple->mouse_rel_x = 0; + return val; + case RETRO_DEVICE_ID_MOUSE_Y: + val = apple->mouse_rel_y; + // NOTE: Because cocoa events are effectively handled async we reset + // the delta which we cumulate on each event + apple->mouse_rel_y = 0; + return val; + case RETRO_DEVICE_ID_MOUSE_LEFT: + return apple->mouse_buttons & 1; + case RETRO_DEVICE_ID_MOUSE_RIGHT: + return apple->mouse_buttons & 2; + case RETRO_DEVICE_ID_MOUSE_WHEELUP: + return apple->mouse_wu; + case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: + return apple->mouse_wd; + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP: + return apple->mouse_wl; + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN: + return apple->mouse_wr; + } - return 0; + return 0; } static int16_t cocoa_mouse_state_screen(cocoa_input_data_t *apple, diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index 5528226b1a..0947e632bf 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -132,8 +132,8 @@ static void app_terminate(void) pos.y = 0; /* Relative */ - apple->mouse_rel_x = (int16_t)event.deltaX; - apple->mouse_rel_y = (int16_t)event.deltaY; + apple->mouse_rel_x += (int16_t)event.deltaX; + apple->mouse_rel_y += (int16_t)event.deltaY; /* Absolute */ #if defined(HAVE_COCOA_METAL) From c4ee0463aad57ed0b6e52a8cbb691efb048e9953 Mon Sep 17 00:00:00 2001 From: Alex Kornitzer Date: Sun, 10 May 2020 22:43:55 +0100 Subject: [PATCH 030/192] cocoa: don't update mouse events when outside nswindow --- ui/drivers/ui_cocoa.m | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index 0947e632bf..0a090051f5 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -131,26 +131,26 @@ static void app_terminate(void) pos.x = 0; pos.y = 0; - /* Relative */ - apple->mouse_rel_x += (int16_t)event.deltaX; - apple->mouse_rel_y += (int16_t)event.deltaY; - - /* Absolute */ #if defined(HAVE_COCOA_METAL) pos = [apple_platform.renderView convertPoint:[event locationInWindow] fromView:nil]; #elif defined(HAVE_COCOA) pos = [[CocoaView get] convertPoint:[event locationInWindow] fromView:nil]; #endif + + NSInteger window_number = [[[NSApplication sharedApplication] keyWindow] windowNumber]; + if ([NSWindow windowNumberAtPoint:pos belowWindowWithWindowNumber:0] != window_number) { + return; + } + + /* Relative */ + apple->mouse_rel_x += (int16_t)event.deltaX; + apple->mouse_rel_y += (int16_t)event.deltaY; + + /* Absolute */ apple->touches[0].screen_x = (int16_t)pos.x; apple->touches[0].screen_y = (int16_t)pos.y; - -#if defined(HAVE_COCOA_METAL) - mouse_pos = [apple_platform.renderView convertPoint:[event locationInWindow] fromView:nil]; -#elif defined(HAVE_COCOA) - mouse_pos = [[CocoaView get] convertPoint:[event locationInWindow] fromView:nil]; -#endif - apple->window_pos_x = (int16_t)mouse_pos.x; - apple->window_pos_y = (int16_t)mouse_pos.y; + apple->window_pos_x = (int16_t)pos.x; + apple->window_pos_y = (int16_t)pos.y; } break; #if defined(HAVE_COCOA_METAL) From 211a8a149bc46a0213754a430231fde553af283a Mon Sep 17 00:00:00 2001 From: Autechre Date: Mon, 11 May 2020 00:31:17 +0200 Subject: [PATCH 031/192] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index b6c306d50a..28274fa1c9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ - 3DS: Enable basic networking / cheevos - GLCORE: Switch to glcore video driver when requested by a core - LINUX/XDG: Use GenericName correctly in desktop entry +- MAC/COCOA: Fix mouse cursor tracking - MENU/MATERIALUI: Add desktop-style playlist view mode - WIIU: Enable graphics widgets From cdfb8348b09e31b4611a74806a92679053308e43 Mon Sep 17 00:00:00 2001 From: Alex Kornitzer Date: Mon, 11 May 2020 00:19:55 +0100 Subject: [PATCH 032/192] cocoa: use absolute positioning over relative Now that we clip the window to locate the cursor correctly on re-entry we need to do our cursor calculations using absolute coordinates --- input/drivers/cocoa_input.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index 05405f2939..6f742275cb 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -201,16 +201,12 @@ static int16_t cocoa_mouse_state(cocoa_input_data_t *apple, switch (id) { case RETRO_DEVICE_ID_MOUSE_X: - val = apple->mouse_rel_x; - // NOTE: Because cocoa events are effectively handled async we reset - // the delta which we cumulate on each event - apple->mouse_rel_x = 0; + val = apple->window_pos_x - apple->mouse_x_last; + apple->mouse_x_last = apple->window_pos_x; return val; case RETRO_DEVICE_ID_MOUSE_Y: - val = apple->mouse_rel_y; - // NOTE: Because cocoa events are effectively handled async we reset - // the delta which we cumulate on each event - apple->mouse_rel_y = 0; + val = apple->window_pos_y - apple->mouse_y_last; + apple->mouse_y_last = apple->window_pos_y; return val; case RETRO_DEVICE_ID_MOUSE_LEFT: return apple->mouse_buttons & 1; From 1d2dd249f3321e64790f8e1d1f33bdbe5ada78de Mon Sep 17 00:00:00 2001 From: Alex Kornitzer Date: Mon, 11 May 2020 00:57:26 +0100 Subject: [PATCH 033/192] cocoa: disable clipping cursor to window --- ui/drivers/ui_cocoa.m | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index 0a090051f5..d31c99b989 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -137,10 +137,11 @@ static void app_terminate(void) pos = [[CocoaView get] convertPoint:[event locationInWindow] fromView:nil]; #endif - NSInteger window_number = [[[NSApplication sharedApplication] keyWindow] windowNumber]; - if ([NSWindow windowNumberAtPoint:pos belowWindowWithWindowNumber:0] != window_number) { - return; - } + // FIXME: Disable clipping until graphical offset issues are fixed + //NSInteger window_number = [[[NSApplication sharedApplication] keyWindow] windowNumber]; + //if ([NSWindow windowNumberAtPoint:pos belowWindowWithWindowNumber:0] != window_number) { + // return; + //} /* Relative */ apple->mouse_rel_x += (int16_t)event.deltaX; From 39dbfd1db41b0ab3efa88417133cb56421947083 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 May 2020 02:32:28 +0200 Subject: [PATCH 034/192] Remove unused menu_content.h --- menu/cbs/menu_cbs_left.c | 1 - menu/cbs/menu_cbs_ok.c | 1 - menu/cbs/menu_cbs_right.c | 1 - menu/menu_content.h | 39 ------------------- menu/menu_displaylist.c | 1 - menu/menu_driver.h | 11 +++++- .../RetroArch_Metal.xcodeproj/project.pbxproj | 4 -- 7 files changed, 10 insertions(+), 48 deletions(-) delete mode 100644 menu/menu_content.h diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 329cc6f86d..db20c52547 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -22,7 +22,6 @@ #include "../../config.h" #endif -#include "../menu_content.h" #include "../menu_driver.h" #include "../menu_entries.h" #include "../menu_cbs.h" diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index b6c157d7af..35a9c6038a 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -52,7 +52,6 @@ #include "../widgets/menu_input_bind_dialog.h" #include "../menu_input.h" #include "../menu_networking.h" -#include "../menu_content.h" #include "../../core.h" #include "../../configuration.h" diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index f001fe838c..b8b3cf3561 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -22,7 +22,6 @@ #include "../../config.h" #endif -#include "../menu_content.h" #include "../menu_driver.h" #include "../menu_entries.h" #include "../menu_cbs.h" diff --git a/menu/menu_content.h b/menu/menu_content.h deleted file mode 100644 index bac1c4220d..0000000000 --- a/menu/menu_content.h +++ /dev/null @@ -1,39 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2011-2017 - Daniel De Matteis - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . - */ - -#ifndef __MENU_CONTENT_H__ -#define __MENU_CONTENT_H__ - -#include -#include - -#include -#include - -RETRO_BEGIN_DECLS - -typedef struct menu_content_ctx_defer_info -{ - void *data; - const char *dir; - const char *path; - const char *menu_label; - char *s; - size_t len; -} menu_content_ctx_defer_info_t; - -RETRO_END_DECLS - -#endif diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index e791e14b52..3c9e5815f0 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -68,7 +68,6 @@ #endif #include "menu_cbs.h" -#include "menu_content.h" #include "menu_driver.h" #include "menu_entries.h" #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 5670e5ffe6..da4debff16 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -208,7 +208,6 @@ enum menu_settings_type MENU_SETTINGS_LAST }; - typedef struct menu_ctx_driver { /* Set a framebuffer texture. This is used for instance by RGUI. */ @@ -323,6 +322,16 @@ typedef struct void *userdata; } menu_handle_t; +typedef struct menu_content_ctx_defer_info +{ + void *data; + const char *dir; + const char *path; + const char *menu_label; + char *s; + size_t len; +} menu_content_ctx_defer_info_t; + typedef struct menu_ctx_displaylist { menu_displaylist_info_t *info; diff --git a/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj index 2bf98f64b7..be8cd9cbcf 100644 --- a/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj @@ -193,7 +193,6 @@ 05A8C52D20DB72F000FF7857 /* menu_cbs_up.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = menu_cbs_up.c; sourceTree = ""; }; 05A8C52E20DB72F000FF7857 /* gfx_animation.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = gfx_animation.c; sourceTree = ""; }; 05A8C52F20DB72F000FF7857 /* menu_displaylist.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = menu_displaylist.h; sourceTree = ""; }; - 05A8C53020DB72F000FF7857 /* menu_content.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = menu_content.h; sourceTree = ""; }; 05A8C53220DB72F000FF7857 /* xmb.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = xmb.c; sourceTree = ""; }; 05A8C53B20DB72F000FF7857 /* xui.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = xui.cpp; sourceTree = ""; }; 05A8C53C20DB72F000FF7857 /* rgui.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = rgui.c; sourceTree = ""; }; @@ -205,7 +204,6 @@ 05A8C54520DB72F000FF7857 /* menu_entries.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = menu_entries.c; sourceTree = ""; }; 05A8C54620DB72F000FF7857 /* menu_setting.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = menu_setting.c; sourceTree = ""; }; 05A8C54720DB72F000FF7857 /* menu_input.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = menu_input.c; sourceTree = ""; }; - 05A8C54820DB72F000FF7857 /* menu_content.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = menu_content.c; sourceTree = ""; }; 05A8C54920DB72F000FF7857 /* menu_displaylist.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = menu_displaylist.c; sourceTree = ""; }; 05A8C54A20DB72F000FF7857 /* menu_shader.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = menu_shader.c; sourceTree = ""; }; 05A8C54B20DB72F000FF7857 /* gfx_animation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = gfx_animation.h; sourceTree = ""; }; @@ -761,8 +759,6 @@ 05A8C54B20DB72F000FF7857 /* gfx_animation.h */, 05A8C54120DB72F000FF7857 /* menu_cbs.c */, 05A8C54C20DB72F000FF7857 /* menu_cbs.h */, - 05A8C54820DB72F000FF7857 /* menu_content.c */, - 05A8C53020DB72F000FF7857 /* menu_content.h */, 05A8C54920DB72F000FF7857 /* menu_displaylist.c */, 05A8C52F20DB72F000FF7857 /* menu_displaylist.h */, 05A8C54D20DB72F000FF7857 /* menu_driver.c */, From 685db0503205df8f0b9f04a3e786bb30dbbf707a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 May 2020 03:29:01 +0200 Subject: [PATCH 035/192] Backport https://github.com/neil4/RetroArch-Lite/commit/66876fe8581de7b2ee79a06a5c4912d0e8e52b41 - handles insertion/removal of audio devices for Xaudio2 - hopefully a callback based approach can be done later --- audio/drivers/xaudio.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/audio/drivers/xaudio.c b/audio/drivers/xaudio.c index 04397fd70a..9fda94bb60 100644 --- a/audio/drivers/xaudio.c +++ b/audio/drivers/xaudio.c @@ -1,6 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2017 - Daniel De Matteis + * Copyright (C) 2011-2020 - Daniel De Matteis + * Copyright (C) 2020 - neil4 * * 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- @@ -42,6 +43,7 @@ #include "../common/mmdevice_common.h" #endif +#include "../../command.h" #include "../../retroarch.h" #include "../../verbosity.h" @@ -57,6 +59,8 @@ typedef struct xaudio2 xaudio2_t; #define XAUDIO2_WRITE_AVAILABLE(handle) ((handle)->bufsize * (MAX_BUFFERS - (handle)->buffers - 1)) +static unsigned xaudio2_device_count; + typedef struct { xaudio2_t *xa; @@ -280,6 +284,8 @@ static xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels, XAUDIO2_COMMIT_NOW))) goto error; + IXAudio2_GetDeviceCount(handle->pXAudio2, &xaudio2_device_count); + if (list) string_list_free(list); return handle; @@ -324,10 +330,21 @@ static void *xa_init(const char *device, unsigned rate, unsigned latency, static ssize_t xa_write(void *data, const void *buf, size_t size) { unsigned bytes; + unsigned dev_count; xa_t *xa = (xa_t*)data; xaudio2_t *handle = xa->xa; const uint8_t *buffer = (const uint8_t*)buf; + /* TODO/FIXME - register a callback instead */ + IXAudio2_GetDeviceCount(handle->pXAudio2, &dev_count); + + if (dev_count != xaudio2_device_count) + { + xaudio2_device_count = dev_count; + command_event(CMD_EVENT_AUDIO_REINIT, NULL); + return 0; + } + if (xa->nonblock) { size_t avail = XAUDIO2_WRITE_AVAILABLE(xa->xa); @@ -458,7 +475,6 @@ static void *xa_list_new(void *u) #if defined(_XBOX) || !(_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/) unsigned i; union string_list_elem_attr attr; - uint32_t dev_count = 0; IXAudio2 *ixa2 = NULL; struct string_list *sl = string_list_new(); @@ -470,9 +486,9 @@ static void *xa_list_new(void *u) if (FAILED(XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR))) return NULL; - IXAudio2_GetDeviceCount(ixa2, &dev_count); + IXAudio2_GetDeviceCount(ixa2, &xaudio2_device_count); - for (i = 0; i < dev_count; i++) + for (i = 0; i < xaudio2_device_count; i++) { XAUDIO2_DEVICE_DETAILS dev_detail; if (IXAudio2_GetDeviceDetails(ixa2, i, &dev_detail) == S_OK) From 35269cce9346a706adabd3d42c9ae7be50069f11 Mon Sep 17 00:00:00 2001 From: Autechre Date: Mon, 11 May 2020 03:32:10 +0200 Subject: [PATCH 036/192] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 28274fa1c9..55629db18d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ - LINUX/XDG: Use GenericName correctly in desktop entry - MAC/COCOA: Fix mouse cursor tracking - MENU/MATERIALUI: Add desktop-style playlist view mode +- WINDOWS/XAUDIO2: Inserting/removing an audio device (e.g. headphones, speakers) will no longer crash RetroArch - WIIU: Enable graphics widgets # 1.8.6 From f5b33c8912b9866aa53235705773b3b2a082aba4 Mon Sep 17 00:00:00 2001 From: Autechre Date: Mon, 11 May 2020 03:33:41 +0200 Subject: [PATCH 037/192] Update CHANGES.md --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 55629db18d..59290984a4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,10 +1,10 @@ # Future - 3DS: Enable basic networking / cheevos +- AUDIO/WINDOWS: XAudio2 - Inserting/removing an audio device (e.g. headphones, speakers) will no longer crash RetroArch - GLCORE: Switch to glcore video driver when requested by a core - LINUX/XDG: Use GenericName correctly in desktop entry - MAC/COCOA: Fix mouse cursor tracking - MENU/MATERIALUI: Add desktop-style playlist view mode -- WINDOWS/XAUDIO2: Inserting/removing an audio device (e.g. headphones, speakers) will no longer crash RetroArch - WIIU: Enable graphics widgets # 1.8.6 From 4a9e1e6c7e504f6d5ef926532bd6027377127e22 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 May 2020 03:49:16 +0200 Subject: [PATCH 038/192] Revert "Backport" This reverts commit 685db0503205df8f0b9f04a3e786bb30dbbf707a. --- audio/drivers/xaudio.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/audio/drivers/xaudio.c b/audio/drivers/xaudio.c index 9fda94bb60..04397fd70a 100644 --- a/audio/drivers/xaudio.c +++ b/audio/drivers/xaudio.c @@ -1,7 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2020 - Daniel De Matteis - * Copyright (C) 2020 - neil4 + * Copyright (C) 2011-2017 - Daniel De Matteis * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- @@ -43,7 +42,6 @@ #include "../common/mmdevice_common.h" #endif -#include "../../command.h" #include "../../retroarch.h" #include "../../verbosity.h" @@ -59,8 +57,6 @@ typedef struct xaudio2 xaudio2_t; #define XAUDIO2_WRITE_AVAILABLE(handle) ((handle)->bufsize * (MAX_BUFFERS - (handle)->buffers - 1)) -static unsigned xaudio2_device_count; - typedef struct { xaudio2_t *xa; @@ -284,8 +280,6 @@ static xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels, XAUDIO2_COMMIT_NOW))) goto error; - IXAudio2_GetDeviceCount(handle->pXAudio2, &xaudio2_device_count); - if (list) string_list_free(list); return handle; @@ -330,21 +324,10 @@ static void *xa_init(const char *device, unsigned rate, unsigned latency, static ssize_t xa_write(void *data, const void *buf, size_t size) { unsigned bytes; - unsigned dev_count; xa_t *xa = (xa_t*)data; xaudio2_t *handle = xa->xa; const uint8_t *buffer = (const uint8_t*)buf; - /* TODO/FIXME - register a callback instead */ - IXAudio2_GetDeviceCount(handle->pXAudio2, &dev_count); - - if (dev_count != xaudio2_device_count) - { - xaudio2_device_count = dev_count; - command_event(CMD_EVENT_AUDIO_REINIT, NULL); - return 0; - } - if (xa->nonblock) { size_t avail = XAUDIO2_WRITE_AVAILABLE(xa->xa); @@ -475,6 +458,7 @@ static void *xa_list_new(void *u) #if defined(_XBOX) || !(_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/) unsigned i; union string_list_elem_attr attr; + uint32_t dev_count = 0; IXAudio2 *ixa2 = NULL; struct string_list *sl = string_list_new(); @@ -486,9 +470,9 @@ static void *xa_list_new(void *u) if (FAILED(XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR))) return NULL; - IXAudio2_GetDeviceCount(ixa2, &xaudio2_device_count); + IXAudio2_GetDeviceCount(ixa2, &dev_count); - for (i = 0; i < xaudio2_device_count; i++) + for (i = 0; i < dev_count; i++) { XAUDIO2_DEVICE_DETAILS dev_detail; if (IXAudio2_GetDeviceDetails(ixa2, i, &dev_detail) == S_OK) From 01667b5fc38ed1de8ada7ef93fb217e524a85c9e Mon Sep 17 00:00:00 2001 From: Autechre Date: Mon, 11 May 2020 04:53:16 +0200 Subject: [PATCH 039/192] Update CHANGES.md --- CHANGES.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 59290984a4..28274fa1c9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,5 @@ # Future - 3DS: Enable basic networking / cheevos -- AUDIO/WINDOWS: XAudio2 - Inserting/removing an audio device (e.g. headphones, speakers) will no longer crash RetroArch - GLCORE: Switch to glcore video driver when requested by a core - LINUX/XDG: Use GenericName correctly in desktop entry - MAC/COCOA: Fix mouse cursor tracking From 98daa0d28cde62c83962e9cf0851994ed14064cc Mon Sep 17 00:00:00 2001 From: Autechre Date: Mon, 11 May 2020 10:19:05 +0200 Subject: [PATCH 040/192] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 28274fa1c9..0974ea3869 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ - LINUX/XDG: Use GenericName correctly in desktop entry - MAC/COCOA: Fix mouse cursor tracking - MENU/MATERIALUI: Add desktop-style playlist view mode +- NETPLAY: Fix regressions introduced in 1.8.5 - WIIU: Enable graphics widgets # 1.8.6 From 26c01dd34c54a980b88aa60162776878a80e9464 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Mon, 11 May 2020 11:38:24 +0100 Subject: [PATCH 041/192] (RGUI) Add option to always stretch menu to fill the screen --- intl/msg_hash_us.h | 4 ++++ menu/drivers/rgui.c | 13 +++++++++++-- menu/menu_defines.h | 1 + menu/menu_setting.c | 8 +++++++- msg_hash.h | 7 ++++--- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index d5d77dd606..0af56c7a4d 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -7359,6 +7359,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_LOCK_INTEGER, "Integer Scale" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_LOCK_FILL_SCREEN, + "Fill Screen (Stretched)" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME_CUSTOM, "Custom" diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 454436e71e..43f6134000 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -2201,7 +2201,7 @@ static void load_custom_theme(rgui_t *rgui, rgui_theme_t *theme_colors, const ch unsigned shadow_color = 0; unsigned particle_color = 0; config_file_t *conf = NULL; - char *wallpaper_key = NULL; + const char *wallpaper_key = NULL; settings_t *settings = config_get_ptr(); bool success = false; unsigned rgui_aspect_ratio = settings->uints.menu_rgui_aspect_ratio; @@ -4078,7 +4078,16 @@ static void rgui_update_menu_viewport(rgui_t *rgui) do_integer_scaling = false; } - if (!do_integer_scaling) + /* Check whether menu should be stretched to + * fill the screen, regardless of internal + * aspect ratio */ + if (aspect_ratio_lock == RGUI_ASPECT_RATIO_LOCK_FILL_SCREEN) + { + rgui->menu_video_settings.viewport.width = vp.full_width; + rgui->menu_video_settings.viewport.height = vp.full_height; + } + /* Normal non-integer aspect-ratio-correct scaling */ + else if (!do_integer_scaling) { float display_aspect_ratio = (float)vp.full_width / (float)vp.full_height; diff --git a/menu/menu_defines.h b/menu/menu_defines.h index 58c294c581..77972fb22d 100644 --- a/menu/menu_defines.h +++ b/menu/menu_defines.h @@ -309,6 +309,7 @@ enum rgui_aspect_ratio_lock RGUI_ASPECT_RATIO_LOCK_NONE = 0, RGUI_ASPECT_RATIO_LOCK_FIT_SCREEN, RGUI_ASPECT_RATIO_LOCK_INTEGER, + RGUI_ASPECT_RATIO_LOCK_FILL_SCREEN, RGUI_ASPECT_RATIO_LOCK_LAST }; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 5764bacf92..e238daf488 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3693,6 +3693,12 @@ static void setting_get_string_representation_uint_rgui_aspect_ratio_lock( MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_LOCK_INTEGER), len); break; + case RGUI_ASPECT_RATIO_LOCK_FILL_SCREEN: + strlcpy(s, + msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_LOCK_FILL_SCREEN), + len); + break; } } @@ -12909,7 +12915,7 @@ static bool setting_append_list( (*list)[list_info->index - 1].get_string_representation = &setting_get_string_representation_uint_rgui_aspect_ratio_lock; #if defined(GEKKO) - menu_settings_list_current_add_range(list, list_info, 0, RGUI_ASPECT_RATIO_LOCK_LAST-2, 1, true, true); + menu_settings_list_current_add_range(list, list_info, 0, RGUI_ASPECT_RATIO_LOCK_LAST-3, 1, true, true); #else menu_settings_list_current_add_range(list, list_info, 0, RGUI_ASPECT_RATIO_LOCK_LAST-1, 1, true, true); #endif diff --git a/msg_hash.h b/msg_hash.h index 5f836ad6d6..e489f3e457 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -2375,9 +2375,10 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_16_10, MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_16_10_CENTRE, - MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_LOCK_NONE, - MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_LOCK_FIT_SCREEN, - MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_LOCK_INTEGER, + MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_LOCK_NONE, + MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_LOCK_FIT_SCREEN, + MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_LOCK_INTEGER, + MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_LOCK_FILL_SCREEN, MENU_ENUM_LABEL_VALUE_RGUI_PARTICLE_EFFECT_NONE, MENU_ENUM_LABEL_VALUE_RGUI_PARTICLE_EFFECT_SNOW, From 718d9801daed5ecdffec2e9e272bad3c7ea8cfa5 Mon Sep 17 00:00:00 2001 From: Autechre Date: Mon, 11 May 2020 16:26:26 +0200 Subject: [PATCH 042/192] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 0974ea3869..7d54fa359c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ - MAC/COCOA: Fix mouse cursor tracking - MENU/MATERIALUI: Add desktop-style playlist view mode - NETPLAY: Fix regressions introduced in 1.8.5 +- RGUI: Add option to always stretch menu to fill the screen - WIIU: Enable graphics widgets # 1.8.6 From 1534e81bed57390ee39ed7a1db34b6c980582a86 Mon Sep 17 00:00:00 2001 From: Jamiras Date: Mon, 4 May 2020 09:11:16 -0600 Subject: [PATCH 043/192] upgrade to rcheevos 9.0 --- Makefile.common | 19 +- cheevos-new/cheevos.c | 324 ++-- cheevos-new/fixup.c | 1 + deps/rcheevos/CHANGELOG.md | 49 + deps/rcheevos/README.md | 287 ++-- deps/rcheevos/include/rcheevos.h | 266 +-- deps/rcheevos/include/rconsoles.h | 79 + deps/rcheevos/include/rhash.h | 124 ++ deps/rcheevos/include/rurl.h | 9 +- deps/rcheevos/src/rcheevos/alloc.c | 34 + deps/rcheevos/src/rcheevos/compat.c | 44 + deps/rcheevos/src/rcheevos/compat.h | 55 + deps/rcheevos/src/rcheevos/condition.c | 122 +- deps/rcheevos/src/rcheevos/condset.c | 183 +- deps/rcheevos/src/rcheevos/consoleinfo.c | 573 +++++++ deps/rcheevos/src/rcheevos/expression.c | 41 - deps/rcheevos/src/rcheevos/format.c | 8 +- deps/rcheevos/src/rcheevos/internal.h | 15 +- deps/rcheevos/src/rcheevos/lboard.c | 115 +- deps/rcheevos/src/rcheevos/memref.c | 61 +- deps/rcheevos/src/rcheevos/operand.c | 390 +++-- deps/rcheevos/src/rcheevos/richpresence.c | 58 +- deps/rcheevos/src/rcheevos/runtime.c | 589 +++++++ deps/rcheevos/src/rcheevos/runtime_progress.c | 445 +++++ deps/rcheevos/src/rcheevos/term.c | 103 -- deps/rcheevos/src/rcheevos/trigger.c | 72 +- deps/rcheevos/src/rcheevos/value.c | 169 +- deps/rcheevos/src/rhash/hash.c | 1491 +++++++++++++++++ deps/rcheevos/src/rhash/md5.h | 18 + deps/rcheevos/src/rurl/url.c | 203 ++- griffin/griffin.c | 11 +- 31 files changed, 4950 insertions(+), 1008 deletions(-) create mode 100644 deps/rcheevos/include/rconsoles.h create mode 100644 deps/rcheevos/include/rhash.h create mode 100644 deps/rcheevos/src/rcheevos/compat.c create mode 100644 deps/rcheevos/src/rcheevos/compat.h create mode 100644 deps/rcheevos/src/rcheevos/consoleinfo.c delete mode 100644 deps/rcheevos/src/rcheevos/expression.c create mode 100644 deps/rcheevos/src/rcheevos/runtime.c create mode 100644 deps/rcheevos/src/rcheevos/runtime_progress.c delete mode 100644 deps/rcheevos/src/rcheevos/term.c create mode 100644 deps/rcheevos/src/rhash/hash.c create mode 100644 deps/rcheevos/src/rhash/md5.h diff --git a/Makefile.common b/Makefile.common index 43d9cf8c6f..981d5134d9 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1851,18 +1851,21 @@ ifeq ($(HAVE_NETWORKING), 1) cheevos-new/parser.o \ cheevos-new/hash.o \ $(LIBRETRO_COMM_DIR)/formats/cdfs/cdfs.o \ - deps/rcheevos/src/rcheevos/trigger.o \ - deps/rcheevos/src/rcheevos/condset.o \ - deps/rcheevos/src/rcheevos/condition.o \ - deps/rcheevos/src/rcheevos/operand.o \ - deps/rcheevos/src/rcheevos/term.o \ - deps/rcheevos/src/rcheevos/expression.o \ - deps/rcheevos/src/rcheevos/value.o \ - deps/rcheevos/src/rcheevos/lboard.o \ deps/rcheevos/src/rcheevos/alloc.o \ + deps/rcheevos/src/rcheevos/compat.o \ + deps/rcheevos/src/rcheevos/condition.o \ + deps/rcheevos/src/rcheevos/condset.o \ + deps/rcheevos/src/rcheevos/consoleinfo.o \ deps/rcheevos/src/rcheevos/format.o \ + deps/rcheevos/src/rcheevos/lboard.o \ deps/rcheevos/src/rcheevos/memref.o \ + deps/rcheevos/src/rcheevos/operand.o \ deps/rcheevos/src/rcheevos/richpresence.o \ + deps/rcheevos/src/rcheevos/runtime.o \ + deps/rcheevos/src/rcheevos/runtime_progress.o \ + deps/rcheevos/src/rcheevos/trigger.o \ + deps/rcheevos/src/rcheevos/value.o \ + deps/rcheevos/src/rhash/hash.o \ deps/rcheevos/src/rurl/url.o ifeq ($(HAVE_LUA), 1) diff --git a/cheevos-new/cheevos.c b/cheevos-new/cheevos.c index 5ea558f276..5ce829c547 100644 --- a/cheevos-new/cheevos.c +++ b/cheevos-new/cheevos.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include <../libretro-common/include/rhash.h> #include #include #include @@ -81,9 +81,6 @@ /* Define this macro to dump all cheevos' addresses. */ #undef CHEEVOS_DUMP_ADDRS -/* Define this macro to remove HTTP timeouts. */ -#undef CHEEVOS_NO_TIMEOUT - /* Define this macro to load a JSON file from disk instead of downloading * from retroachievements.org. */ #undef CHEEVOS_JSON_OVERRIDE @@ -92,7 +89,7 @@ * that name. */ #undef CHEEVOS_SAVE_JSON - /* Define this macro to log URLs. */ +/* Define this macro to log URLs. */ #undef CHEEVOS_LOG_URLS /* Define this macro to have the password and token logged. THIS WILL DISCLOSE @@ -311,69 +308,94 @@ static void rcheevos_get_user_agent(char* buffer) *ptr = '\0'; } -static void rcheevos_log_url(const char* format, const char* url) +#ifdef CHEEVOS_LOG_URLS +static void rcheevos_filter_url_param(char* url, char* param) +{ + char* start; + char* next; + size_t param_len = strlen(param); + + start = strchr(url, '?'); + if (!start) + start = url; + else + ++start; + + do + { + next = strchr(start, '&'); + + if (start[param_len] == '=' && memcmp(start, param, param_len) == 0) + { + if (next) + strcpy(start, next + 1); + else if (start > url) + start[-1] = '\0'; + else + *start = '\0'; + + return; + } + + if (!next) + return; + + start = next + 1; + } while (1); +} +#endif + +static void rcheevos_log_url(const char* api, const char* url) { #ifdef CHEEVOS_LOG_URLS -#ifdef CHEEVOS_LOG_PASSWORD - CHEEVOS_LOG(format, url); -#else + #ifdef CHEEVOS_LOG_PASSWORD + CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s\n", api, url); + #else char copy[256]; - char* aux = NULL; - char* next = NULL; - - if (!string_is_empty(url)) - strlcpy(copy, url, sizeof(copy)); - - aux = strstr(copy, "?p="); - - if (!aux) - aux = strstr(copy, "&p="); - - if (aux) - { - aux += 3; - next = strchr(aux, '&'); - - if (next) - { - do - { - *aux++ = *next++; - } while (next[-1] != 0); - } - else - *aux = 0; - } - - aux = strstr(copy, "?t="); - - if (!aux) - aux = strstr(copy, "&t="); - - if (aux) - { - aux += 3; - next = strchr(aux, '&'); - - if (next) - { - do - { - *aux++ = *next++; - } while (next[-1] != 0); - } - else - *aux = 0; - } - - CHEEVOS_LOG(format, copy); -#endif + strlcpy(copy, url, sizeof(copy)); + rcheevos_filter_url_param(copy, "p"); + rcheevos_filter_url_param(copy, "t"); + CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s\n", api, copy); + #endif #else - (void)format; + (void)api; (void)url; #endif } +static void rcheevos_log_post_url(const char* api, const char* url, const char* post) +{ +#ifdef CHEEVOS_LOG_URLS + #ifdef CHEEVOS_LOG_PASSWORD + if (post && post[0]) + CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s&%s\n", api, url, post); + else + CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s\n", api, url); + #else + if (post && post[0]) + { + char post_copy[2048]; + strlcpy(post_copy, post, sizeof(post_copy)); + rcheevos_filter_url_param(post_copy, "p"); + rcheevos_filter_url_param(post_copy, "t"); + + if (post_copy[0]) + CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s&%s\n", api, url, post_copy); + else + CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s\n", api, url); + } + else + { + CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s\n", api, url); + } + #endif +#else + (void)api; + (void)url; + (void)post; +#endif +} + static retro_time_t rcheevos_async_send_rich_presence(rcheevos_async_io_request* request); static void rcheevos_async_award_achievement(rcheevos_async_io_request* request); static void rcheevos_async_submit_lboard(rcheevos_async_io_request* request); @@ -442,39 +464,6 @@ static void rcheevos_async_task_callback(retro_task_t* task, void* task_data, vo } } -static const char* rcheevos_rc_error(int ret) -{ - switch (ret) - { - case RC_OK: return "Ok"; - case RC_INVALID_LUA_OPERAND: return "Invalid Lua operand"; - case RC_INVALID_MEMORY_OPERAND: return "Invalid memory operand"; - case RC_INVALID_CONST_OPERAND: return "Invalid constant operand"; - case RC_INVALID_FP_OPERAND: return "Invalid floating-point operand"; - case RC_INVALID_CONDITION_TYPE: return "Invalid condition type"; - case RC_INVALID_OPERATOR: return "Invalid operator"; - case RC_INVALID_REQUIRED_HITS: return "Invalid required hits"; - case RC_DUPLICATED_START: return "Duplicated start condition"; - case RC_DUPLICATED_CANCEL: return "Duplicated cancel condition"; - case RC_DUPLICATED_SUBMIT: return "Duplicated submit condition"; - case RC_DUPLICATED_VALUE: return "Duplicated value expression"; - case RC_DUPLICATED_PROGRESS: return "Duplicated progress expression"; - case RC_MISSING_START: return "Missing start condition"; - case RC_MISSING_CANCEL: return "Missing cancel condition"; - case RC_MISSING_SUBMIT: return "Missing submit condition"; - case RC_MISSING_VALUE: return "Missing value expression"; - case RC_INVALID_LBOARD_FIELD: return "Invalid field in leaderboard"; - case RC_MISSING_DISPLAY_STRING: return "Missing display string"; - case RC_OUT_OF_MEMORY: return "Out of memory"; - case RC_INVALID_VALUE_FLAG: return "Invalid flag in value expression"; - case RC_MISSING_VALUE_MEASURED: return "Missing measured flag in value expression"; - case RC_MULTIPLE_MEASURED: return "Multiple measured targets"; - case RC_INVALID_MEASURED_TARGET: return "Invalid measured target"; - - default: return "Unknown error"; - } -} - static int rcheevos_parse(const char* json) { char buffer[256]; @@ -604,7 +593,7 @@ static int rcheevos_parse(const char* json) if (res < 0) { snprintf(buffer, sizeof(buffer), "Error in achievement %d \"%s\": %s", - cheevo->info->id, cheevo->info->title, rcheevos_rc_error(res)); + cheevo->info->id, cheevo->info->title, rc_error_str(res)); if (settings->bools.cheevos_verbose_enable) runloop_msg_queue_push(buffer, 0, 4 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); @@ -641,7 +630,7 @@ static int rcheevos_parse(const char* json) if (res < 0) { snprintf(buffer, sizeof(buffer), "Error in leaderboard %d \"%s\": %s", - lboard->info->id, lboard->info->title, rcheevos_rc_error(res)); + lboard->info->id, lboard->info->title, rc_error_str(res)); if (settings->bools.cheevos_verbose_enable) runloop_msg_queue_push(buffer, 0, 4 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); @@ -671,7 +660,7 @@ static int rcheevos_parse(const char* json) int buffer_size = rc_richpresence_size(rcheevos_locals.patchdata.richpresence_script); if (buffer_size <= 0) { - snprintf(buffer, sizeof(buffer), "Error in rich presence: %s", rcheevos_rc_error(buffer_size)); + snprintf(buffer, sizeof(buffer), "Error in rich presence: %s", rc_error_str(buffer_size)); if (settings->bools.cheevos_verbose_enable) runloop_msg_queue_push(buffer, 0, 4 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); @@ -721,7 +710,7 @@ static void rcheevos_async_award_achievement(rcheevos_async_io_request* request) { char buffer[256]; settings_t *settings = config_get_ptr(); - int ret = rc_url_award_cheevo(buffer, sizeof(buffer), settings->arrays.cheevos_username, rcheevos_locals.token, request->id, request->hardcore); + int ret = rc_url_award_cheevo(buffer, sizeof(buffer), settings->arrays.cheevos_username, rcheevos_locals.token, request->id, request->hardcore, rcheevos_locals.hash); if (ret != 0) { @@ -730,7 +719,7 @@ static void rcheevos_async_award_achievement(rcheevos_async_io_request* request) return; } - rcheevos_log_url(RCHEEVOS_TAG "rc_url_award_cheevo: %s\n", buffer); + rcheevos_log_url("rc_url_award_cheevo", buffer); task_push_http_transfer_with_user_agent(buffer, true, NULL, request->user_agent, rcheevos_async_task_callback, request); } @@ -907,7 +896,7 @@ static void rcheevos_async_submit_lboard(rcheevos_async_io_request* request) char buffer[256]; settings_t *settings = config_get_ptr(); int ret = rc_url_submit_lboard(buffer, sizeof(buffer), settings->arrays.cheevos_username, - rcheevos_locals.token, request->id, request->value, rcheevos_locals.hash); + rcheevos_locals.token, request->id, request->value); if (ret != 0) { @@ -916,7 +905,7 @@ static void rcheevos_async_submit_lboard(rcheevos_async_io_request* request) return; } - rcheevos_log_url(RCHEEVOS_TAG "rc_url_submit_lboard: %s\n", buffer); + rcheevos_log_url("rc_url_submit_lboard", buffer); task_push_http_transfer_with_user_agent(buffer, true, NULL, request->user_agent, rcheevos_async_task_callback, request); } @@ -971,39 +960,33 @@ static void rcheevos_test_leaderboards(void) switch (rc_evaluate_lboard(lboard->lboard, &lboard->last_value, rcheevos_peek, NULL, NULL)) { default: - case RC_LBOARD_INACTIVE: break; - case RC_LBOARD_ACTIVE: - /* this is where we would update the onscreen tracker */ - break; - - case RC_LBOARD_TRIGGERED: + case RC_LBOARD_STATE_TRIGGERED: rcheevos_lboard_submit(lboard); break; - case RC_LBOARD_CANCELED: - { + case RC_LBOARD_STATE_CANCELED: CHEEVOS_LOG(RCHEEVOS_TAG "Cancel leaderboard %s\n", lboard->info->title); lboard->active = 0; runloop_msg_queue_push("Leaderboard attempt cancelled!", 0, 2 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); break; - } - case RC_LBOARD_STARTED: - { - char buffer[256]; + case RC_LBOARD_STATE_STARTED: + if (!lboard->active) + { + char buffer[256]; - CHEEVOS_LOG(RCHEEVOS_TAG "Leaderboard started: %s\n", lboard->info->title); - lboard->active = 1; + CHEEVOS_LOG(RCHEEVOS_TAG "Leaderboard started: %s\n", lboard->info->title); + lboard->active = 1; - snprintf(buffer, sizeof(buffer), - "Leaderboard Active: %s", lboard->info->title); - runloop_msg_queue_push(buffer, 0, 2 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); - runloop_msg_queue_push(lboard->info->description, 0, 3 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + snprintf(buffer, sizeof(buffer), + "Leaderboard Active: %s", lboard->info->title); + runloop_msg_queue_push(buffer, 0, 2 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + runloop_msg_queue_push(lboard->info->description, 0, 3 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + } break; - } } if (rcheevos_locals.invalid_peek_address) @@ -1046,30 +1029,31 @@ static retro_time_t rcheevos_async_send_rich_presence(rcheevos_async_io_request* { char url[256], post_data[1024]; + int ret = rc_url_ping(url, sizeof(url), post_data, sizeof(post_data), + cheevos_username, rcheevos_locals.token, rcheevos_locals.patchdata.game_id, + rcheevos_locals.richpresence.evaluation); - snprintf(url, sizeof(url), - "http://retroachievements.org/dorequest.php?r=ping&u=%s&t=%s", - cheevos_username, rcheevos_locals.token); - - if (rcheevos_locals.richpresence.evaluation[0]) + if (ret < 0) { - char* tmp = NULL; - net_http_urlencode(&tmp, rcheevos_locals.richpresence.evaluation); - snprintf(post_data, sizeof(post_data), "g=%u&m=%s", rcheevos_locals.patchdata.game_id, tmp); - CHEEVOS_FREE(tmp); - -#ifdef HAVE_DISCORD - if (settings->bools.discord_enable) - discord_update(DISCORD_PRESENCE_RETROACHIEVEMENTS, false); -#endif + CHEEVOS_ERR(RCHEEVOS_TAG "buffer too small to create URL\n"); } else - snprintf(post_data, sizeof(post_data), "g=%u", rcheevos_locals.patchdata.game_id); + { + rcheevos_log_post_url("rc_url_ping", url, post_data); - rcheevos_get_user_agent(request->user_agent); - task_push_http_post_transfer_with_user_agent(url, post_data, true, "POST", request->user_agent, NULL, NULL); + rcheevos_get_user_agent(request->user_agent); + task_push_http_post_transfer_with_user_agent(url, post_data, true, "POST", request->user_agent, NULL, NULL); + } } +#ifdef HAVE_DISCORD + if (rcheevos_locals.richpresence.evaluation[0]) + { + if (settings->bools.discord_enable) + discord_update(DISCORD_PRESENCE_RETROACHIEVEMENTS, false); + } +#endif + /* Update rich presence every two minutes */ if (settings->bools.cheevos_richpresence_enable) return cpu_features_get_time_usec() + CHEEVOS_PING_FREQUENCY; @@ -1109,15 +1093,7 @@ void rcheevos_reset_game(void) rc_reset_lboard(lboard->lboard); if (lboard->active) - { lboard->active = 0; - - /* This ensures the leaderboard won't restart - * until the start trigger is false for at - * least one frame */ - if (lboard->lboard) - lboard->lboard->submitted = 1; - } } rcheevos_locals.richpresence.last_update = cpu_features_get_time_usec(); @@ -2463,14 +2439,6 @@ found: } memcpy(coro->last_hash, coro->hash, sizeof(coro->hash)); - size = rc_url_get_gameid(coro->url, sizeof(coro->url), coro->hash); - - if (size < 0) - { - CHEEVOS_ERR(RCHEEVOS_TAG "buffer too small to create URL\n"); - CORO_RET(); - } - sprintf(rcheevos_locals.hash, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", coro->hash[0], coro->hash[1], coro->hash[2], coro->hash[3], coro->hash[4], coro->hash[5], coro->hash[6], coro->hash[7], @@ -2478,7 +2446,16 @@ found: coro->hash[12], coro->hash[13], coro->hash[14], coro->hash[15]); CHEEVOS_LOG(RCHEEVOS_TAG "checking %s\n", rcheevos_locals.hash); - rcheevos_log_url(RCHEEVOS_TAG "rc_url_get_gameid: %s\n", coro->url); + + size = rc_url_get_gameid(coro->url, sizeof(coro->url), rcheevos_locals.hash); + + if (size < 0) + { + CHEEVOS_ERR(RCHEEVOS_TAG "buffer too small to create URL\n"); + CORO_RET(); + } + + rcheevos_log_url("rc_url_get_gameid", coro->url); CORO_GOSUB(RCHEEVOS_HTTP_GET); if (!coro->json) @@ -2511,7 +2488,7 @@ found: CORO_STOP(); } - rcheevos_log_url(RCHEEVOS_TAG "rc_url_get_patch: %s\n", coro->url); + rcheevos_log_url("rc_url_get_patch", coro->url); CORO_GOSUB(RCHEEVOS_HTTP_GET); if (!coro->json) @@ -2651,21 +2628,36 @@ found: } if (string_is_empty(coro->settings->arrays.cheevos_token)) + { ret = rc_url_login_with_password(coro->url, sizeof(coro->url), coro->settings->arrays.cheevos_username, coro->settings->arrays.cheevos_password); + + if (ret == RC_OK) + { + CHEEVOS_LOG(RCHEEVOS_TAG "attempting to login %s (with password)\n", coro->settings->arrays.cheevos_username); + rcheevos_log_url("rc_url_login_with_password", coro->url); + } + } else + { ret = rc_url_login_with_token(coro->url, sizeof(coro->url), coro->settings->arrays.cheevos_username, coro->settings->arrays.cheevos_token); + if (ret == RC_OK) + { + CHEEVOS_LOG(RCHEEVOS_TAG "attempting to login %s (with token)\n", coro->settings->arrays.cheevos_username); + rcheevos_log_url("rc_url_login_with_token", coro->url); + } + } + if (ret < 0) { CHEEVOS_ERR(RCHEEVOS_TAG "buffer too small to create URL\n"); CORO_STOP(); } - rcheevos_log_url(RCHEEVOS_TAG "rc_url_login_with_password: %s\n", coro->url); CORO_GOSUB(RCHEEVOS_HTTP_GET); if (!coro->json) @@ -2686,6 +2678,7 @@ found: tok); runloop_msg_queue_push(msg, 0, 5 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); *coro->settings->arrays.cheevos_token = 0; + CHEEVOS_ERR(RCHEEVOS_TAG "login error: %s\n", tok); CHEEVOS_FREE(coro->json); CORO_STOP(); @@ -2703,6 +2696,7 @@ found: runloop_msg_queue_push(msg, 0, 3 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); } + CHEEVOS_LOG(RCHEEVOS_TAG "logged in successfully\n"); strlcpy(rcheevos_locals.token, tok, sizeof(rcheevos_locals.token)); @@ -2838,7 +2832,7 @@ found: CORO_STOP(); } - rcheevos_log_url(RCHEEVOS_TAG "rc_url_get_unlock_list: %s\n", coro->url); + rcheevos_log_url("rc_url_get_unlock_list", coro->url); CORO_GOSUB(RCHEEVOS_HTTP_GET); if (coro->json) @@ -2862,15 +2856,19 @@ found: *************************************************************************/ CORO_SUB(RCHEEVOS_PLAYING) - snprintf( - coro->url, sizeof(coro->url), - "http://retroachievements.org/dorequest.php?r=postactivity&u=%s&t=%s&a=3&m=%u", + { + int ret = rc_url_post_playing(coro->url, sizeof(coro->url), coro->settings->arrays.cheevos_username, - rcheevos_locals.token, coro->gameid - ); + rcheevos_locals.token, coro->gameid); - coro->url[sizeof(coro->url) - 1] = 0; - rcheevos_log_url(RCHEEVOS_TAG "url to post the 'playing' activity: %s\n", coro->url); + if (ret < 0) + { + CHEEVOS_ERR(RCHEEVOS_TAG "buffer too small to create URL\n"); + CORO_STOP(); + } + } + + rcheevos_log_url("rc_url_post_playing", coro->url); CORO_GOSUB(RCHEEVOS_HTTP_GET); diff --git a/cheevos-new/fixup.c b/cheevos-new/fixup.c index 29783424f3..1a199caf2f 100644 --- a/cheevos-new/fixup.c +++ b/cheevos-new/fixup.c @@ -21,6 +21,7 @@ #include "../core.h" #include "../deps/rcheevos/include/rcheevos.h" +#include "../deps/rcheevos/include/rconsoles.h" static int rcheevos_cmpaddr(const void* e1, const void* e2) { diff --git a/deps/rcheevos/CHANGELOG.md b/deps/rcheevos/CHANGELOG.md index 8d5a48ea9e..2146f17700 100644 --- a/deps/rcheevos/CHANGELOG.md +++ b/deps/rcheevos/CHANGELOG.md @@ -1,3 +1,52 @@ +# v9.0.0 + +* new size: RC_MEMSIZE_BITCOUNT +* new flag: RC_CONDITION_OR_NEXT +* new flag: RC_CONDITION_TRIGGER +* new flag: RC_CONDITION_MEASURED_IF +* new operators: RC_OPERATOR_MULT / RC_OPERATOR_DIV +* is_bcd removed from memref - now part of RC_MEMSIZE +* add rc_runtime_t and associated functions +* add rc_hash_ functions +* add rc_error_str function +* add game_hash parameter to rc_url_award_cheevo +* remove hash parameter from rc_url_submit_lboard +* add rc_url_ping function +* add rc_console_ functions + +# v8.1.0 + +* new flag: RC_CONDITION_MEASURED +* new flag: RC_CONDITION_ADD_ADDRESS +* add rc_evaluate_trigger - extended version of rc_test_trigger with more granular return codes +* make rc_evaluate_value return a signed int (was unsigned int) +* new formats: RC_FORMAT_MINUTES and RC_FORMAT_SECONDS_AS_MINUTES +* removed " Points" text from RC_FORMAT_SCORE format +* removed RC_FORMAT_OTHER format. "OTHER" format now parses to RC_FORMAT_SCORE +* bugfix: AddHits will now honor AndNext on previous condition + +# v8.0.1 + +* bugfix: prevent null reference exception if rich presence contains condition without display string +* bugfix: 24-bit read from memory should only read 24-bits + +# v8.0.0 + +* support for prior operand type +* support for AndNext condition flag +* support for rich presence +* bugfix: update delta/prior memory values while group is paused +* bugfix: allow floating point number without leading 0 +* bugfix: support empty alt groups + +# v7.1.1 + +* Address signed/unsigned mismatch warnings + +# v7.1.0 + +* Added the RC_DISABLE_LUA macro to compile rcheevos without Lua support + # v7.0.2 * Make sure the code is C89-compliant diff --git a/deps/rcheevos/README.md b/deps/rcheevos/README.md index d9738e5312..f45f2f7c53 100644 --- a/deps/rcheevos/README.md +++ b/deps/rcheevos/README.md @@ -59,10 +59,16 @@ enum { RC_INVALID_VALUE_FLAG = -20, RC_MISSING_VALUE_MEASURED = -21, RC_MULTIPLE_MEASURED = -22, - RC_INVALID_MEASURED_TARGET = -23 + RC_INVALID_MEASURED_TARGET = -23, + RC_INVALID_COMPARISON = -24 }; ``` +To convert the return code into something human-readable, pass it to: +```c +const char* rc_error_str(int ret); +``` + ### Console identifiers This enumeration uniquely identifies each of the supported platforms in RetroAchievements. @@ -92,14 +98,38 @@ enum { RC_CONSOLE_PLAYSTATION_2 = 21, RC_CONSOLE_XBOX = 22, RC_CONSOLE_SKYNET = 23, - RC_CONSOLE_XBOX_ONE = 24, + RC_CONSOLE_POKEMON_MINI = 24, RC_CONSOLE_ATARI_2600 = 25, RC_CONSOLE_MS_DOS = 26, RC_CONSOLE_ARCADE = 27, RC_CONSOLE_VIRTUAL_BOY = 28, RC_CONSOLE_MSX = 29, RC_CONSOLE_COMMODORE_64 = 30, - RC_CONSOLE_ZX81 = 31 + RC_CONSOLE_ZX81 = 31, + RC_CONSOLE_ORIC = 32, + RC_CONSOLE_SG1000 = 33, + RC_CONSOLE_VIC20 = 34, + RC_CONSOLE_AMIGA = 35, + RC_CONSOLE_AMIGA_ST = 36, + RC_CONSOLE_AMSTRAD_PC = 37, + RC_CONSOLE_APPLE_II = 38, + RC_CONSOLE_SATURN = 39, + RC_CONSOLE_DREAMCAST = 40, + RC_CONSOLE_PSP = 41, + RC_CONSOLE_CDI = 42, + RC_CONSOLE_3DO = 43, + RC_CONSOLE_COLECOVISION = 44, + RC_CONSOLE_INTELLIVISION = 45, + RC_CONSOLE_VECTREX = 46, + RC_CONSOLE_PC8800 = 47, + RC_CONSOLE_PC9800 = 48, + RC_CONSOLE_PCFX = 49, + RC_CONSOLE_ATARI_5200 = 50, + RC_CONSOLE_ATARI_7800 = 51, + RC_CONSOLE_X68K = 52, + RC_CONSOLE_WONDERSWAN = 53, + RC_CONSOLE_CASSETTEVISION = 54, + RC_CONSOLE_SUPER_CASSETTEVISION = 55 }; ``` @@ -115,27 +145,23 @@ An operand is the leaf node of RetroAchievements expressions, and can hold one o typedef struct { union { /* A value read from memory. */ - struct { - /* The memory address or constant value of this variable. */ - unsigned value; - /* The previous memory contents if RC_OPERAND_DELTA. */ - unsigned previous; + rc_memref_value_t* memref; - /* The size of the variable. */ - char size; - /* True if the value is in BCD. */ - char is_bcd; - /* The type of the variable. */ - }; + /* An integer value. */ + unsigned num; /* A floating point value. */ - double fp_value; + double dbl; /* A reference to the Lua function that provides the value. */ - int function_ref; + int luafunc; }; + /* specifies which member of the value union is being used */ char type; + + /* the actual RC_MEMSIZE of the operand - memref.size may differ */ + char size; } rc_operand_t; ``` @@ -144,20 +170,21 @@ The `size` field, when applicable, holds one of these values: ```c enum { - RC_OPERAND_BIT_0, - RC_OPERAND_BIT_1, - RC_OPERAND_BIT_2, - RC_OPERAND_BIT_3, - RC_OPERAND_BIT_4, - RC_OPERAND_BIT_5, - RC_OPERAND_BIT_6, - RC_OPERAND_BIT_7, - RC_OPERAND_LOW, - RC_OPERAND_HIGH, - RC_OPERAND_8_BITS, - RC_OPERAND_16_BITS, - RC_OPERAND_24_BITS, - RC_OPERAND_32_BITS, + RC_MEMSIZE_8_BITS, + RC_MEMSIZE_16_BITS, + RC_MEMSIZE_24_BITS, + RC_MEMSIZE_32_BITS, + RC_MEMSIZE_LOW, + RC_MEMSIZE_HIGH, + RC_MEMSIZE_BIT_0, + RC_MEMSIZE_BIT_1, + RC_MEMSIZE_BIT_2, + RC_MEMSIZE_BIT_3, + RC_MEMSIZE_BIT_4, + RC_MEMSIZE_BIT_5, + RC_MEMSIZE_BIT_6, + RC_MEMSIZE_BIT_7, + RC_MEMSIZE_BITCOUNT }; ``` @@ -165,15 +192,18 @@ The `type` field is always valid, and holds one of these values: ```c enum { - RC_OPERAND_ADDRESS, /* Compare to the value of a live address in RAM. */ - RC_OPERAND_DELTA, /* The value last known at this address. */ - RC_OPERAND_CONST, /* A 32-bit unsigned integer. */ - RC_OPERAND_FP, /* A floating point value. */ - RC_OPERAND_LUA /* A Lua function that provides the value. */ + RC_OPERAND_ADDRESS, /* The value of a live address in RAM. */ + RC_OPERAND_DELTA, /* The value last known at this address. */ + RC_OPERAND_CONST, /* A 32-bit unsigned integer. */ + RC_OPERAND_FP, /* A floating point value. */ + RC_OPERAND_LUA, /* A Lua function that provides the value. */ + RC_OPERAND_PRIOR, /* The last differing value at this address. */ + RC_OPERAND_BCD, /* The BCD-decoded value of a live address in RAM */ + RC_OPERAND_INVERTED /* The twos-complement value of a live address in RAM */ }; ``` -`RC_OPERAND_ADDRESS`, `RC_OPERAND_DELTA` and `RC_OPERAND_CONST` mean that the anonymous structure in the union is active. `RC_OPERAND_FP` means that `fp_value` is active. `RC_OPERAND_LUA` means `function_ref` is active. +`RC_OPERAND_ADDRESS`, `RC_OPERAND_DELTA`, `RC_OPERAND_PRIOR`, `RC_OPERAND_BCD`, and `RC_OPERAND_INVERTED` mean that `memref` is active. `RC_OPERAND_CONST` means that `num` is active. `RC_OPERAND_FP` means that `dbl` is active. `RC_OPERAND_LUA` means `luafunc` is active. ### `rc_condition_t` @@ -184,9 +214,6 @@ A condition compares its two operands according to the defined operator. It also typedef struct rc_condition_t rc_condition_t; struct rc_condition_t { - /* The next condition in the chain. */ - rc_condition_t* next; - /* The condition's operands. */ rc_operand_t operand1; rc_operand_t operand2; @@ -196,6 +223,9 @@ struct rc_condition_t { /* Number of hits so far. */ unsigned current_hits; + /* The next condition in the chain. */ + rc_condition_t* next; + /* The type of the condition. */ char type; /* The comparison operator to use. */ @@ -219,7 +249,9 @@ enum { RC_CONDITION_ADD_HITS, RC_CONDITION_AND_NEXT, RC_CONDITION_MEASURED, - RC_CONDITION_ADD_ADDRESS + RC_CONDITION_ADD_ADDRESS, + RC_CONDITION_TRIGGER, + RC_CONDITION_MEASURED_IF }; ``` @@ -227,13 +259,16 @@ enum { ```c enum { - RC_CONDITION_EQ, - RC_CONDITION_LT, - RC_CONDITION_LE, - RC_CONDITION_GT, - RC_CONDITION_GE, - RC_CONDITION_NE, - RC_CONDITION_NONE + RC_OPERATOR_EQ, + RC_OPERATOR_LT, + RC_OPERATOR_LE, + RC_OPERATOR_GT, + RC_OPERATOR_GE, + RC_OPERATOR_NE, + RC_OPERATOR_NONE, + RC_OPERATOR_MULT, + RC_OPERATOR_DIV, + RC_OPERATOR_AND }; ``` @@ -267,6 +302,9 @@ typedef struct { /* The list of sub condition sets in this test. */ rc_condset_t* alternative; + + /* The memory references required by the trigger. */ + rc_memref_value_t* memrefs; } rc_trigger_t; ``` @@ -313,7 +351,8 @@ enum { RC_TRIGGER_STATE_ACTIVE, /* achievement is active and may trigger */ RC_TRIGGER_STATE_PAUSED, /* achievement is currently paused and will not trigger */ RC_TRIGGER_STATE_RESET, /* achievement hit counts were reset */ - RC_TRIGGER_STATE_TRIGGERED /* achievement has triggered */ + RC_TRIGGER_STATE_TRIGGERED, /* achievement has triggered */ + RC_TRIGGER_STATE_PRIMED /* all non-Trigger conditions are true */ }; ``` @@ -323,52 +362,12 @@ Finally, `rc_reset_trigger` can be used to reset the internal state of a trigger void rc_reset_trigger(rc_trigger_t* self); ``` -### `rc_term_t` - -A term is the leaf node of expressions used to compute values from operands. A term is evaluated by multiplying its two operands. `invert` is used to invert the bits of the second operand of the term, when the unary operator `~` is used. - -```c -typedef struct rc_term_t rc_term_t; - -struct rc_term_t { - /* The next term in this chain. */ - rc_term_t* next; - - /* The first operand. */ - rc_operand_t operand1; - /* The second operand. */ - rc_operand_t operand2; - - /* A value that is applied to the second variable to invert its bits. */ - unsigned invert; -}; -``` - -### `rc_expression_t` - -An expression is a collection of terms. All terms in the collection are added together to give the value of the expression. - -```c -typedef struct rc_expression_t rc_expression_t; - -struct rc_expression_t { - /* The next expression in this chain. */ - rc_expression_t* next; - - /* The list of terms in this expression. */ - rc_term_t* terms; -}; -``` - ### `rc_value_t` -A value is a collection of expressions. It's used to give the value for a leaderboard, and it evaluates to value of the expression with the greatest value in the collection. +A value is a collection of conditions that result in a single RC_CONDITION_MEASURED expression. It's used to calculate the value for a leaderboard and for lookups in rich presence. ```c typedef struct { - /* The list of expression to evaluate. */ - rc_expression_t* expressions; - /* The list of conditions to evaluate. */ rc_condset_t* conditions; @@ -413,9 +412,9 @@ typedef struct { rc_trigger_t cancel; rc_value_t value; rc_value_t* progress; + rc_memref_value_t* memrefs; - char started; - char submitted; + char state; } rc_lboard_t; ``` @@ -437,11 +436,12 @@ The function returns an action that must be performed by the caller, and `value` ```c enum { - RC_LBOARD_INACTIVE, - RC_LBOARD_ACTIVE, - RC_LBOARD_STARTED, - RC_LBOARD_CANCELED, - RC_LBOARD_TRIGGERED + RC_LBOARD_STATE_INACTIVE, /* leaderboard is not being processed */ + RC_LBOARD_STATE_WAITING, /* leaderboard cannot activate until the start condition has been false for at least one frame */ + RC_LBOARD_STATE_ACTIVE, /* leaderboard is active and may start */ + RC_LBOARD_STATE_STARTED, /* leaderboard attempt in progress */ + RC_LBOARD_STATE_CANCELED, /* leaderboard attempt canceled */ + RC_LBOARD_STATE_TRIGGERED /* leaderboard attempt complete, value should be submitted */ }; ``` @@ -458,6 +458,101 @@ The caller must keep track of these values and do the necessary actions: void rc_reset_lboard(rc_lboard_t* lboard); ``` +### `rc_runtime_t` + +The runtime encapsulates a set of achievements and leaderboards and manages processing them for each frame. When important things occur, events are raised for the caller via a callback. + +```c +typedef struct rc_runtime_t { + rc_runtime_trigger_t* triggers; + unsigned trigger_count; + unsigned trigger_capacity; + + rc_runtime_lboard_t* lboards; + unsigned lboard_count; + unsigned lboard_capacity; + + rc_runtime_richpresence_t* richpresence; + char* richpresence_display_buffer; + char richpresence_update_timer; + + rc_memref_value_t* memrefs; + rc_memref_value_t** next_memref; +} +rc_runtime_t; +``` + +The runtime must first be initialized. +```c +void rc_runtime_init(rc_runtime_t* runtime); +``` + +Then individual achievements, leaderboards, and even rich presence can be loaded into the runtime. These functions return RC_OK, or one of the negative value error codes listed above. +```c +int rc_runtime_activate_achievement(rc_runtime_t* runtime, unsigned id, const char* memaddr, lua_State* L, int funcs_idx); +int rc_runtime_activate_lboard(rc_runtime_t* runtime, unsigned id, const char* memaddr, lua_State* L, int funcs_idx); +int rc_runtime_activate_richpresence(rc_runtime_t* runtime, const char* script, lua_State* L, int funcs_idx); +``` + +The runtime should be called once per frame to evaluate the state of the active achievements/leaderboards: +```c +void rc_runtime_do_frame(rc_runtime_t* runtime, rc_runtime_event_handler_t event_handler, rc_peek_t peek, void* ud, lua_State* L); +``` + +The `event_handler` is a callback function that is called for each event that occurs when processing the frame. +```c +typedef struct rc_runtime_event_t { + unsigned id; + int value; + char type; +} +rc_runtime_event_t; + +typedef void (*rc_runtime_event_handler_t)(const rc_runtime_event_t* runtime_event); +``` + +The `event.type` field will be one of the following: +* RC_RUNTIME_EVENT_ACHIEVEMENT_ACTIVATED (id=achievement id) + An achievement starts in the RC_TRIGGER_STATE_WAITING state and cannot trigger until it has been false for at least one frame. This event indicates the achievement is no longer waiting and may trigger on a future frame. +* RC_RUNTIME_EVENT_ACHIEVEMENT_PAUSED (id=achievement id) + One or more conditions in the achievement have disabled the achievement. +* RC_RUNTIME_EVENT_ACHIEVEMENT_RESET (id=achievement id) + One or more conditions in the achievement have reset any progress captured in the achievement. +* RC_RUNTIME_EVENT_ACHIEVEMENT_TRIGGERED (id=achievement id) + All conditions for the achievement have been met and the user should be informed. + NOTE: If `rc_runtime_reset` is called without deactivating the achievement, it may trigger again. +* RC_RUNTIME_EVENT_ACHIEVEMENT_PRIMED (id=achievement id) + All non-trigger conditions for the achievement have been met. This typically indicates the achievement is a challenge achievement and the challenge is active. +* RC_RUNTIME_EVENT_LBOARD_STARTED (id=leaderboard id, value=leaderboard value) + The leaderboard's start condition has been met and the user should be informed that a leaderboard attempt has started. +* RC_RUNTIME_EVENT_LBOARD_CANCELED (id=leaderboard id, value=leaderboard value) + The leaderboard's cancel condition has been met and the user should be informed that a leaderboard attempt has failed. +* RC_RUNTIME_EVENT_LBOARD_UPDATED (id=leaderboard id, value=leaderboard value) + The leaderboard value has changed. +* RC_RUNTIME_EVENT_LBOARD_TRIGGERED (id=leaderboard id, value=leaderboard value) + The leaderboard's submit condition has been met and the user should be informed that a leaderboard attempt was successful. The value should be submitted. + +When an achievement triggers, it should be deactivated so it won't trigger again: +```c +void rc_runtime_deactivate_achievement(rc_runtime_t* runtime, unsigned id); +``` +Additionally, the unlock should be submitted to the server. + +When a leaderboard triggers, it should not be deactivated in case the player wants to try again for a better score. The value should be submitted to the server. + +`rc_runtime_do_frame` also periodically updates the rich presense string (every 60 frames). To get the current value, call +```c +const char* rc_runtime_get_richpresence(const rc_runtime_t* runtime); +``` + +When the game is reset, the runtime should also be reset: +```c +void rc_runtime_reset(rc_runtime_t* runtime); +``` + +This ensures any active achievements/leaderboards are set back to their initial states and prevents unexpected triggers when the memory changes in atypical way. + + ### Value Formatting **rcheevos** includes helper functions to parse formatting strings from RetroAchievements, and format values according to them. diff --git a/deps/rcheevos/include/rcheevos.h b/deps/rcheevos/include/rcheevos.h index 467771464b..2ff0289750 100644 --- a/deps/rcheevos/include/rcheevos.h +++ b/deps/rcheevos/include/rcheevos.h @@ -35,46 +35,12 @@ enum { RC_INVALID_VALUE_FLAG = -20, RC_MISSING_VALUE_MEASURED = -21, RC_MULTIPLE_MEASURED = -22, - RC_INVALID_MEASURED_TARGET = -23 + RC_INVALID_MEASURED_TARGET = -23, + RC_INVALID_COMPARISON = -24, + RC_INVALID_STATE = -25 }; -/*****************************************************************************\ -| Console identifiers | -\*****************************************************************************/ - -enum { - RC_CONSOLE_MEGA_DRIVE = 1, - RC_CONSOLE_NINTENDO_64 = 2, - RC_CONSOLE_SUPER_NINTENDO = 3, - RC_CONSOLE_GAMEBOY = 4, - RC_CONSOLE_GAMEBOY_ADVANCE = 5, - RC_CONSOLE_GAMEBOY_COLOR = 6, - RC_CONSOLE_NINTENDO = 7, - RC_CONSOLE_PC_ENGINE = 8, - RC_CONSOLE_SEGA_CD = 9, - RC_CONSOLE_SEGA_32X = 10, - RC_CONSOLE_MASTER_SYSTEM = 11, - RC_CONSOLE_PLAYSTATION = 12, - RC_CONSOLE_ATARI_LYNX = 13, - RC_CONSOLE_NEOGEO_POCKET = 14, - RC_CONSOLE_GAME_GEAR = 15, - RC_CONSOLE_GAMECUBE = 16, - RC_CONSOLE_ATARI_JAGUAR = 17, - RC_CONSOLE_NINTENDO_DS = 18, - RC_CONSOLE_WII = 19, - RC_CONSOLE_WII_U = 20, - RC_CONSOLE_PLAYSTATION_2 = 21, - RC_CONSOLE_XBOX = 22, - RC_CONSOLE_SKYNET = 23, - RC_CONSOLE_XBOX_ONE = 24, - RC_CONSOLE_ATARI_2600 = 25, - RC_CONSOLE_MS_DOS = 26, - RC_CONSOLE_ARCADE = 27, - RC_CONSOLE_VIRTUAL_BOY = 28, - RC_CONSOLE_MSX = 29, - RC_CONSOLE_COMMODORE_64 = 30, - RC_CONSOLE_ZX81 = 31 -}; +const char* rc_error_str(int ret); /*****************************************************************************\ | Callbacks | @@ -93,6 +59,12 @@ typedef unsigned (*rc_peek_t)(unsigned address, unsigned num_bytes, void* ud); /* Sizes. */ enum { + RC_MEMSIZE_8_BITS, + RC_MEMSIZE_16_BITS, + RC_MEMSIZE_24_BITS, + RC_MEMSIZE_32_BITS, + RC_MEMSIZE_LOW, + RC_MEMSIZE_HIGH, RC_MEMSIZE_BIT_0, RC_MEMSIZE_BIT_1, RC_MEMSIZE_BIT_2, @@ -101,12 +73,7 @@ enum { RC_MEMSIZE_BIT_5, RC_MEMSIZE_BIT_6, RC_MEMSIZE_BIT_7, - RC_MEMSIZE_LOW, - RC_MEMSIZE_HIGH, - RC_MEMSIZE_8_BITS, - RC_MEMSIZE_16_BITS, - RC_MEMSIZE_24_BITS, - RC_MEMSIZE_32_BITS + RC_MEMSIZE_BITCOUNT }; typedef struct { @@ -114,8 +81,6 @@ typedef struct { unsigned address; /* The size of the variable. */ char size; - /* True if the value is in BCD. */ - char is_bcd; /* True if the reference will be used in indirection */ char is_indirect; } rc_memref_t; @@ -143,12 +108,14 @@ struct rc_memref_value_t { /* types */ enum { - RC_OPERAND_ADDRESS, /* Compare to the value of a live address in RAM. */ - RC_OPERAND_DELTA, /* The value last known at this address. */ - RC_OPERAND_CONST, /* A 32-bit unsigned integer. */ - RC_OPERAND_FP, /* A floating point value. */ - RC_OPERAND_LUA, /* A Lua function that provides the value. */ - RC_OPERAND_PRIOR /* The last differing value at this address. */ + RC_OPERAND_ADDRESS, /* The value of a live address in RAM. */ + RC_OPERAND_DELTA, /* The value last known at this address. */ + RC_OPERAND_CONST, /* A 32-bit unsigned integer. */ + RC_OPERAND_FP, /* A floating point value. */ + RC_OPERAND_LUA, /* A Lua function that provides the value. */ + RC_OPERAND_PRIOR, /* The last differing value at this address. */ + RC_OPERAND_BCD, /* The BCD-decoded value of a live address in RAM */ + RC_OPERAND_INVERTED /* The twos-complement value of a live address in RAM */ }; typedef struct { @@ -166,7 +133,11 @@ typedef struct { int luafunc; } value; + /* specifies which member of the value union is being used */ char type; + + /* the actual RC_MEMSIZE of the operand - memref.size may differ */ + char size; } rc_operand_t; @@ -184,18 +155,24 @@ enum { RC_CONDITION_ADD_HITS, RC_CONDITION_AND_NEXT, RC_CONDITION_MEASURED, - RC_CONDITION_ADD_ADDRESS + RC_CONDITION_ADD_ADDRESS, + RC_CONDITION_OR_NEXT, + RC_CONDITION_TRIGGER, + RC_CONDITION_MEASURED_IF }; /* operators */ enum { - RC_CONDITION_EQ, - RC_CONDITION_LT, - RC_CONDITION_LE, - RC_CONDITION_GT, - RC_CONDITION_GE, - RC_CONDITION_NE, - RC_CONDITION_NONE + RC_OPERATOR_EQ, + RC_OPERATOR_LT, + RC_OPERATOR_LE, + RC_OPERATOR_GT, + RC_OPERATOR_GE, + RC_OPERATOR_NE, + RC_OPERATOR_NONE, + RC_OPERATOR_MULT, + RC_OPERATOR_DIV, + RC_OPERATOR_AND }; typedef struct rc_condition_t rc_condition_t; @@ -256,7 +233,8 @@ enum { RC_TRIGGER_STATE_ACTIVE, /* achievement is active and may trigger */ RC_TRIGGER_STATE_PAUSED, /* achievement is currently paused and will not trigger */ RC_TRIGGER_STATE_RESET, /* achievement hit counts were reset */ - RC_TRIGGER_STATE_TRIGGERED /* achievement has triggered */ + RC_TRIGGER_STATE_TRIGGERED, /* achievement has triggered */ + RC_TRIGGER_STATE_PRIMED /* all non-Trigger conditions are true */ }; typedef struct { @@ -290,38 +268,10 @@ int rc_test_trigger(rc_trigger_t* trigger, rc_peek_t peek, void* ud, lua_State* void rc_reset_trigger(rc_trigger_t* self); /*****************************************************************************\ -| Expressions and values | +| Values | \*****************************************************************************/ -typedef struct rc_term_t rc_term_t; - -struct rc_term_t { - /* The next term in this chain. */ - rc_term_t* next; - - /* The first operand. */ - rc_operand_t operand1; - /* The second operand. */ - rc_operand_t operand2; - - /* A value that is applied to the second variable to invert its bits. */ - unsigned invert; -}; - -typedef struct rc_expression_t rc_expression_t; - -struct rc_expression_t { - /* The next expression in this chain. */ - rc_expression_t* next; - - /* The list of terms in this expression. */ - rc_term_t* terms; -}; - typedef struct { - /* The list of expression to evaluate. */ - rc_expression_t* expressions; - /* The list of conditions to evaluate. */ rc_condset_t* conditions; @@ -340,11 +290,12 @@ int rc_evaluate_value(rc_value_t* value, rc_peek_t peek, void* ud, lua_State* L) /* Return values for rc_evaluate_lboard. */ enum { - RC_LBOARD_INACTIVE, - RC_LBOARD_ACTIVE, - RC_LBOARD_STARTED, - RC_LBOARD_CANCELED, - RC_LBOARD_TRIGGERED + RC_LBOARD_STATE_INACTIVE, /* leaderboard is not being processed */ + RC_LBOARD_STATE_WAITING, /* leaderboard cannot activate until the start condition has been false for at least one frame */ + RC_LBOARD_STATE_ACTIVE, /* leaderboard is active and may start */ + RC_LBOARD_STATE_STARTED, /* leaderboard attempt in progress */ + RC_LBOARD_STATE_CANCELED, /* leaderboard attempt canceled */ + RC_LBOARD_STATE_TRIGGERED /* leaderboard attempt complete, value should be submitted */ }; typedef struct { @@ -355,8 +306,7 @@ typedef struct { rc_value_t* progress; rc_memref_value_t* memrefs; - char started; - char submitted; + char state; } rc_lboard_t; @@ -433,6 +383,128 @@ int rc_richpresence_size(const char* script); rc_richpresence_t* rc_parse_richpresence(void* buffer, const char* script, lua_State* L, int funcs_ndx); int rc_evaluate_richpresence(rc_richpresence_t* richpresence, char* buffer, unsigned buffersize, rc_peek_t peek, void* peek_ud, lua_State* L); +/*****************************************************************************\ +| Runtime | +\*****************************************************************************/ + +typedef struct rc_runtime_trigger_t { + unsigned id; + rc_trigger_t* trigger; + void* buffer; + unsigned char md5[16]; + char owns_memrefs; +} +rc_runtime_trigger_t; + +typedef struct rc_runtime_lboard_t { + unsigned id; + int value; + rc_lboard_t* lboard; + void* buffer; + unsigned char md5[16]; + char owns_memrefs; +} +rc_runtime_lboard_t; + +typedef struct rc_runtime_richpresence_t { + rc_richpresence_t* richpresence; + void* buffer; + struct rc_runtime_richpresence_t* previous; + char owns_memrefs; +} +rc_runtime_richpresence_t; + +typedef struct rc_runtime_t { + rc_runtime_trigger_t* triggers; + unsigned trigger_count; + unsigned trigger_capacity; + + rc_runtime_lboard_t* lboards; + unsigned lboard_count; + unsigned lboard_capacity; + + rc_runtime_richpresence_t* richpresence; + char* richpresence_display_buffer; + char richpresence_update_timer; + + rc_memref_value_t* memrefs; + rc_memref_value_t** next_memref; +} +rc_runtime_t; + +void rc_runtime_init(rc_runtime_t* runtime); +void rc_runtime_destroy(rc_runtime_t* runtime); + +int rc_runtime_activate_achievement(rc_runtime_t* runtime, unsigned id, const char* memaddr, lua_State* L, int funcs_idx); +void rc_runtime_deactivate_achievement(rc_runtime_t* runtime, unsigned id); +rc_trigger_t* rc_runtime_get_achievement(const rc_runtime_t* runtime, unsigned id); + +int rc_runtime_activate_lboard(rc_runtime_t* runtime, unsigned id, const char* memaddr, lua_State* L, int funcs_idx); +void rc_runtime_deactivate_lboard(rc_runtime_t* runtime, unsigned id); +rc_lboard_t* rc_runtime_get_lboard(const rc_runtime_t* runtime, unsigned id); + +int rc_runtime_activate_richpresence(rc_runtime_t* runtime, const char* script, lua_State* L, int funcs_idx); +const char* rc_runtime_get_richpresence(const rc_runtime_t* runtime); + +enum { + RC_RUNTIME_EVENT_ACHIEVEMENT_ACTIVATED, /* from WAITING, PAUSED, or PRIMED to ACTIVE */ + RC_RUNTIME_EVENT_ACHIEVEMENT_PAUSED, + RC_RUNTIME_EVENT_ACHIEVEMENT_RESET, + RC_RUNTIME_EVENT_ACHIEVEMENT_TRIGGERED, + RC_RUNTIME_EVENT_ACHIEVEMENT_PRIMED, + RC_RUNTIME_EVENT_LBOARD_STARTED, + RC_RUNTIME_EVENT_LBOARD_CANCELED, + RC_RUNTIME_EVENT_LBOARD_UPDATED, + RC_RUNTIME_EVENT_LBOARD_TRIGGERED +}; + +typedef struct rc_runtime_event_t { + unsigned id; + int value; + char type; +} +rc_runtime_event_t; + +typedef void (*rc_runtime_event_handler_t)(const rc_runtime_event_t* runtime_event); + +void rc_runtime_do_frame(rc_runtime_t* runtime, rc_runtime_event_handler_t event_handler, rc_peek_t peek, void* ud, lua_State* L); +void rc_runtime_reset(rc_runtime_t* runtime); + +int rc_runtime_progress_size(const rc_runtime_t* runtime, lua_State* L); +int rc_runtime_serialize_progress(void* buffer, const rc_runtime_t* runtime, lua_State* L); +int rc_runtime_deserialize_progress(rc_runtime_t* runtime, const unsigned char* serialized, lua_State* L); + +/*****************************************************************************\ +| Memory mapping | +\*****************************************************************************/ + +enum { + RC_MEMORY_TYPE_SYSTEM_RAM, /* normal system memory */ + RC_MEMORY_TYPE_SAVE_RAM, /* memory that persists between sessions */ + RC_MEMORY_TYPE_VIDEO_RAM, /* memory reserved for graphical processing */ + RC_MEMORY_TYPE_READONLY, /* memory that maps to read only data */ + RC_MEMORY_TYPE_HARDWARE_CONTROLLER, /* memory for interacting with system components */ + RC_MEMORY_TYPE_VIRTUAL_RAM, /* secondary address space that maps to real memory in system RAM */ + RC_MEMORY_TYPE_UNUSED /* these addresses don't really exist */ +}; + +typedef struct rc_memory_region_t { + unsigned start_address; /* first address of block as queried by RetroAchievements */ + unsigned end_address; /* last address of block as queried by RetroAchievements */ + unsigned real_address; /* real address for first address of block */ + char type; /* RC_MEMORY_TYPE_ for block */ + const char* description; /* short description of block */ +} +rc_memory_region_t; + +typedef struct rc_memory_regions_t { + const rc_memory_region_t* region; + unsigned num_regions; +} +rc_memory_regions_t; + +const rc_memory_regions_t* rc_console_memory_regions(int console_id); + #ifdef __cplusplus } #endif diff --git a/deps/rcheevos/include/rconsoles.h b/deps/rcheevos/include/rconsoles.h new file mode 100644 index 0000000000..d57c924791 --- /dev/null +++ b/deps/rcheevos/include/rconsoles.h @@ -0,0 +1,79 @@ +#ifndef RCONSOLES_H +#define RCONSOLES_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*****************************************************************************\ +| Console identifiers | +\*****************************************************************************/ + +enum { + RC_CONSOLE_MEGA_DRIVE = 1, + RC_CONSOLE_NINTENDO_64 = 2, + RC_CONSOLE_SUPER_NINTENDO = 3, + RC_CONSOLE_GAMEBOY = 4, + RC_CONSOLE_GAMEBOY_ADVANCE = 5, + RC_CONSOLE_GAMEBOY_COLOR = 6, + RC_CONSOLE_NINTENDO = 7, + RC_CONSOLE_PC_ENGINE = 8, + RC_CONSOLE_SEGA_CD = 9, + RC_CONSOLE_SEGA_32X = 10, + RC_CONSOLE_MASTER_SYSTEM = 11, + RC_CONSOLE_PLAYSTATION = 12, + RC_CONSOLE_ATARI_LYNX = 13, + RC_CONSOLE_NEOGEO_POCKET = 14, + RC_CONSOLE_GAME_GEAR = 15, + RC_CONSOLE_GAMECUBE = 16, + RC_CONSOLE_ATARI_JAGUAR = 17, + RC_CONSOLE_NINTENDO_DS = 18, + RC_CONSOLE_WII = 19, + RC_CONSOLE_WII_U = 20, + RC_CONSOLE_PLAYSTATION_2 = 21, + RC_CONSOLE_XBOX = 22, + /* 23 used to be EVENTS */ + RC_CONSOLE_POKEMON_MINI = 24, + RC_CONSOLE_ATARI_2600 = 25, + RC_CONSOLE_MS_DOS = 26, + RC_CONSOLE_ARCADE = 27, + RC_CONSOLE_VIRTUAL_BOY = 28, + RC_CONSOLE_MSX = 29, + RC_CONSOLE_COMMODORE_64 = 30, + RC_CONSOLE_ZX81 = 31, + RC_CONSOLE_ORIC = 32, + RC_CONSOLE_SG1000 = 33, + RC_CONSOLE_VIC20 = 34, + RC_CONSOLE_AMIGA = 35, + RC_CONSOLE_AMIGA_ST = 36, + RC_CONSOLE_AMSTRAD_PC = 37, + RC_CONSOLE_APPLE_II = 38, + RC_CONSOLE_SATURN = 39, + RC_CONSOLE_DREAMCAST = 40, + RC_CONSOLE_PSP = 41, + RC_CONSOLE_CDI = 42, + RC_CONSOLE_3DO = 43, + RC_CONSOLE_COLECOVISION = 44, + RC_CONSOLE_INTELLIVISION = 45, + RC_CONSOLE_VECTREX = 46, + RC_CONSOLE_PC8800 = 47, + RC_CONSOLE_PC9800 = 48, + RC_CONSOLE_PCFX = 49, + RC_CONSOLE_ATARI_5200 = 50, + RC_CONSOLE_ATARI_7800 = 51, + RC_CONSOLE_X68K = 52, + RC_CONSOLE_WONDERSWAN = 53, + RC_CONSOLE_CASSETTEVISION = 54, + RC_CONSOLE_SUPER_CASSETTEVISION = 55, + + RC_CONSOLE_HUBS = 100, + RC_CONSOLE_EVENTS = 101 +}; + +const char* rc_console_name(int console_id); + +#ifdef __cplusplus +} +#endif + +#endif /* RCONSOLES_H */ diff --git a/deps/rcheevos/include/rhash.h b/deps/rcheevos/include/rhash.h new file mode 100644 index 0000000000..32e9655dfc --- /dev/null +++ b/deps/rcheevos/include/rhash.h @@ -0,0 +1,124 @@ +#ifndef RHASH_H +#define RHASH_H + +#include +#include +#include + +#include "rconsoles.h" + +#ifdef __cplusplus +extern "C" { +#endif + + /* ===================================================== */ + + /* generates a hash from a block of memory. + * returns non-zero on success, or zero on failure. + */ + int rc_hash_generate_from_buffer(char hash[33], int console_id, uint8_t* buffer, size_t buffer_size); + + /* generates a hash from a file. + * returns non-zero on success, or zero on failure. + */ + int rc_hash_generate_from_file(char hash[33], int console_id, const char* path); + + /* ===================================================== */ + + /* data for rc_hash_iterate + */ + struct rc_hash_iterator + { + uint8_t* buffer; + size_t buffer_size; + uint8_t consoles[12]; + int index; + const char* path; + }; + + /* initializes a rc_hash_iterator + * - path must be provided + * - if buffer and buffer_size are provided, path may be a filename (i.e. for something extracted from a zip file) + */ + void rc_hash_initialize_iterator(struct rc_hash_iterator* iterator, const char* path, uint8_t* buffer, size_t buffer_size); + + /* releases resources associated to a rc_hash_iterator + */ + void rc_hash_destroy_iterator(struct rc_hash_iterator* iterator); + + /* generates the next hash for the data in the rc_hash_iterator. + * returns non-zero if a hash was generated, or zero if no more hashes can be generated for the data. + */ + int rc_hash_iterate(char hash[33], struct rc_hash_iterator* iterator); + + /* ===================================================== */ + + /* specifies a function to call when an error occurs to display the error message */ + typedef void (*rc_hash_message_callback)(const char*); + void rc_hash_init_error_message_callback(rc_hash_message_callback callback); + + /* specifies a function to call for verbose logging */ + void rc_hash_init_verbose_message_callback(rc_hash_message_callback callback); + + /* ===================================================== */ + + /* opens a file */ + typedef void* (*rc_hash_filereader_open_file_handler)(const char* path_utf8); + + /* moves the file pointer - standard fseek parameters */ + typedef void (*rc_hash_filereader_seek_handler)(void* file_handle, size_t offset, int origin); + + /* locates the file pointer */ + typedef size_t (*rc_hash_filereader_tell_handler)(void* file_handle); + + /* reads the specified number of bytes from the file starting at the read pointer. + * returns the number of bytes actually read. + */ + typedef size_t (*rc_hash_filereader_read_handler)(void* file_handle, void* buffer, size_t requested_bytes); + + /* closes the file */ + typedef void (*rc_hash_filereader_close_file_handler)(void* file_handle); + + struct rc_hash_filereader + { + rc_hash_filereader_open_file_handler open; + rc_hash_filereader_seek_handler seek; + rc_hash_filereader_tell_handler tell; + rc_hash_filereader_read_handler read; + rc_hash_filereader_close_file_handler close; + }; + + void rc_hash_init_custom_filereader(struct rc_hash_filereader* reader); + + /* ===================================================== */ + + /* opens a track from the specified file. track 0 indicates the first data track should be opened. + * returns a handle to be passed to the other functions, or NULL if the track could not be opened. + */ + typedef void* (*rc_hash_cdreader_open_track_handler)(const char* path, uint32_t track); + + /* attempts to read the specified number of bytes from the file starting at the read pointer. + * returns the number of bytes actually read. + */ + typedef size_t (*rc_hash_cdreader_read_sector_handler)(void* track_handle, uint32_t sector, void* buffer, size_t requested_bytes); + + /* closes the track handle */ + typedef void (*rc_hash_cdreader_close_track_handler)(void* track_handle); + + struct rc_hash_cdreader + { + rc_hash_cdreader_open_track_handler open_track; + rc_hash_cdreader_read_sector_handler read_sector; + rc_hash_cdreader_close_track_handler close_track; + }; + + void rc_hash_init_default_cdreader(); + void rc_hash_init_custom_cdreader(struct rc_hash_cdreader* reader); + + /* ===================================================== */ + +#ifdef __cplusplus +} +#endif + +#endif /* RHASH_H */ diff --git a/deps/rcheevos/include/rurl.h b/deps/rcheevos/include/rurl.h index 1c1a44cd0e..19bc675f87 100644 --- a/deps/rcheevos/include/rurl.h +++ b/deps/rcheevos/include/rurl.h @@ -7,11 +7,11 @@ extern "C" { #endif -int rc_url_award_cheevo(char* buffer, size_t size, const char* user_name, const char* login_token, unsigned cheevo_id, int hardcore); +int rc_url_award_cheevo(char* buffer, size_t size, const char* user_name, const char* login_token, unsigned cheevo_id, int hardcore, const char* game_hash); -int rc_url_submit_lboard(char* buffer, size_t size, const char* user_name, const char* login_token, unsigned lboard_id, int value, const char* game_hash); +int rc_url_submit_lboard(char* buffer, size_t size, const char* user_name, const char* login_token, unsigned lboard_id, int value); -int rc_url_get_gameid(char* buffer, size_t size, unsigned char hash[16]); +int rc_url_get_gameid(char* buffer, size_t size, const char* hash); int rc_url_get_patch(char* buffer, size_t size, const char* user_name, const char* login_token, unsigned gameid); @@ -25,6 +25,9 @@ int rc_url_get_unlock_list(char* buffer, size_t size, const char* user_name, con int rc_url_post_playing(char* buffer, size_t size, const char* user_name, const char* login_token, unsigned gameid); +int rc_url_ping(char* url_buffer, size_t url_buffer_size, char* post_buffer, size_t post_buffer_size, + const char* user_name, const char* login_token, unsigned gameid, const char* rich_presence); + #ifdef __cplusplus } #endif diff --git a/deps/rcheevos/src/rcheevos/alloc.c b/deps/rcheevos/src/rcheevos/alloc.c index 2730fa1ff1..69db981549 100644 --- a/deps/rcheevos/src/rcheevos/alloc.c +++ b/deps/rcheevos/src/rcheevos/alloc.c @@ -52,3 +52,37 @@ void rc_destroy_parse_state(rc_parse_state_t* parse) if (parse->scratch.memref != parse->scratch.memref_buffer) free(parse->scratch.memref); } + +const char* rc_error_str(int ret) +{ + switch (ret) { + case RC_OK: return "OK"; + case RC_INVALID_LUA_OPERAND: return "Invalid Lua operand"; + case RC_INVALID_MEMORY_OPERAND: return "Invalid memory operand"; + case RC_INVALID_CONST_OPERAND: return "Invalid constant operand"; + case RC_INVALID_FP_OPERAND: return "Invalid floating-point operand"; + case RC_INVALID_CONDITION_TYPE: return "Invalid condition type"; + case RC_INVALID_OPERATOR: return "Invalid operator"; + case RC_INVALID_REQUIRED_HITS: return "Invalid required hits"; + case RC_DUPLICATED_START: return "Duplicated start condition"; + case RC_DUPLICATED_CANCEL: return "Duplicated cancel condition"; + case RC_DUPLICATED_SUBMIT: return "Duplicated submit condition"; + case RC_DUPLICATED_VALUE: return "Duplicated value expression"; + case RC_DUPLICATED_PROGRESS: return "Duplicated progress expression"; + case RC_MISSING_START: return "Missing start condition"; + case RC_MISSING_CANCEL: return "Missing cancel condition"; + case RC_MISSING_SUBMIT: return "Missing submit condition"; + case RC_MISSING_VALUE: return "Missing value expression"; + case RC_INVALID_LBOARD_FIELD: return "Invalid field in leaderboard"; + case RC_MISSING_DISPLAY_STRING: return "Missing display string"; + case RC_OUT_OF_MEMORY: return "Out of memory"; + case RC_INVALID_VALUE_FLAG: return "Invalid flag in value expression"; + case RC_MISSING_VALUE_MEASURED: return "Missing measured flag in value expression"; + case RC_MULTIPLE_MEASURED: return "Multiple measured targets"; + case RC_INVALID_MEASURED_TARGET: return "Invalid measured target"; + case RC_INVALID_COMPARISON: return "Invalid comparison"; + case RC_INVALID_STATE: return "Invalid state"; + + default: return "Unknown error"; + } +} diff --git a/deps/rcheevos/src/rcheevos/compat.c b/deps/rcheevos/src/rcheevos/compat.c new file mode 100644 index 0000000000..6d6402503f --- /dev/null +++ b/deps/rcheevos/src/rcheevos/compat.c @@ -0,0 +1,44 @@ +#include "compat.h" + +#include +#include + +int rc_strncasecmp(const char* left, const char* right, size_t length) +{ + while (length) + { + if (*left != *right) + { + const int diff = tolower(*left) - tolower(*right); + if (diff != 0) + return diff; + } + + ++left; + ++right; + --length; + } + + return 0; +} + +char* rc_strdup(const char* str) +{ + const size_t length = strlen(str); + char* buffer = (char*)malloc(length + 1); + memcpy(buffer, str, length + 1); + return buffer; +} + +int rc_snprintf(char* buffer, size_t size, const char* format, ...) +{ + int result; + va_list args; + + va_start(args, format); + /* assume buffer is large enough and ignore size */ + result = vsprintf(buffer, format, args); + va_end(args); + + return result; +} diff --git a/deps/rcheevos/src/rcheevos/compat.h b/deps/rcheevos/src/rcheevos/compat.h new file mode 100644 index 0000000000..3bc648ab0f --- /dev/null +++ b/deps/rcheevos/src/rcheevos/compat.h @@ -0,0 +1,55 @@ +#ifndef RC_COMPAT_H +#define RC_COMPAT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#if defined(MINGW) || defined(__MINGW32__) || defined(__MINGW64__) + +/* MinGW redefinitions */ + +#elif defined(_MSC_VER) + +/* Visual Studio redefinitions */ + +#ifndef strcasecmp + #define strcasecmp _stricmp +#endif +#ifndef strncasecmp + #define strncasecmp _strnicmp +#endif +#ifndef strdup + #define strdup _strdup +#endif + +#elif __STDC_VERSION__ < 199901L + +/* C89 redefinitions */ + +#ifndef snprintf + extern int rc_snprintf(char* buffer, size_t size, const char* format, ...); + #define snprintf rc_snprintf +#endif + +#ifndef strncasecmp + extern int rc_strncasecmp(const char* left, const char* right, size_t length); + #define strncasecmp rc_strncasecmp +#endif + +#ifndef strdup + extern char* rc_strdup(const char* str); + #define strdup rc_strdup +#endif + +#endif /* __STDC_VERSION__ < 199901L */ + +#ifdef __cplusplus +} +#endif + +#endif /* RC_COMPAT_H */ diff --git a/deps/rcheevos/src/rcheevos/condition.c b/deps/rcheevos/src/rcheevos/condition.c index 7343e19564..1afb8bbbd2 100644 --- a/deps/rcheevos/src/rcheevos/condition.c +++ b/deps/rcheevos/src/rcheevos/condition.c @@ -6,6 +6,7 @@ rc_condition_t* rc_parse_condition(const char** memaddr, rc_parse_state_t* parse rc_condition_t* self; const char* aux; int ret2; + int can_modify = 0; aux = *memaddr; self = RC_ALLOC(rc_condition_t, parse); @@ -15,12 +16,15 @@ rc_condition_t* rc_parse_condition(const char** memaddr, rc_parse_state_t* parse switch (*aux) { case 'p': case 'P': self->type = RC_CONDITION_PAUSE_IF; break; case 'r': case 'R': self->type = RC_CONDITION_RESET_IF; break; - case 'a': case 'A': self->type = RC_CONDITION_ADD_SOURCE; break; - case 'b': case 'B': self->type = RC_CONDITION_SUB_SOURCE; break; + case 'a': case 'A': self->type = RC_CONDITION_ADD_SOURCE; can_modify = 1; break; + case 'b': case 'B': self->type = RC_CONDITION_SUB_SOURCE; can_modify = 1; break; case 'c': case 'C': self->type = RC_CONDITION_ADD_HITS; break; case 'n': case 'N': self->type = RC_CONDITION_AND_NEXT; break; + case 'o': case 'O': self->type = RC_CONDITION_OR_NEXT; break; case 'm': case 'M': self->type = RC_CONDITION_MEASURED; break; - case 'i': case 'I': self->type = RC_CONDITION_ADD_ADDRESS; break; + case 'q': case 'Q': self->type = RC_CONDITION_MEASURED_IF; break; + case 'i': case 'I': self->type = RC_CONDITION_ADD_ADDRESS; can_modify = 1; break; + case 't': case 'T': self->type = RC_CONDITION_TRIGGER; break; default: parse->offset = RC_INVALID_CONDITION_TYPE; return 0; } @@ -37,9 +41,14 @@ rc_condition_t* rc_parse_condition(const char** memaddr, rc_parse_state_t* parse return 0; } + if (self->operand1.type == RC_OPERAND_FP) { + parse->offset = can_modify ? RC_INVALID_FP_OPERAND : RC_INVALID_COMPARISON; + return 0; + } + switch (*aux++) { case '=': - self->oper = RC_CONDITION_EQ; + self->oper = RC_OPERATOR_EQ; aux += *aux == '='; break; @@ -51,33 +60,45 @@ rc_condition_t* rc_parse_condition(const char** memaddr, rc_parse_state_t* parse return 0; } - self->oper = RC_CONDITION_NE; + self->oper = RC_OPERATOR_NE; break; case '<': - self->oper = RC_CONDITION_LT; + self->oper = RC_OPERATOR_LT; if (*aux == '=') { - self->oper = RC_CONDITION_LE; + self->oper = RC_OPERATOR_LE; aux++; } break; case '>': - self->oper = RC_CONDITION_GT; + self->oper = RC_OPERATOR_GT; if (*aux == '=') { - self->oper = RC_CONDITION_GE; + self->oper = RC_OPERATOR_GE; aux++; } break; + case '*': + self->oper = RC_OPERATOR_MULT; + break; + + case '/': + self->oper = RC_OPERATOR_DIV; + break; + + case '&': + self->oper = RC_OPERATOR_AND; + break; + case '_': case ')': case '\0': - self->oper = RC_CONDITION_NONE; + self->oper = RC_OPERATOR_NONE; self->operand2.type = RC_OPERAND_CONST; self->operand2.value.num = 1; self->required_hits = 0; @@ -85,6 +106,36 @@ rc_condition_t* rc_parse_condition(const char** memaddr, rc_parse_state_t* parse return self; } + switch (self->oper) { + case RC_OPERATOR_MULT: + case RC_OPERATOR_DIV: + case RC_OPERATOR_AND: + /* modifying operators are only valid on modifying statements */ + if (!can_modify) { + parse->offset = RC_INVALID_OPERATOR; + return 0; + } + break; + + default: + /* comparison operators are not valid on modifying statements */ + if (can_modify) { + switch (self->type) { + case RC_CONDITION_ADD_SOURCE: + case RC_CONDITION_SUB_SOURCE: + case RC_CONDITION_ADD_ADDRESS: + /* prevent parse errors on legacy achievements where a condition was present before changing the type */ + self->oper = RC_OPERATOR_NONE; + break; + + default: + parse->offset = RC_INVALID_OPERATOR; + return 0; + } + } + break; + } + ret2 = rc_parse_operand(&self->operand2, &aux, 1, is_indirect, parse); if (ret2 < 0) { @@ -92,6 +143,17 @@ rc_condition_t* rc_parse_condition(const char** memaddr, rc_parse_state_t* parse return 0; } + if (self->oper == RC_OPERATOR_NONE) { + /* if operator is none, explicitly clear out the right side */ + self->operand2.type = RC_INVALID_CONST_OPERAND; + self->operand2.value.num = 0; + } + + if (!can_modify && self->operand2.type == RC_OPERAND_FP) { + parse->offset = RC_INVALID_COMPARISON; + return 0; + } + if (*aux == '(') { char* end; self->required_hits = (unsigned)strtoul(++aux, &end, 10); @@ -127,13 +189,39 @@ int rc_test_condition(rc_condition_t* self, rc_eval_state_t* eval_state) { unsigned value2 = rc_evaluate_operand(&self->operand2, eval_state); switch (self->oper) { - case RC_CONDITION_EQ: return value1 == value2; - case RC_CONDITION_NE: return value1 != value2; - case RC_CONDITION_LT: return value1 < value2; - case RC_CONDITION_LE: return value1 <= value2; - case RC_CONDITION_GT: return value1 > value2; - case RC_CONDITION_GE: return value1 >= value2; - case RC_CONDITION_NONE: return 1; + case RC_OPERATOR_EQ: return value1 == value2; + case RC_OPERATOR_NE: return value1 != value2; + case RC_OPERATOR_LT: return value1 < value2; + case RC_OPERATOR_LE: return value1 <= value2; + case RC_OPERATOR_GT: return value1 > value2; + case RC_OPERATOR_GE: return value1 >= value2; + case RC_OPERATOR_NONE: return 1; default: return 1; } } + +int rc_evaluate_condition_value(rc_condition_t* self, rc_eval_state_t* eval_state) { + unsigned value = rc_evaluate_operand(&self->operand1, eval_state); + + switch (self->oper) { + case RC_OPERATOR_MULT: + if (self->operand2.type == RC_OPERAND_FP) + value = (int)((double)value * self->operand2.value.dbl); + else + value *= rc_evaluate_operand(&self->operand2, eval_state); + break; + + case RC_OPERATOR_DIV: + if (self->operand2.type == RC_OPERAND_FP) + value = (int)((double)value / self->operand2.value.dbl); + else + value /= rc_evaluate_operand(&self->operand2, eval_state); + break; + + case RC_OPERATOR_AND: + value &= rc_evaluate_operand(&self->operand2, eval_state); + break; + } + + return value; +} diff --git a/deps/rcheevos/src/rcheevos/condset.c b/deps/rcheevos/src/rcheevos/condset.c index a9ed1513f9..9e142a61d3 100644 --- a/deps/rcheevos/src/rcheevos/condset.c +++ b/deps/rcheevos/src/rcheevos/condset.c @@ -9,15 +9,16 @@ static void rc_update_condition_pause(rc_condition_t* condition, int* in_pause) case RC_CONDITION_PAUSE_IF: *in_pause = condition->pause = 1; break; - + case RC_CONDITION_ADD_SOURCE: case RC_CONDITION_SUB_SOURCE: case RC_CONDITION_ADD_HITS: case RC_CONDITION_AND_NEXT: + case RC_CONDITION_OR_NEXT: case RC_CONDITION_ADD_ADDRESS: condition->pause = *in_pause; break; - + default: *in_pause = condition->pause = 0; break; @@ -48,14 +49,15 @@ rc_condset_t* rc_parse_condset(const char** memaddr, rc_parse_state_t* parse) { return 0; } - if ((*next)->oper == RC_CONDITION_NONE) { + if ((*next)->oper == RC_OPERATOR_NONE) { switch ((*next)->type) { case RC_CONDITION_ADD_ADDRESS: case RC_CONDITION_ADD_HITS: case RC_CONDITION_ADD_SOURCE: case RC_CONDITION_SUB_SOURCE: case RC_CONDITION_AND_NEXT: - break; + case RC_CONDITION_OR_NEXT: + break; default: parse->offset = RC_INVALID_OPERATOR; @@ -110,10 +112,14 @@ rc_condset_t* rc_parse_condset(const char** memaddr, rc_parse_state_t* parse) { static int rc_test_condset_internal(rc_condset_t* self, int processing_pause, rc_eval_state_t* eval_state) { rc_condition_t* condition; - int set_valid, cond_valid, prev_cond; + int set_valid, cond_valid, and_next, or_next; + unsigned measured_value = 0; + int can_measure = 1, measured_from_hits = 0; + eval_state->primed = 1; set_valid = 1; - prev_cond = 1; + and_next = 1; + or_next = 0; eval_state->add_value = eval_state->add_hits = eval_state->add_address = 0; for (condition = self->conditions; condition != 0; condition = condition->next) { @@ -121,93 +127,107 @@ static int rc_test_condset_internal(rc_condset_t* self, int processing_pause, rc continue; } + /* STEP 1: process modifier conditions */ switch (condition->type) { case RC_CONDITION_ADD_SOURCE: - eval_state->add_value += rc_evaluate_operand(&condition->operand1, eval_state); + eval_state->add_value += rc_evaluate_condition_value(condition, eval_state); eval_state->add_address = 0; continue; - + case RC_CONDITION_SUB_SOURCE: - eval_state->add_value -= rc_evaluate_operand(&condition->operand1, eval_state); - eval_state->add_address = 0; - continue; - - case RC_CONDITION_ADD_HITS: - /* always evaluate the condition to ensure everything is updated correctly */ - cond_valid = rc_test_condition(condition, eval_state); - - /* merge AndNext value and reset it for the next condition */ - cond_valid &= prev_cond; - prev_cond = 1; - - /* if the condition is true, tally it */ - if (cond_valid) { - if (condition->required_hits == 0 || condition->current_hits < condition->required_hits) { - condition->current_hits++; - } - - condition->is_true = (condition->required_hits == 0 || condition->current_hits >= condition->required_hits); - } - else { - condition->is_true = 0; - } - - eval_state->add_value = 0; - eval_state->add_address = 0; - eval_state->add_hits += condition->current_hits; - continue; - - case RC_CONDITION_AND_NEXT: - prev_cond &= rc_test_condition(condition, eval_state); - eval_state->add_value = 0; + eval_state->add_value -= rc_evaluate_condition_value(condition, eval_state); eval_state->add_address = 0; continue; case RC_CONDITION_ADD_ADDRESS: - eval_state->add_address = rc_evaluate_operand(&condition->operand1, eval_state); + eval_state->add_address = rc_evaluate_condition_value(condition, eval_state); continue; + + case RC_CONDITION_MEASURED: + if (condition->required_hits == 0) { + /* Measured condition without a hit target measures the value of the left operand */ + measured_value = rc_evaluate_condition_value(condition, eval_state) + eval_state->add_value; + } + break; + + default: + break; } - /* always evaluate the condition to ensure everything is updated correctly */ - cond_valid = rc_test_condition(condition, eval_state); + /* STEP 2: evaluate the current condition */ + condition->is_true = rc_test_condition(condition, eval_state); + eval_state->add_value = 0; + eval_state->add_address = 0; - /* merge AndNext value and reset it for the next condition */ - cond_valid &= prev_cond; - prev_cond = 1; + /* apply logic flags and reset them for the next condition */ + cond_valid = condition->is_true; + cond_valid &= and_next; + cond_valid |= or_next; + and_next = 1; + or_next = 0; - /* if the condition has a target hit count that has already been met, it's automatically true, even if not currently true. */ - if (condition->required_hits != 0 && (condition->current_hits + eval_state->add_hits) >= condition->required_hits) { - cond_valid = 1; - } - else if (cond_valid) { - condition->current_hits++; + /* true conditions should update hit count */ + if (cond_valid) { + eval_state->has_hits = 1; if (condition->required_hits == 0) { - /* not a hit-based requirement: ignore any additional logic! */ + /* no target hit count, just keep tallying */ + ++condition->current_hits; } - else if ((condition->current_hits + eval_state->add_hits) < condition->required_hits) { - /* HitCount target has not yet been met, condition is not yet valid */ - cond_valid = 0; + else if (condition->current_hits < condition->required_hits) { + /* target hit count hasn't been met, tally and revalidate - only true if hit count becomes met */ + ++condition->current_hits; + cond_valid = (condition->current_hits == condition->required_hits); + } + else { + /* target hit count has been met, do nothing */ } } - condition->is_true = cond_valid; - eval_state->has_hits |= (condition->current_hits || eval_state->add_hits); + else if (condition->current_hits > 0) { + /* target has been true in the past, if the hit target is met, consider it true now */ + eval_state->has_hits = 1; + cond_valid = (condition->current_hits == condition->required_hits); + } - /* capture measured state */ - if (condition->type == RC_CONDITION_MEASURED) { - unsigned int measured_value; - if (condition->required_hits > 0) + /* STEP 3: handle logic flags */ + switch (condition->type) { + case RC_CONDITION_ADD_HITS: + eval_state->add_hits += condition->current_hits; + continue; + + case RC_CONDITION_AND_NEXT: + and_next = cond_valid; + continue; + + case RC_CONDITION_OR_NEXT: + or_next = cond_valid; + continue; + + default: + break; + } + + if (eval_state->add_hits) { + if (condition->required_hits != 0) { + /* if the condition has a target hit count, we have to recalculate cond_valid including the AddHits counter */ + measured_from_hits = 1; measured_value = condition->current_hits + eval_state->add_hits; - else - measured_value = rc_evaluate_operand(&condition->operand1, eval_state) + eval_state->add_value; + cond_valid = (measured_value >= condition->required_hits); + } + else { + /* no target hit count. we can't tell if the add_hits value is from this frame or not, so ignore it. + complex condition will only be true if the current condition is true */ + } - if (measured_value > eval_state->measured_value) - eval_state->measured_value = measured_value; + eval_state->add_hits = 0; + } + else if (condition->required_hits != 0) { + /* if there's a hit target, capture the current hits for recording Measured value later */ + measured_from_hits = 1; + measured_value = condition->current_hits; } - /* reset AddHits and AddSource/SubSource values */ - eval_state->add_value = eval_state->add_hits = eval_state->add_address = 0; - + /* STEP 4: handle special flags */ switch (condition->type) { case RC_CONDITION_PAUSE_IF: /* as soon as we find a PauseIf that evaluates to true, stop processing the rest of the group */ @@ -227,20 +247,38 @@ static int rc_test_condset_internal(rc_condset_t* self, int processing_pause, rc /* PauseIf has a HitCount that hasn't been met, ignore it for now. */ } - break; - + continue; + case RC_CONDITION_RESET_IF: if (cond_valid) { eval_state->was_reset = 1; /* let caller know to reset all hit counts */ set_valid = 0; /* cannot be valid if we've hit a reset condition */ } + continue; + case RC_CONDITION_MEASURED_IF: + if (!cond_valid) + can_measure = 0; break; + case RC_CONDITION_TRIGGER: + /* update truthiness of set, but do not update truthiness of primed state */ + set_valid &= cond_valid; + continue; + default: - set_valid &= cond_valid; break; } + + /* STEP 5: update overall truthiness of set and primed state */ + eval_state->primed &= cond_valid; + set_valid &= cond_valid; + } + + /* if not suppressed, update the measured value */ + if (measured_value > eval_state->measured_value && can_measure) { + eval_state->measured_value = measured_value; + eval_state->measured_from_hits = measured_from_hits; } return set_valid; @@ -255,6 +293,7 @@ int rc_test_condset(rc_condset_t* self, rc_eval_state_t* eval_state) { if (self->has_pause) { if ((self->is_paused = rc_test_condset_internal(self, 1, eval_state))) { /* one or more Pause conditions exists, if any of them are true, stop processing this group */ + eval_state->primed = 0; return 0; } } diff --git a/deps/rcheevos/src/rcheevos/consoleinfo.c b/deps/rcheevos/src/rcheevos/consoleinfo.c new file mode 100644 index 0000000000..a610b8ce95 --- /dev/null +++ b/deps/rcheevos/src/rcheevos/consoleinfo.c @@ -0,0 +1,573 @@ +#include "rcheevos.h" +#include "rconsoles.h" + +#include + +const char* rc_console_name(int console_id) +{ + switch (console_id) + { + case RC_CONSOLE_3DO: + return "3DO"; + + case RC_CONSOLE_AMIGA: + return "Amiga"; + + case RC_CONSOLE_AMIGA_ST: + return "Amiga ST"; + + case RC_CONSOLE_AMSTRAD_PC: + return "Amstrad CPC"; + + case RC_CONSOLE_APPLE_II: + return "Apple II"; + + case RC_CONSOLE_ARCADE: + return "Arcade"; + + case RC_CONSOLE_ATARI_2600: + return "Atari 2600"; + + case RC_CONSOLE_ATARI_5200: + return "Atari 5200"; + + case RC_CONSOLE_ATARI_7800: + return "Atari 7800"; + + case RC_CONSOLE_ATARI_JAGUAR: + return "Atari Jaguar"; + + case RC_CONSOLE_ATARI_LYNX: + return "Atari Lynx"; + + case RC_CONSOLE_CASSETTEVISION: + return "CassetteVision"; + + case RC_CONSOLE_CDI: + return "CD-I"; + + case RC_CONSOLE_COLECOVISION: + return "ColecoVision"; + + case RC_CONSOLE_COMMODORE_64: + return "Commodore 64"; + + case RC_CONSOLE_DREAMCAST: + return "Dreamcast"; + + case RC_CONSOLE_EVENTS: + return "Events"; + + case RC_CONSOLE_GAMEBOY: + return "GameBoy"; + + case RC_CONSOLE_GAMEBOY_ADVANCE: + return "GameBoy Advance"; + + case RC_CONSOLE_GAMEBOY_COLOR: + return "GameBoy Color"; + + case RC_CONSOLE_GAMECUBE: + return "GameCube"; + + case RC_CONSOLE_GAME_GEAR: + return "Game Gear"; + + case RC_CONSOLE_HUBS: + return "Hubs"; + + case RC_CONSOLE_INTELLIVISION: + return "Intellivision"; + + case RC_CONSOLE_MASTER_SYSTEM: + return "Master System"; + + case RC_CONSOLE_MEGA_DRIVE: + return "Sega Genesis"; + + case RC_CONSOLE_MS_DOS: + return "MS-DOS"; + + case RC_CONSOLE_MSX: + return "MSX"; + + case RC_CONSOLE_NINTENDO: + return "Nintendo Entertainment System"; + + case RC_CONSOLE_NINTENDO_64: + return "Nintendo 64"; + + case RC_CONSOLE_NINTENDO_DS: + return "Nintendo DS"; + + case RC_CONSOLE_NEOGEO_POCKET: + return "Neo Geo Pocket"; + + case RC_CONSOLE_ORIC: + return "Oric"; + + case RC_CONSOLE_PC8800: + return "PC-8000/8800"; + + case RC_CONSOLE_PC9800: + return "PC-9800"; + + case RC_CONSOLE_PCFX: + return "PCFX"; + + case RC_CONSOLE_PC_ENGINE: + return "PCEngine"; + + case RC_CONSOLE_PLAYSTATION: + return "PlayStation"; + + case RC_CONSOLE_PLAYSTATION_2: + return "PlayStation 2"; + + case RC_CONSOLE_PSP: + return "PlayStation Portable"; + + case RC_CONSOLE_POKEMON_MINI: + return "Pokemon Mini"; + + case RC_CONSOLE_SEGA_32X: + return "Sega 32X"; + + case RC_CONSOLE_SEGA_CD: + return "Sega CD"; + + case RC_CONSOLE_SATURN: + return "Sega Saturn"; + + case RC_CONSOLE_SG1000: + return "SG-1000"; + + case RC_CONSOLE_SUPER_NINTENDO: + return "Super Nintendo Entertainment System"; + + case RC_CONSOLE_SUPER_CASSETTEVISION: + return "Super CassetteVision"; + + case RC_CONSOLE_WONDERSWAN: + return "WonderSwan"; + + case RC_CONSOLE_VECTREX: + return "Vectrex"; + + case RC_CONSOLE_VIC20: + return "VIC-20"; + + case RC_CONSOLE_VIRTUAL_BOY: + return "Virtual Boy"; + + case RC_CONSOLE_WII: + return "Wii"; + + case RC_CONSOLE_WII_U: + return "Wii-U"; + + case RC_CONSOLE_X68K: + return "X68K"; + + case RC_CONSOLE_XBOX: + return "XBOX"; + + case RC_CONSOLE_ZX81: + return "ZX-81"; + + default: + return "Unknown"; + } +} + +/* ===== 3DO ===== */ +/* http://www.arcaderestoration.com/memorymap/48/3DO+Bios.aspx */ +/* NOTE: the Opera core attempts to expose the NVRAM as RETRO_SAVE_RAM, but the 3DO documentation + * says that applications should only access NVRAM through API calls as it's shared across mulitple + * games. This suggests that even if the core does expose it, it may change depending on which other + * games the user has played - so ignore it. + */ +static const rc_memory_region_t _rc_memory_regions_3do[] = { + { 0x000000U, 0x1FFFFFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Main RAM" }, +}; +static const rc_memory_regions_t rc_memory_regions_3do = { _rc_memory_regions_3do, 1 }; + +/* ===== Apple II ===== */ +static const rc_memory_region_t _rc_memory_regions_appleii[] = { + { 0x000000U, 0x00FFFFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Main RAM" }, + { 0x010000U, 0x01FFFFU, 0x010000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Auxillary RAM" } +}; +static const rc_memory_regions_t rc_memory_regions_appleii = { _rc_memory_regions_appleii, 2 }; + +/* ===== Atari 2600 ===== */ +static const rc_memory_region_t _rc_memory_regions_atari2600[] = { + { 0x000000U, 0x00007FU, 0x000080U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" } +}; +static const rc_memory_regions_t rc_memory_regions_atari2600 = { _rc_memory_regions_atari2600, 1 }; + +/* ===== Atari 7800 ===== */ +/* http://www.atarihq.com/danb/files/78map.txt */ +/* http://pdf.textfiles.com/technical/7800_devkit.pdf */ +static const rc_memory_region_t _rc_memory_regions_atari7800[] = { + { 0x000000U, 0x0017FFU, 0x000000U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "Hardware Interface" }, + { 0x001800U, 0x0027FFU, 0x001800U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, + { 0x002800U, 0x002FFFU, 0x002800U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Mirrored RAM" }, + { 0x003000U, 0x0037FFU, 0x003000U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Mirrored RAM" }, + { 0x003800U, 0x003FFFU, 0x003800U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Mirrored RAM" }, + { 0x004000U, 0x007FFFU, 0x004000U, RC_MEMORY_TYPE_SAVE_RAM, "Cartridge RAM" }, + { 0x008000U, 0x00FFFFU, 0x008000U, RC_MEMORY_TYPE_READONLY, "Cartridge ROM" } +}; +static const rc_memory_regions_t rc_memory_regions_atari7800 = { _rc_memory_regions_atari7800, 7 }; + +/* ===== Atari Jaguar ===== */ +/* https://www.mulle-kybernetik.com/jagdox/memorymap.html */ +static const rc_memory_region_t _rc_memory_regions_atari_jaguar[] = { + { 0x000000U, 0x1FFFFFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" } +}; +static const rc_memory_regions_t rc_memory_regions_atari_jaguar = { _rc_memory_regions_atari_jaguar, 1 }; + +/* ===== Atari Lynx ===== */ +/* http://www.retroisle.com/atari/lynx/Technical/Programming/lynxprgdumm.php */ +static const rc_memory_region_t _rc_memory_regions_atari_lynx[] = { + { 0x000000U, 0x0000FFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Zero Page" }, + { 0x000100U, 0x0001FFU, 0x000100U, RC_MEMORY_TYPE_SYSTEM_RAM, "Stack" }, + { 0x000200U, 0x00FBFFU, 0x000200U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, + { 0x00FC00U, 0x00FCFFU, 0x00FC00U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "SUZY hardware access" }, + { 0x00FD00U, 0x00FDFFU, 0x00FD00U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "MIKEY hardware access" }, + { 0x00FE00U, 0x00FFF7U, 0x00FE00U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "Boot ROM" }, + { 0x00FFF8U, 0x00FFFFU, 0x00FFF8U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "Hardware vectors" } +}; +static const rc_memory_regions_t rc_memory_regions_atari_lynx = { _rc_memory_regions_atari_lynx, 7 }; + +/* ===== ColecoVision ===== */ +static const rc_memory_region_t _rc_memory_regions_colecovision[] = { + { 0x000000U, 0x0003FFU, 0x006000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" } +}; +static const rc_memory_regions_t rc_memory_regions_colecovision = { _rc_memory_regions_colecovision, 1 }; + +/* ===== GameBoy / GameBoy Color ===== */ +static const rc_memory_region_t _rc_memory_regions_gameboy[] = { + { 0x000000U, 0x0000FFU, 0x000000U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "Interrupt vector" }, + { 0x000100U, 0x00014FU, 0x000100U, RC_MEMORY_TYPE_READONLY, "Cartridge header" }, + { 0x000150U, 0x003FFFU, 0x000150U, RC_MEMORY_TYPE_READONLY, "Cartridge ROM (fixed)" }, /* bank 0 */ + { 0x004000U, 0x007FFFU, 0x004000U, RC_MEMORY_TYPE_READONLY, "Cartridge ROM (paged)" }, /* bank 1-XX (switchable) */ + { 0x008000U, 0x0097FFU, 0x008000U, RC_MEMORY_TYPE_VIDEO_RAM, "Tile RAM" }, + { 0x009800U, 0x009BFFU, 0x009800U, RC_MEMORY_TYPE_VIDEO_RAM, "BG1 map data" }, + { 0x009C00U, 0x009FFFU, 0x009C00U, RC_MEMORY_TYPE_VIDEO_RAM, "BG2 map data" }, + { 0x00A000U, 0x00BFFFU, 0x00A000U, RC_MEMORY_TYPE_SAVE_RAM, "Cartridge RAM"}, + { 0x00C000U, 0x00CFFFU, 0x00C000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM (fixed)" }, + { 0x00D000U, 0x00DFFFU, 0x00D000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM (bank 1)" }, + { 0x00E000U, 0x00FDFFU, 0x00C000U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Echo RAM" }, + { 0x00FE00U, 0x00FE9FU, 0x00FE00U, RC_MEMORY_TYPE_VIDEO_RAM, "Sprite RAM"}, + { 0x00FEA0U, 0x00FEFFU, 0x00FEA0U, RC_MEMORY_TYPE_READONLY, "Unusable"}, + { 0x00FF00U, 0x00FF7FU, 0x00FF00U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "Hardware I/O"}, + { 0x00FF80U, 0x00FFFEU, 0x00FF80U, RC_MEMORY_TYPE_SYSTEM_RAM, "Quick RAM"}, + { 0x00FFFFU, 0x00FFFFU, 0x00FFFFU, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "Interrupt enable"}, + + /* GameBoy Color provides six extra banks of memory that can be paged out through the $DXXX + * memory space, but the timing of that does not correspond with blanks, which is when achievements + * are processed. As such, it is desirable to always have access to these extra banks. We do this + * by expecting the extra banks to be addressable at addresses not supported by the native system. */ + { 0x010000U, 0x015FFFU, 0x010000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM (banks 2-7, GBC only)" } +}; +static const rc_memory_regions_t rc_memory_regions_gameboy = { _rc_memory_regions_gameboy, 16 }; +static const rc_memory_regions_t rc_memory_regions_gameboy_color = { _rc_memory_regions_gameboy, 17 }; + +/* ===== GameBoy Advance ===== */ +static const rc_memory_region_t _rc_memory_regions_gameboy_advance[] = { + { 0x000000U, 0x007FFFU, 0x03000000U, RC_MEMORY_TYPE_SAVE_RAM, "Cartridge RAM" }, + { 0x008000U, 0x047FFFU, 0x02000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" } +}; +static const rc_memory_regions_t rc_memory_regions_gameboy_advance = { _rc_memory_regions_gameboy_advance, 2 }; + +/* ===== Game Gear ===== */ +/* http://www.smspower.org/Development/MemoryMap */ +static const rc_memory_region_t _rc_memory_regions_game_gear[] = { + { 0x000000U, 0x001FFFU, 0x00C000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" } +}; +static const rc_memory_regions_t rc_memory_regions_game_gear = { _rc_memory_regions_game_gear, 1 }; + +/* ===== Intellivision ===== */ +/* http://wiki.intellivision.us/index.php%3Ftitle%3DMemory_Map */ +static const rc_memory_region_t _rc_memory_regions_intellivision[] = { + { 0x000000U, 0x00007FU, 0x000000U, RC_MEMORY_TYPE_VIDEO_RAM, "STIC Registers" }, + { 0x000080U, 0x0000FFU, 0x000080U, RC_MEMORY_TYPE_UNUSED, "" }, + { 0x000100U, 0x00035FU, 0x000100U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, + { 0x000360U, 0x0003FFU, 0x000360U, RC_MEMORY_TYPE_UNUSED, "" }, + { 0x000400U, 0x000FFFU, 0x000400U, RC_MEMORY_TYPE_SYSTEM_RAM, "Cartridge RAM" }, + { 0x001000U, 0x001FFFU, 0x001000U, RC_MEMORY_TYPE_UNUSED, "" }, + { 0x002000U, 0x002FFFU, 0x002000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Cartridge RAM" }, + { 0x003000U, 0x003FFFU, 0x003000U, RC_MEMORY_TYPE_VIDEO_RAM, "Video RAM" }, + { 0x004000U, 0x00FFFFU, 0x004000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Cartridge RAM" }, +}; +static const rc_memory_regions_t rc_memory_regions_intellivision = { _rc_memory_regions_intellivision, 9 }; + +/* ===== Master System ===== */ +/* http://www.smspower.org/Development/MemoryMap */ +static const rc_memory_region_t _rc_memory_regions_master_system[] = { + { 0x000000U, 0x001FFFU, 0x00C000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" } +}; +static const rc_memory_regions_t rc_memory_regions_master_system = { _rc_memory_regions_master_system, 1 }; + +/* ===== MegaDrive (Genesis) ===== */ +/* http://www.smspower.org/Development/MemoryMap */ +static const rc_memory_region_t _rc_memory_regions_megadrive[] = { + { 0x000000U, 0x00FFFFU, 0xFF0000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, + { 0x010000U, 0x01FFFFU, 0x000000U, RC_MEMORY_TYPE_SAVE_RAM, "Cartridge RAM" } +}; +static const rc_memory_regions_t rc_memory_regions_megadrive = { _rc_memory_regions_megadrive, 2 }; + +/* ===== Neo Geo Pocket ===== */ +/* http://neopocott.emuunlim.com/docs/tech-11.txt */ +static const rc_memory_region_t _rc_memory_regions_neo_geo_pocket[] = { + /* MednafenNGP exposes 16KB, but the doc suggests there's 24-32KB */ + { 0x000000U, 0x003FFFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" } +}; +static const rc_memory_regions_t rc_memory_regions_neo_geo_pocket = { _rc_memory_regions_neo_geo_pocket, 1 }; + +/* ===== Nintendo Entertainment System ===== */ +/* https://wiki.nesdev.com/w/index.php/CPU_memory_map */ +static const rc_memory_region_t _rc_memory_regions_nes[] = { + { 0x0000U, 0x07FFU, 0x0000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, + { 0x0800U, 0x0FFFU, 0x0000U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Mirror RAM" }, /* duplicates memory from $0000-$07FF */ + { 0x1000U, 0x17FFU, 0x0000U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Mirror RAM" }, /* duplicates memory from $0000-$07FF */ + { 0x1800U, 0x1FFFU, 0x0000U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Mirror RAM" }, /* duplicates memory from $0000-$07FF */ + { 0x2000U, 0x2007U, 0x2000U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "PPU Register" }, + { 0x2008U, 0x3FFFU, 0x2008U, RC_MEMORY_TYPE_VIRTUAL_RAM, "Mirrored PPU Register" }, /* repeats every 8 bytes */ + { 0x4000U, 0x4017U, 0x4000U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "APU and I/O register" }, + { 0x4018U, 0x401FU, 0x4018U, RC_MEMORY_TYPE_HARDWARE_CONTROLLER, "APU and I/O test register" }, + { 0x4020U, 0x5FFFU, 0x4020U, RC_MEMORY_TYPE_READONLY, "Cartridge data"}, /* varies by mapper */ + { 0x6000U, 0x7FFFU, 0x6000U, RC_MEMORY_TYPE_SAVE_RAM, "Cartridge RAM"}, + { 0x8000U, 0xFFFFU, 0x8000U, RC_MEMORY_TYPE_READONLY, "Cartridge ROM"}, +}; +static const rc_memory_regions_t rc_memory_regions_nes = { _rc_memory_regions_nes, 11 }; + +/* ===== Nintendo 64 ===== */ +/* https://raw.githubusercontent.com/mikeryan/n64dev/master/docs/n64ops/n64ops%23h.txt */ +static const rc_memory_region_t _rc_memory_regions_n64[] = { + { 0x000000U, 0x1FFFFFU, 0x00000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, /* RDRAM 1 */ + { 0x200000U, 0x3FFFFFU, 0x00020000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, /* RDRAM 2 */ + { 0x400000U, 0x7FFFFFU, 0x80000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" } /* expansion pak - cannot find any details for real address */ +}; +static const rc_memory_regions_t rc_memory_regions_n64 = { _rc_memory_regions_n64, 3 }; + +/* ===== Nintendo DS ===== */ +/* https://www.akkit.org/info/gbatek.htm#dsmemorymaps */ +static const rc_memory_region_t _rc_memory_regions_nintendo_ds[] = { + { 0x000000U, 0x3FFFFFU, 0x02000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" } +}; +static const rc_memory_regions_t rc_memory_regions_nintendo_ds = { _rc_memory_regions_nintendo_ds, 1 }; + +/* ===== Oric ===== */ +static const rc_memory_region_t _rc_memory_regions_oric[] = { + /* actual size depends on machine type - up to 64KB */ + { 0x000000U, 0x00FFFFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" } +}; +static const rc_memory_regions_t rc_memory_regions_oric = { _rc_memory_regions_oric, 1 }; + +/* ===== PC-8800 ===== */ +static const rc_memory_region_t _rc_memory_regions_pc8800[] = { + { 0x000000U, 0x00FFFFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Main RAM" }, + { 0x010000U, 0x010FFFU, 0x010000U, RC_MEMORY_TYPE_VIDEO_RAM, "Text VRAM" } /* technically VRAM, but often used as system RAM */ +}; +static const rc_memory_regions_t rc_memory_regions_pc8800 = { _rc_memory_regions_pc8800, 2 }; + +/* ===== PC Engine ===== */ +static const rc_memory_region_t _rc_memory_regions_pcengine[] = { + { 0x000000U, 0x001FFFU, 0x1F0000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, + { 0x002000U, 0x011FFFU, 0x100000U, RC_MEMORY_TYPE_SYSTEM_RAM, "CD RAM" }, + { 0x012000U, 0x041FFFU, 0x0D0000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Super System Card RAM" }, + { 0x042000U, 0x0427FFU, 0x1EE000U, RC_MEMORY_TYPE_SAVE_RAM, "CD Battery-backed RAM" } +}; +static const rc_memory_regions_t rc_memory_regions_pcengine = { _rc_memory_regions_pcengine, 4 }; + +/* ===== PlayStation ===== */ +/* http://www.raphnet.net/electronique/psx_adaptor/Playstation.txt */ +static const rc_memory_region_t _rc_memory_regions_playstation[] = { + { 0x000000U, 0x00FFFFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Kernel RAM" }, + { 0x010000U, 0x1FFFFFU, 0x010000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" } +}; +static const rc_memory_regions_t rc_memory_regions_playstation = { _rc_memory_regions_playstation, 2 }; + +/* ===== Pokemon Mini ===== */ +/* https://www.pokemon-mini.net/documentation/memory-map/ */ +static const rc_memory_region_t _rc_memory_regions_pokemini[] = { + { 0x000000U, 0x000FFFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "BIOS RAM" }, + { 0x001000U, 0x001FFFU, 0x001000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" } +}; +static const rc_memory_regions_t rc_memory_regions_pokemini = { _rc_memory_regions_pokemini, 2 }; + +/* ===== Sega CD ===== */ +static const rc_memory_region_t _rc_memory_regions_segacd[] = { + { 0x000000U, 0x00FFFFU, 0x00FF0000U, RC_MEMORY_TYPE_SYSTEM_RAM, "68000 RAM" }, + { 0x010000U, 0x08FFFFU, 0x80000000U, RC_MEMORY_TYPE_SAVE_RAM, "CD PRG RAM" } /* normally banked into $020000-$03FFFF */ +}; +static const rc_memory_regions_t rc_memory_regions_segacd = { _rc_memory_regions_segacd, 2 }; + +/* ===== Sega Saturn ===== */ +/* https://segaretro.org/Sega_Saturn_hardware_notes_(2004-04-27) */ +static const rc_memory_region_t _rc_memory_regions_saturn[] = { + { 0x000000U, 0x0FFFFFU, 0x00200000U, RC_MEMORY_TYPE_SYSTEM_RAM, "Work RAM Low" }, + { 0x100000U, 0x1FFFFFU, 0x06000000U, RC_MEMORY_TYPE_SAVE_RAM, "Work RAM High" } +}; +static const rc_memory_regions_t rc_memory_regions_saturn = { _rc_memory_regions_saturn, 2 }; + +/* ===== SG-1000 ===== */ +/* http://www.smspower.org/Development/MemoryMap */ +static const rc_memory_region_t _rc_memory_regions_sg1000[] = { + { 0x000000U, 0x0003FFU, 0xC000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" } + /* TODO: should cartridge memory be exposed ($0000-$BFFF)? it's usually just ROM data, but may contain on-cartridge RAM + * This not is also concerning: http://www.smspower.org/Development/MemoryMap + * Cartridges may disable the system RAM and thus take over the full 64KB address space. */ +}; +static const rc_memory_regions_t rc_memory_regions_sg1000 = { _rc_memory_regions_sg1000, 1 }; + +/* ===== Super Cassette Vision ===== */ +static const rc_memory_region_t _rc_memory_regions_scv[] = { + { 0x000000U, 0x000FFFU, 0x000000U, RC_MEMORY_TYPE_READONLY, "System ROM" }, + { 0x001000U, 0x001FFFU, 0x001000U, RC_MEMORY_TYPE_UNUSED, "" }, + { 0x002000U, 0x003FFFU, 0x002000U, RC_MEMORY_TYPE_VIDEO_RAM, "Video RAM" }, + { 0x004000U, 0x007FFFU, 0x004000U, RC_MEMORY_TYPE_UNUSED, "" }, + { 0x008000U, 0x00DFFFU, 0x008000U, RC_MEMORY_TYPE_READONLY, "Cartridge ROM" }, + { 0x00E000U, 0x00FF7FU, 0x00E000U, RC_MEMORY_TYPE_SAVE_RAM, "Cartridge RAM" }, + { 0x00FF80U, 0x00FFFFU, 0x00FF80U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" } +}; +static const rc_memory_regions_t rc_memory_regions_scv = { _rc_memory_regions_scv, 7 }; + +/* ===== Super Nintendo ===== */ +/* https://segaretro.org/Sega_Saturn_hardware_notes_(2004-04-27) */ +static const rc_memory_region_t _rc_memory_regions_snes[] = { + { 0x000000U, 0x01FFFFU, 0x7E0000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, + { 0x020000U, 0x03FFFFU, 0xFE0000U, RC_MEMORY_TYPE_SAVE_RAM, "Cartridge RAM" } +}; +static const rc_memory_regions_t rc_memory_regions_snes = { _rc_memory_regions_snes, 2 }; + +/* ===== WonderSwan ===== */ +/* http://daifukkat.su/docs/wsman/#ovr_memmap */ +static const rc_memory_region_t _rc_memory_regions_wonderswan[] = { + /* RAM ends at 0x3FFF for WonderSwan, WonderSwan color uses all 64KB */ + { 0x000000U, 0x00FFFFU, 0x000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" } +}; +static const rc_memory_regions_t rc_memory_regions_wonderswan = { _rc_memory_regions_wonderswan, 1 }; + +/* ===== Vectrex ===== */ +/* https://roadsidethoughts.com/vectrex/vectrex-memory-map.htm */ +static const rc_memory_region_t _rc_memory_regions_vectrex[] = { + { 0x000000U, 0x0003FFU, 0x00C800U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" } +}; +static const rc_memory_regions_t rc_memory_regions_vectrex = { _rc_memory_regions_vectrex, 1 }; + +/* ===== Virtual Boy ===== */ +static const rc_memory_region_t _rc_memory_regions_virtualboy[] = { + { 0x000000U, 0x00FFFFU, 0x05000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, + { 0x010000U, 0x01FFFFU, 0x06000000U, RC_MEMORY_TYPE_SAVE_RAM, "Cartridge RAM" } +}; +static const rc_memory_regions_t rc_memory_regions_virtualboy = { _rc_memory_regions_virtualboy, 2 }; + +/* ===== default ===== */ +static const rc_memory_regions_t rc_memory_regions_none = { 0, 0 }; + +const rc_memory_regions_t* rc_console_memory_regions(int console_id) +{ + switch (console_id) + { + case RC_CONSOLE_3DO: + return &rc_memory_regions_3do; + + case RC_CONSOLE_APPLE_II: + return &rc_memory_regions_appleii; + + case RC_CONSOLE_ATARI_2600: + return &rc_memory_regions_atari2600; + + case RC_CONSOLE_ATARI_7800: + return &rc_memory_regions_atari7800; + + case RC_CONSOLE_ATARI_JAGUAR: + return &rc_memory_regions_atari_jaguar; + + case RC_CONSOLE_ATARI_LYNX: + return &rc_memory_regions_atari_lynx; + + case RC_CONSOLE_COLECOVISION: + return &rc_memory_regions_colecovision; + + case RC_CONSOLE_GAMEBOY: + return &rc_memory_regions_gameboy; + + case RC_CONSOLE_GAMEBOY_COLOR: + return &rc_memory_regions_gameboy_color; + + case RC_CONSOLE_GAMEBOY_ADVANCE: + return &rc_memory_regions_gameboy_advance; + + case RC_CONSOLE_GAME_GEAR: + return &rc_memory_regions_game_gear; + + case RC_CONSOLE_INTELLIVISION: + return &rc_memory_regions_intellivision; + + case RC_CONSOLE_MASTER_SYSTEM: + return &rc_memory_regions_master_system; + + case RC_CONSOLE_MEGA_DRIVE: + case RC_CONSOLE_SEGA_32X: + /* NOTE: 32x adds an extra 512KB of memory (256KB RAM + 256KB VRAM) to the + * Genesis, but we currently don't support it. */ + return &rc_memory_regions_megadrive; + + case RC_CONSOLE_NEOGEO_POCKET: + return &rc_memory_regions_neo_geo_pocket; + + case RC_CONSOLE_NINTENDO: + return &rc_memory_regions_nes; + + case RC_CONSOLE_NINTENDO_64: + return &rc_memory_regions_n64; + + case RC_CONSOLE_NINTENDO_DS: + return &rc_memory_regions_nintendo_ds; + + case RC_CONSOLE_ORIC: + return &rc_memory_regions_oric; + + case RC_CONSOLE_PC8800: + return &rc_memory_regions_pc8800; + + case RC_CONSOLE_PC_ENGINE: + return &rc_memory_regions_pcengine; + + case RC_CONSOLE_PLAYSTATION: + return &rc_memory_regions_playstation; + + case RC_CONSOLE_POKEMON_MINI: + return &rc_memory_regions_pokemini; + + case RC_CONSOLE_SATURN: + return &rc_memory_regions_saturn; + + case RC_CONSOLE_SEGA_CD: + return &rc_memory_regions_segacd; + + case RC_CONSOLE_SG1000: + return &rc_memory_regions_sg1000; + + case RC_CONSOLE_SUPER_CASSETTEVISION: + return &rc_memory_regions_scv; + + case RC_CONSOLE_SUPER_NINTENDO: + return &rc_memory_regions_snes; + + case RC_CONSOLE_WONDERSWAN: + return &rc_memory_regions_wonderswan; + + case RC_CONSOLE_VECTREX: + return &rc_memory_regions_vectrex; + + case RC_CONSOLE_VIRTUAL_BOY: + return &rc_memory_regions_virtualboy; + + default: + return &rc_memory_regions_none; + } +} diff --git a/deps/rcheevos/src/rcheevos/expression.c b/deps/rcheevos/src/rcheevos/expression.c deleted file mode 100644 index 0adbc03a4f..0000000000 --- a/deps/rcheevos/src/rcheevos/expression.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "internal.h" - -rc_expression_t* rc_parse_expression(const char** memaddr, rc_parse_state_t* parse) { - rc_expression_t* self; - rc_term_t** next; - - self = RC_ALLOC(rc_expression_t, parse); - next = &self->terms; - - for (;;) { - *next = rc_parse_term(memaddr, 0, parse); - - if (parse->offset < 0) { - return 0; - } - - next = &(*next)->next; - - if (**memaddr != '_') { - break; - } - - (*memaddr)++; - } - - *next = 0; - return self; -} - -int rc_evaluate_expression(rc_expression_t* self, rc_eval_state_t* eval_state) { - rc_term_t* term; - int value; - - value = 0; - - for (term = self->terms; term != 0; term = term->next) { - value += rc_evaluate_term(term, eval_state); - } - - return value; -} diff --git a/deps/rcheevos/src/rcheevos/format.c b/deps/rcheevos/src/rcheevos/format.c index 33dddda41d..f7556796cf 100644 --- a/deps/rcheevos/src/rcheevos/format.c +++ b/deps/rcheevos/src/rcheevos/format.c @@ -1,5 +1,7 @@ #include "internal.h" +#include "compat.h" + #include #include @@ -11,7 +13,7 @@ int rc_parse_format(const char* format_str) { } break; - + case 'T': if (!strcmp(format_str, "IME")) { return RC_FORMAT_FRAMES; @@ -21,7 +23,7 @@ int rc_parse_format(const char* format_str) { } break; - + case 'S': if (!strcmp(format_str, "ECS")) { return RC_FORMAT_SECONDS; @@ -34,7 +36,7 @@ int rc_parse_format(const char* format_str) { } break; - + case 'M': if (!strcmp(format_str, "ILLISECS")) { return RC_FORMAT_CENTISECS; diff --git a/deps/rcheevos/src/rcheevos/internal.h b/deps/rcheevos/src/rcheevos/internal.h index 72733183c3..612df0ac0d 100644 --- a/deps/rcheevos/src/rcheevos/internal.h +++ b/deps/rcheevos/src/rcheevos/internal.h @@ -6,7 +6,6 @@ #define RC_ALLOW_ALIGN(T) struct __align_ ## T { char ch; T t; }; RC_ALLOW_ALIGN(rc_condition_t) RC_ALLOW_ALIGN(rc_condset_t) -RC_ALLOW_ALIGN(rc_expression_t) RC_ALLOW_ALIGN(rc_lboard_t) RC_ALLOW_ALIGN(rc_memref_value_t) RC_ALLOW_ALIGN(rc_operand_t) @@ -15,7 +14,6 @@ RC_ALLOW_ALIGN(rc_richpresence_display_t) RC_ALLOW_ALIGN(rc_richpresence_display_part_t) RC_ALLOW_ALIGN(rc_richpresence_lookup_t) RC_ALLOW_ALIGN(rc_richpresence_lookup_item_t) -RC_ALLOW_ALIGN(rc_term_t) RC_ALLOW_ALIGN(rc_trigger_t) RC_ALLOW_ALIGN(rc_value_t) RC_ALLOW_ALIGN(char) @@ -36,8 +34,6 @@ typedef struct { rc_condition_t condition; rc_condset_t condset; rc_trigger_t trigger; - rc_term_t term; - rc_expression_t expression; rc_lboard_t lboard; rc_memref_value_t memref_value; rc_richpresence_t richpresence; @@ -61,6 +57,8 @@ typedef struct { unsigned measured_value; /* Measured */ char was_reset; /* ResetIf triggered */ char has_hits; /* one of more hit counts is non-zero */ + char primed; /* true if all non-Trigger conditions are true */ + char measured_from_hits; /* true if the measured_value came from a condition's hit count */ } rc_eval_state_t; @@ -86,7 +84,7 @@ void rc_destroy_parse_state(rc_parse_state_t* parse); void* rc_alloc(void* pointer, int* offset, int size, int alignment, rc_scratch_t* scratch); char* rc_alloc_str(rc_parse_state_t* parse, const char* text, int length); -rc_memref_value_t* rc_alloc_memref_value(rc_parse_state_t* parse, unsigned address, char size, char is_bcd, char is_indirect); +rc_memref_value_t* rc_alloc_memref_value(rc_parse_state_t* parse, unsigned address, char size, char is_indirect); void rc_update_memref_values(rc_memref_value_t* memref, rc_peek_t peek, void* ud); void rc_update_memref_value(rc_memref_value_t* memref, rc_peek_t peek, void* ud); rc_memref_value_t* rc_get_indirect_memref(rc_memref_value_t* memref, rc_eval_state_t* eval_state); @@ -99,16 +97,11 @@ void rc_reset_condset(rc_condset_t* self); rc_condition_t* rc_parse_condition(const char** memaddr, rc_parse_state_t* parse, int is_indirect); int rc_test_condition(rc_condition_t* self, rc_eval_state_t* eval_state); +int rc_evaluate_condition_value(rc_condition_t* self, rc_eval_state_t* eval_state); int rc_parse_operand(rc_operand_t* self, const char** memaddr, int is_trigger, int is_indirect, rc_parse_state_t* parse); unsigned rc_evaluate_operand(rc_operand_t* self, rc_eval_state_t* eval_state); -rc_term_t* rc_parse_term(const char** memaddr, int is_indirect, rc_parse_state_t* parse); -int rc_evaluate_term(rc_term_t* self, rc_eval_state_t* eval_state); - -rc_expression_t* rc_parse_expression(const char** memaddr, rc_parse_state_t* parse); -int rc_evaluate_expression(rc_expression_t* self, rc_eval_state_t* eval_state); - void rc_parse_value_internal(rc_value_t* self, const char** memaddr, rc_parse_state_t* parse); void rc_parse_lboard_internal(rc_lboard_t* self, const char* memaddr, rc_parse_state_t* parse); diff --git a/deps/rcheevos/src/rcheevos/lboard.c b/deps/rcheevos/src/rcheevos/lboard.c index 11628fff71..5eb107d52f 100644 --- a/deps/rcheevos/src/rcheevos/lboard.c +++ b/deps/rcheevos/src/rcheevos/lboard.c @@ -133,7 +133,7 @@ void rc_parse_lboard_internal(rc_lboard_t* self, const char* memaddr, rc_parse_s return; } - self->started = self->submitted = 0; + self->state = RC_LBOARD_STATE_WAITING; } int rc_lboard_size(const char* memaddr) { @@ -164,82 +164,89 @@ rc_lboard_t* rc_parse_lboard(void* buffer, const char* memaddr, lua_State* L, in int rc_evaluate_lboard(rc_lboard_t* self, int* value, rc_peek_t peek, void* peek_ud, lua_State* L) { int start_ok, cancel_ok, submit_ok; - int action = -1; rc_update_memref_values(self->memrefs, peek, peek_ud); - /* ASSERT: these are always tested once every frame, to ensure delta variables work properly */ + if (self->state == RC_LBOARD_STATE_INACTIVE) + return RC_LBOARD_STATE_INACTIVE; + + /* these are always tested once every frame, to ensure hit counts work properly */ start_ok = rc_test_trigger(&self->start, peek, peek_ud, L); cancel_ok = rc_test_trigger(&self->cancel, peek, peek_ud, L); submit_ok = rc_test_trigger(&self->submit, peek, peek_ud, L); - if (self->submitted) { - /* if we've already submitted or canceled the leaderboard, don't reactivate it until it becomes inactive. */ - if (!start_ok) { - self->submitted = 0; - } - } - else if (!self->started) { - /* leaderboard is not active, if the start condition is true, activate it */ - if (start_ok && !cancel_ok) { - if (submit_ok) { - /* start and submit both true in the same frame, just submit without announcing the leaderboard is available */ - action = RC_LBOARD_TRIGGERED; - /* prevent multiple submissions/notifications */ - self->submitted = 1; + switch (self->state) + { + case RC_LBOARD_STATE_WAITING: + case RC_LBOARD_STATE_TRIGGERED: + case RC_LBOARD_STATE_CANCELED: + /* don't activate/reactivate until the start condition becomes false */ + if (start_ok) { + *value = 0; + return RC_LBOARD_STATE_INACTIVE; /* just return inactive for all of these */ } - else if (self->start.requirement != 0 || self->start.alternative != 0) { - self->started = 1; - action = RC_LBOARD_STARTED; - } - } - } - else { - /* leaderboard is active */ - if (cancel_ok) { - /* cancel condition is true, deactivate the leaderboard */ - self->started = 0; - action = RC_LBOARD_CANCELED; - /* prevent multiple cancel notifications */ - self->submitted = 1; - } - else if (submit_ok) { - /* submit condition is true, submit the current value */ - self->started = 0; - action = RC_LBOARD_TRIGGERED; - self->submitted = 1; - } - } - if (action == -1) { - action = self->started ? RC_LBOARD_ACTIVE : RC_LBOARD_INACTIVE; + /* start condition is false, allow the leaderboard to start on future frames */ + self->state = RC_LBOARD_STATE_ACTIVE; + break; + + case RC_LBOARD_STATE_ACTIVE: + /* leaderboard attempt is not in progress. if the start condition is true and the cancel condition is not, start the attempt */ + if (start_ok && !cancel_ok) { + if (submit_ok) { + /* start and submit are both true in the same frame, just submit without announcing the leaderboard is available */ + self->state = RC_LBOARD_STATE_TRIGGERED; + } + else if (self->start.requirement == 0 && self->start.alternative == 0) { + /* start condition is empty - this leaderboard is submit-only with no measured progress */ + } + else { + /* start the leaderboard attempt */ + self->state = RC_LBOARD_STATE_STARTED; + + /* reset any hit counts in the value */ + if (self->value.conditions) + rc_reset_condset(self->value.conditions); + } + } + break; + + case RC_LBOARD_STATE_STARTED: + /* leaderboard attempt in progress */ + if (cancel_ok) { + /* cancel condition is true, abort the attempt */ + self->state = RC_LBOARD_STATE_CANCELED; + } + else if (submit_ok) { + /* submit condition is true, submit the current value */ + self->state = RC_LBOARD_STATE_TRIGGERED; + } + break; } /* Calculate the value */ - switch (action) { - case RC_LBOARD_STARTED: - if (self->value.conditions) - rc_reset_condset(self->value.conditions); - /* fall through */ - case RC_LBOARD_ACTIVE: - *value = rc_evaluate_value(self->progress != 0 ? self->progress : &self->value, peek, peek_ud, L); - break; + switch (self->state) { + case RC_LBOARD_STATE_STARTED: + if (self->progress) { + *value = rc_evaluate_value(self->progress, peek, peek_ud, L); + break; + } + /* fallthrough to RC_LBOARD_STATE_TRIGGERED */ - case RC_LBOARD_TRIGGERED: + case RC_LBOARD_STATE_TRIGGERED: *value = rc_evaluate_value(&self->value, peek, peek_ud, L); break; - case RC_LBOARD_INACTIVE: - case RC_LBOARD_CANCELED: + default: *value = 0; break; } - return action; + return self->state; } void rc_reset_lboard(rc_lboard_t* self) { - self->started = self->submitted = 0; + self->state = RC_LBOARD_STATE_WAITING; rc_reset_trigger(&self->start); rc_reset_trigger(&self->submit); diff --git a/deps/rcheevos/src/rcheevos/memref.c b/deps/rcheevos/src/rcheevos/memref.c index a7c24c7446..7ce1b3906a 100644 --- a/deps/rcheevos/src/rcheevos/memref.c +++ b/deps/rcheevos/src/rcheevos/memref.c @@ -5,7 +5,7 @@ #define MEMREF_PLACEHOLDER_ADDRESS 0xFFFFFFFF -static rc_memref_value_t* rc_alloc_memref_value_sizing_mode(rc_parse_state_t* parse, unsigned address, char size, char is_bcd, char is_indirect) { +static rc_memref_value_t* rc_alloc_memref_value_sizing_mode(rc_parse_state_t* parse, unsigned address, char size, char is_indirect) { rc_memref_t* memref; int i; @@ -20,7 +20,7 @@ static rc_memref_value_t* rc_alloc_memref_value_sizing_mode(rc_parse_state_t* pa /* have to track unique address/size/bcd combinations - use scratch.memref for sizing mode */ for (i = 0; i < parse->scratch.memref_count; ++i) { memref = &parse->scratch.memref[i]; - if (memref->address == address && memref->size == size && memref->is_bcd == is_bcd) { + if (memref->address == address && memref->size == size) { return &parse->scratch.obj.memref_value; } } @@ -57,7 +57,6 @@ static rc_memref_value_t* rc_alloc_memref_value_sizing_mode(rc_parse_state_t* pa memref = &parse->scratch.memref[parse->scratch.memref_count++]; memref->address = address; memref->size = size; - memref->is_bcd = is_bcd; memref->is_indirect = is_indirect; } @@ -65,7 +64,7 @@ static rc_memref_value_t* rc_alloc_memref_value_sizing_mode(rc_parse_state_t* pa return RC_ALLOC(rc_memref_value_t, parse); } -static rc_memref_value_t* rc_alloc_memref_value_constuct_mode(rc_parse_state_t* parse, unsigned address, char size, char is_bcd, char is_indirect) { +static rc_memref_value_t* rc_alloc_memref_value_constuct_mode(rc_parse_state_t* parse, unsigned address, char size, char is_indirect) { rc_memref_value_t** next_memref_value; rc_memref_value_t* memref_value; rc_memref_value_t* indirect_memref_value; @@ -75,8 +74,8 @@ static rc_memref_value_t* rc_alloc_memref_value_constuct_mode(rc_parse_state_t* next_memref_value = parse->first_memref; while (*next_memref_value) { memref_value = *next_memref_value; - if (!memref_value->memref.is_indirect && memref_value->memref.address == address && - memref_value->memref.size == size && memref_value->memref.is_bcd == is_bcd) { + if (!memref_value->memref.is_indirect && memref_value->memref.address == address && + memref_value->memref.size == size) { return memref_value; } @@ -96,7 +95,6 @@ static rc_memref_value_t* rc_alloc_memref_value_constuct_mode(rc_parse_state_t* memref_value = RC_ALLOC(rc_memref_value_t, parse); memref_value->memref.address = address; memref_value->memref.size = size; - memref_value->memref.is_bcd = is_bcd; memref_value->memref.is_indirect = is_indirect; memref_value->value = 0; memref_value->previous = 0; @@ -110,7 +108,6 @@ static rc_memref_value_t* rc_alloc_memref_value_constuct_mode(rc_parse_state_t* indirect_memref_value = RC_ALLOC(rc_memref_value_t, parse); indirect_memref_value->memref.address = MEMREF_PLACEHOLDER_ADDRESS; indirect_memref_value->memref.size = size; - indirect_memref_value->memref.is_bcd = is_bcd; indirect_memref_value->memref.is_indirect = 1; indirect_memref_value->value = 0; indirect_memref_value->previous = 0; @@ -123,16 +120,19 @@ static rc_memref_value_t* rc_alloc_memref_value_constuct_mode(rc_parse_state_t* return memref_value; } -rc_memref_value_t* rc_alloc_memref_value(rc_parse_state_t* parse, unsigned address, char size, char is_bcd, char is_indirect) { +rc_memref_value_t* rc_alloc_memref_value(rc_parse_state_t* parse, unsigned address, char size, char is_indirect) { if (!parse->first_memref) - return rc_alloc_memref_value_sizing_mode(parse, address, size, is_bcd, is_indirect); + return rc_alloc_memref_value_sizing_mode(parse, address, size, is_indirect); - return rc_alloc_memref_value_constuct_mode(parse, address, size, is_bcd, is_indirect); + return rc_alloc_memref_value_constuct_mode(parse, address, size, is_indirect); } static unsigned rc_memref_get_value(rc_memref_t* self, rc_peek_t peek, void* ud) { unsigned value; + if (!peek) + return 0; + switch (self->size) { case RC_MEMSIZE_BIT_0: @@ -177,56 +177,19 @@ static unsigned rc_memref_get_value(rc_memref_t* self, rc_peek_t peek, void* ud) case RC_MEMSIZE_8_BITS: value = peek(self->address, 1, ud); - - if (self->is_bcd) { - value = ((value >> 4) & 0x0f) * 10 + (value & 0x0f); - } - break; case RC_MEMSIZE_16_BITS: value = peek(self->address, 2, ud); - - if (self->is_bcd) { - value = ((value >> 12) & 0x0f) * 1000 - + ((value >> 8) & 0x0f) * 100 - + ((value >> 4) & 0x0f) * 10 - + ((value >> 0) & 0x0f) * 1; - } - break; case RC_MEMSIZE_24_BITS: /* peek 4 bytes - don't expect the caller to understand 24-bit numbers */ - value = peek(self->address, 4, ud); - - if (self->is_bcd) { - value = ((value >> 20) & 0x0f) * 100000 - + ((value >> 16) & 0x0f) * 10000 - + ((value >> 12) & 0x0f) * 1000 - + ((value >> 8) & 0x0f) * 100 - + ((value >> 4) & 0x0f) * 10 - + ((value >> 0) & 0x0f) * 1; - } else { - value &= 0x00FFFFFF; - } - + value = peek(self->address, 4, ud) & 0x00FFFFFF; break; case RC_MEMSIZE_32_BITS: value = peek(self->address, 4, ud); - - if (self->is_bcd) { - value = ((value >> 28) & 0x0f) * 10000000 - + ((value >> 24) & 0x0f) * 1000000 - + ((value >> 20) & 0x0f) * 100000 - + ((value >> 16) & 0x0f) * 10000 - + ((value >> 12) & 0x0f) * 1000 - + ((value >> 8) & 0x0f) * 100 - + ((value >> 4) & 0x0f) * 10 - + ((value >> 0) & 0x0f) * 1; - } - break; default: diff --git a/deps/rcheevos/src/rcheevos/operand.c b/deps/rcheevos/src/rcheevos/operand.c index 39f80c4f98..9bea21efe9 100644 --- a/deps/rcheevos/src/rcheevos/operand.c +++ b/deps/rcheevos/src/rcheevos/operand.c @@ -70,7 +70,6 @@ static int rc_parse_operand_memory(rc_operand_t* self, const char** memaddr, rc_ const char* aux = *memaddr; char* end; unsigned long address; - char is_bcd = 0; char size; switch (*aux++) { @@ -78,15 +77,18 @@ static int rc_parse_operand_memory(rc_operand_t* self, const char** memaddr, rc_ self->type = RC_OPERAND_DELTA; break; - case 'b': case 'B': - self->type = RC_OPERAND_ADDRESS; - is_bcd = 1; - break; - case 'p': case 'P': self->type = RC_OPERAND_PRIOR; break; + case 'b': case 'B': + self->type = RC_OPERAND_BCD; + break; + + case '~': + self->type = RC_OPERAND_INVERTED; + break; + default: self->type = RC_OPERAND_ADDRESS; aux--; @@ -104,25 +106,33 @@ static int rc_parse_operand_memory(rc_operand_t* self, const char** memaddr, rc_ aux++; switch (*aux++) { - case 'm': case 'M': size = RC_MEMSIZE_BIT_0; break; - case 'n': case 'N': size = RC_MEMSIZE_BIT_1; break; - case 'o': case 'O': size = RC_MEMSIZE_BIT_2; break; - case 'p': case 'P': size = RC_MEMSIZE_BIT_3; break; - case 'q': case 'Q': size = RC_MEMSIZE_BIT_4; break; - case 'r': case 'R': size = RC_MEMSIZE_BIT_5; break; - case 's': case 'S': size = RC_MEMSIZE_BIT_6; break; - case 't': case 'T': size = RC_MEMSIZE_BIT_7; break; - case 'l': case 'L': size = RC_MEMSIZE_LOW; break; - case 'u': case 'U': size = RC_MEMSIZE_HIGH; break; - case 'h': case 'H': size = RC_MEMSIZE_8_BITS; break; - case 'w': case 'W': size = RC_MEMSIZE_24_BITS; break; - case 'x': case 'X': size = RC_MEMSIZE_32_BITS; break; + case 'm': case 'M': self->size = RC_MEMSIZE_BIT_0; size = RC_MEMSIZE_8_BITS; break; + case 'n': case 'N': self->size = RC_MEMSIZE_BIT_1; size = RC_MEMSIZE_8_BITS; break; + case 'o': case 'O': self->size = RC_MEMSIZE_BIT_2; size = RC_MEMSIZE_8_BITS; break; + case 'p': case 'P': self->size = RC_MEMSIZE_BIT_3; size = RC_MEMSIZE_8_BITS; break; + case 'q': case 'Q': self->size = RC_MEMSIZE_BIT_4; size = RC_MEMSIZE_8_BITS; break; + case 'r': case 'R': self->size = RC_MEMSIZE_BIT_5; size = RC_MEMSIZE_8_BITS; break; + case 's': case 'S': self->size = RC_MEMSIZE_BIT_6; size = RC_MEMSIZE_8_BITS; break; + case 't': case 'T': self->size = RC_MEMSIZE_BIT_7; size = RC_MEMSIZE_8_BITS; break; + case 'l': case 'L': self->size = RC_MEMSIZE_LOW; size = RC_MEMSIZE_8_BITS; break; + case 'u': case 'U': self->size = RC_MEMSIZE_HIGH; size = RC_MEMSIZE_8_BITS; break; + case 'k': case 'K': self->size = RC_MEMSIZE_BITCOUNT; size = RC_MEMSIZE_8_BITS; break; + case 'h': case 'H': self->size = size = RC_MEMSIZE_8_BITS; break; + case 'w': case 'W': self->size = size = RC_MEMSIZE_24_BITS; break; + case 'x': case 'X': self->size = size = RC_MEMSIZE_32_BITS; break; - default: /* fall through */ + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': aux--; + /* fallthrough */ case ' ': - size = RC_MEMSIZE_16_BITS; + self->size = size = RC_MEMSIZE_16_BITS; break; + + default: + return RC_INVALID_MEMORY_OPERAND; } address = strtoul(aux, &end, 16); @@ -135,7 +145,7 @@ static int rc_parse_operand_memory(rc_operand_t* self, const char** memaddr, rc_ address = 0xffffffffU; } - self->value.memref = rc_alloc_memref_value(parse, address, size, is_bcd, is_indirect); + self->value.memref = rc_alloc_memref_value(parse, address, size, is_indirect); if (parse->offset < 0) return parse->offset; @@ -143,14 +153,17 @@ static int rc_parse_operand_memory(rc_operand_t* self, const char** memaddr, rc_ return RC_OK; } -static int rc_parse_operand_trigger(rc_operand_t* self, const char** memaddr, int is_indirect, rc_parse_state_t* parse) { +int rc_parse_operand(rc_operand_t* self, const char** memaddr, int is_trigger, int is_indirect, rc_parse_state_t* parse) { const char* aux = *memaddr; char* end; int ret; unsigned long value; + int negative; + + self->size = RC_MEMSIZE_32_BITS; switch (*aux) { - case 'h': case 'H': + case 'h': case 'H': /* hex constant */ if (aux[2] == 'x' || aux[2] == 'X') { /* H0x1234 is a typo - either H1234 or 0xH1234 was probably meant */ return RC_INVALID_CONST_OPERAND; @@ -171,115 +184,9 @@ static int rc_parse_operand_trigger(rc_operand_t* self, const char** memaddr, in aux = end; break; - - case '0': - if (aux[1] == 'x' || aux[1] == 'X') { - /* fall through */ - default: - ret = rc_parse_operand_memory(self, &aux, parse, is_indirect); - if (ret < 0) { - return ret; - } - - break; - } - - /* fall through */ - case '+': case '-': - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - value = strtoul(aux, &end, 10); - - if (end == aux) { - return RC_INVALID_CONST_OPERAND; - } - - if (value > 0xffffffffU) { - value = 0xffffffffU; - } - - self->type = RC_OPERAND_CONST; - self->value.num = (unsigned)value; - - aux = end; - break; - - case '@': - ret = rc_parse_operand_lua(self, &aux, parse); - - if (ret < 0) { - return ret; - } - - break; - } - - *memaddr = aux; - return RC_OK; -} - -static int rc_parse_operand_term(rc_operand_t* self, const char** memaddr, int is_indirect, rc_parse_state_t* parse) { - const char* aux = *memaddr; - char* end; - int ret; - unsigned long value; - long svalue; - - switch (*aux) { - case 'h': case 'H': - value = strtoul(++aux, &end, 16); - - if (end == aux) { - return RC_INVALID_CONST_OPERAND; - } - - if (value > 0xffffffffU) { - value = 0xffffffffU; - } - - self->type = RC_OPERAND_CONST; - self->value.num = (unsigned)value; - - aux = end; - break; - - case 'v': case 'V': - svalue = strtol(++aux, &end, 10); - - if (end == aux) { - return RC_INVALID_CONST_OPERAND; - } - - if (svalue > 0xffffffffU) { - svalue = 0xffffffffU; - } - - self->type = RC_OPERAND_CONST; - self->value.num = (unsigned)svalue; - - aux = end; - break; - - case '0': - if (aux[1] == 'x' || aux[1] == 'X') { - /* fall through */ - default: - ret = rc_parse_operand_memory(self, &aux, parse, is_indirect); - - if (ret < 0) { - return ret; - } - - break; - } - - /* fall through */ - case '.': - case '+': case '-': - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - self->value.dbl = strtod(aux, &end); + case 'f': case 'F': /* floating point constant */ + self->value.dbl = strtod(++aux, &end); if (end == aux) { return RC_INVALID_FP_OPERAND; @@ -292,9 +199,77 @@ static int rc_parse_operand_term(rc_operand_t* self, const char** memaddr, int i else { self->type = RC_OPERAND_FP; } + aux = end; break; - + + case 'v': case 'V': /* signed integer constant */ + negative = 0; + ++aux; + + if (*aux == '-') + { + negative = 1; + ++aux; + } + else if (*aux == '+') + { + ++aux; + } + + value = strtoul(aux, &end, 10); + + if (end == aux) { + return RC_INVALID_CONST_OPERAND; + } + + if (value > 0x7fffffffU) { + value = 0x7fffffffU; + } + + self->type = RC_OPERAND_CONST; + + if (negative) + self->value.num = (unsigned)(-((long)value)); + else + self->value.num = (unsigned)value; + + aux = end; + break; + + case '0': + if (aux[1] == 'x' || aux[1] == 'X') { + /* fall through */ + default: + ret = rc_parse_operand_memory(self, &aux, parse, is_indirect); + + if (ret < 0) { + return ret; + } + + break; + } + + /* fall through for case '0' where not '0x' */ + case '+': case '-': + case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': + value = strtoul(aux, &end, 10); + + if (end == aux) { + return RC_INVALID_CONST_OPERAND; + } + + if (value > 0xffffffffU) { + value = 0xffffffffU; + } + + self->type = RC_OPERAND_CONST; + self->value.num = (unsigned)value; + + aux = end; + break; + case '@': ret = rc_parse_operand_lua(self, &aux, parse); @@ -309,15 +284,6 @@ static int rc_parse_operand_term(rc_operand_t* self, const char** memaddr, int i return RC_OK; } -int rc_parse_operand(rc_operand_t* self, const char** memaddr, int is_trigger, int is_indirect, rc_parse_state_t* parse) { - if (is_trigger) { - return rc_parse_operand_trigger(self, memaddr, is_indirect, parse); - } - else { - return rc_parse_operand_term(self, memaddr, is_indirect, parse); - } -} - #ifndef RC_DISABLE_LUA typedef struct { @@ -339,6 +305,8 @@ static int rc_luapeek(lua_State* L) { #endif /* RC_DISABLE_LUA */ +static const unsigned char rc_bits_set[16] = { 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4 }; + unsigned rc_evaluate_operand(rc_operand_t* self, rc_eval_state_t* eval_state) { #ifndef RC_DISABLE_LUA rc_luapeek_t luapeek; @@ -346,15 +314,15 @@ unsigned rc_evaluate_operand(rc_operand_t* self, rc_eval_state_t* eval_state) { unsigned value = 0; + /* step 1: read memory */ switch (self->type) { case RC_OPERAND_CONST: - value = self->value.num; - break; + return self->value.num; case RC_OPERAND_FP: - /* This is handled by rc_evaluate_expression. */ + /* This is handled by rc_evaluate_condition_value. */ return 0; - + case RC_OPERAND_LUA: #ifndef RC_DISABLE_LUA @@ -366,7 +334,7 @@ unsigned rc_evaluate_operand(rc_operand_t* self, rc_eval_state_t* eval_state) { luapeek.ud = eval_state->peek_userdata; lua_pushlightuserdata(eval_state->L, &luapeek); - + if (lua_pcall(eval_state->L, 2, 1, 0) == LUA_OK) { if (lua_isboolean(eval_state->L, -1)) { value = lua_toboolean(eval_state->L, -1); @@ -384,6 +352,8 @@ unsigned rc_evaluate_operand(rc_operand_t* self, rc_eval_state_t* eval_state) { break; case RC_OPERAND_ADDRESS: + case RC_OPERAND_BCD: + case RC_OPERAND_INVERTED: value = rc_get_indirect_memref(self->value.memref, eval_state)->value; break; @@ -396,5 +366,131 @@ unsigned rc_evaluate_operand(rc_operand_t* self, rc_eval_state_t* eval_state) { break; } + /* step 2: mask off appropriate bits */ + switch (self->size) + { + case RC_MEMSIZE_BIT_0: + value = (value >> 0) & 1; + break; + + case RC_MEMSIZE_BIT_1: + value = (value >> 1) & 1; + break; + + case RC_MEMSIZE_BIT_2: + value = (value >> 2) & 1; + break; + + case RC_MEMSIZE_BIT_3: + value = (value >> 3) & 1; + break; + + case RC_MEMSIZE_BIT_4: + value = (value >> 4) & 1; + break; + + case RC_MEMSIZE_BIT_5: + value = (value >> 5) & 1; + break; + + case RC_MEMSIZE_BIT_6: + value = (value >> 6) & 1; + break; + + case RC_MEMSIZE_BIT_7: + value = (value >> 7) & 1; + break; + + case RC_MEMSIZE_LOW: + value = value & 0x0f; + break; + + case RC_MEMSIZE_HIGH: + value = (value >> 4) & 0x0f; + break; + + case RC_MEMSIZE_BITCOUNT: + value = rc_bits_set[(value & 0x0F)] + + rc_bits_set[((value >> 4) & 0x0F)]; + break; + } + + /* step 3: apply logic */ + switch (self->type) + { + case RC_OPERAND_BCD: + switch (self->size) + { + case RC_MEMSIZE_8_BITS: + value = ((value >> 4) & 0x0f) * 10 + + ((value ) & 0x0f); + break; + + case RC_MEMSIZE_16_BITS: + value = ((value >> 12) & 0x0f) * 1000 + + ((value >> 8) & 0x0f) * 100 + + ((value >> 4) & 0x0f) * 10 + + ((value ) & 0x0f); + break; + + case RC_MEMSIZE_24_BITS: + value = ((value >> 20) & 0x0f) * 100000 + + ((value >> 16) & 0x0f) * 10000 + + ((value >> 12) & 0x0f) * 1000 + + ((value >> 8) & 0x0f) * 100 + + ((value >> 4) & 0x0f) * 10 + + ((value ) & 0x0f); + break; + + case RC_MEMSIZE_32_BITS: + value = ((value >> 28) & 0x0f) * 10000000 + + ((value >> 24) & 0x0f) * 1000000 + + ((value >> 20) & 0x0f) * 100000 + + ((value >> 16) & 0x0f) * 10000 + + ((value >> 12) & 0x0f) * 1000 + + ((value >> 8) & 0x0f) * 100 + + ((value >> 4) & 0x0f) * 10 + + ((value ) & 0x0f); + break; + + default: + break; + } + break; + + case RC_OPERAND_INVERTED: + switch (self->size) + { + case RC_MEMSIZE_LOW: + case RC_MEMSIZE_HIGH: + value ^= 0x0f; + break; + + case RC_MEMSIZE_8_BITS: + value ^= 0xff; + break; + + case RC_MEMSIZE_16_BITS: + value ^= 0xffff; + break; + + case RC_MEMSIZE_24_BITS: + value ^= 0xffffff; + break; + + case RC_MEMSIZE_32_BITS: + value ^= 0xffffffff; + break; + + default: + value ^= 0x01; + break; + } + break; + + default: + break; + } + return value; } diff --git a/deps/rcheevos/src/rcheevos/richpresence.c b/deps/rcheevos/src/rcheevos/richpresence.c index 1f9d7c3470..15fba8fec8 100644 --- a/deps/rcheevos/src/rcheevos/richpresence.c +++ b/deps/rcheevos/src/rcheevos/richpresence.c @@ -1,9 +1,8 @@ #include "internal.h" +#include "compat.h" + #include -#include -#include -#include /* special formats only used by rc_richpresence_display_part_t.display_type. must not overlap other RC_FORMAT values */ enum { @@ -116,6 +115,7 @@ static rc_richpresence_display_t* rc_parse_richpresence_display_internal(const c /* just calculating size, can't confirm lookup exists */ part = RC_ALLOC(rc_richpresence_display_part_t, parse); + in = line; line = ++ptr; while (ptr < endline && *ptr != ')') ++ptr; @@ -124,6 +124,10 @@ static rc_richpresence_display_t* rc_parse_richpresence_display_internal(const c if (parse->offset < 0) return 0; ++ptr; + } else { + /* no closing parenthesis - allocate space for the invalid string */ + --in; /* already skipped over @ */ + rc_alloc_str(parse, line, (int)(ptr - in)); } } else { @@ -139,6 +143,7 @@ static rc_richpresence_display_t* rc_parse_richpresence_display_internal(const c part->first_lookup_item = lookup->first_item; part->display_type = lookup->format; + in = line; line = ++ptr; while (ptr < endline && *ptr != ')') ++ptr; @@ -149,6 +154,12 @@ static rc_richpresence_display_t* rc_parse_richpresence_display_internal(const c return 0; ++ptr; } + else { + /* non-terminated macro, dump the macro and the remaining portion of the line */ + --in; /* already skipped over @ */ + part->display_type = RC_FORMAT_STRING; + part->text = rc_alloc_str(parse, in, (int)(ptr - in)); + } break; } @@ -170,7 +181,7 @@ static rc_richpresence_display_t* rc_parse_richpresence_display_internal(const c /* assert: the allocated string is going to be smaller than the memory used for the parameter of the macro */ part->display_type = RC_FORMAT_UNKNOWN_MACRO; - part->text = rc_alloc_str(parse, line, ptr - line); + part->text = rc_alloc_str(parse, line, (int)(ptr - line)); } } } @@ -194,7 +205,7 @@ static const char* rc_parse_richpresence_lookup(rc_richpresence_lookup_t* lookup const char* defaultlabel = 0; char* endptr = 0; unsigned key; - int chars; + unsigned chars; next = &lookup->first_item; @@ -372,7 +383,7 @@ int rc_richpresence_size(const char* script) { rc_richpresence_t* self; rc_parse_state_t parse; rc_init_parse_state(&parse, 0, 0, 0); - + self = RC_ALLOC(rc_richpresence_t, &parse); rc_parse_richpresence_internal(self, script, &parse); @@ -389,7 +400,7 @@ rc_richpresence_t* rc_parse_richpresence(void* buffer, const char* script, lua_S rc_init_parse_state_memrefs(&parse, &self->memrefs); rc_parse_richpresence_internal(self, script, &parse); - + rc_destroy_parse_state(&parse); return parse.offset >= 0 ? self : 0; } @@ -398,8 +409,10 @@ int rc_evaluate_richpresence(rc_richpresence_t* richpresence, char* buffer, unsi rc_richpresence_display_t* display; rc_richpresence_display_part_t* part; rc_richpresence_lookup_item_t* item; + char tmp[256]; char* ptr; - int chars; + const char* text; + size_t chars; unsigned value; rc_update_memref_values(richpresence->memrefs, peek, peek_ud); @@ -412,37 +425,52 @@ int rc_evaluate_richpresence(rc_richpresence_t* richpresence, char* buffer, unsi while (part) { switch (part->display_type) { case RC_FORMAT_STRING: - chars = snprintf(ptr, buffersize, "%s", part->text); + text = part->text; + chars = strlen(text); break; case RC_FORMAT_LOOKUP: value = rc_evaluate_value(&part->value, peek, peek_ud, L); item = part->first_lookup_item; if (!item) { + text = ""; chars = 0; } else { while (item->next_item && item->value != value) item = item->next_item; - chars = snprintf(ptr, buffersize, "%s", item->label); + text = item->label; + chars = strlen(text); } break; case RC_FORMAT_UNKNOWN_MACRO: - chars = snprintf(ptr, buffersize, "[Unknown macro]%s", part->text); + chars = snprintf(tmp, sizeof(tmp), "[Unknown macro]%s", part->text); + text = tmp; break; default: value = rc_evaluate_value(&part->value, peek, peek_ud, L); - chars = rc_format_value(ptr, buffersize, value, part->display_type); + chars = rc_format_value(tmp, sizeof(tmp), value, part->display_type); + text = tmp; break; } - if (chars > 0) { - ptr += chars; - buffersize -= chars; + if (chars > 0 && buffersize > 0) { + if ((unsigned)chars >= buffersize) { + /* prevent write past end of buffer */ + memcpy(ptr, text, buffersize - 1); + ptr[buffersize - 1] = '\0'; + buffersize = 0; + } + else { + memcpy(ptr, text, chars); + ptr[chars] = '\0'; + buffersize -= (unsigned)chars; + } } + ptr += chars; part = part->next; } diff --git a/deps/rcheevos/src/rcheevos/runtime.c b/deps/rcheevos/src/rcheevos/runtime.c new file mode 100644 index 0000000000..b9e9df4e76 --- /dev/null +++ b/deps/rcheevos/src/rcheevos/runtime.c @@ -0,0 +1,589 @@ +#include "internal.h" + +#include "../rhash/md5.h" + +#include +#include + +#define RC_RICHPRESENCE_DISPLAY_BUFFER_SIZE 256 + +void rc_runtime_init(rc_runtime_t* self) { + memset(self, 0, sizeof(rc_runtime_t)); + self->next_memref = &self->memrefs; +} + +void rc_runtime_destroy(rc_runtime_t* self) { + unsigned i; + + if (self->triggers) { + for (i = 0; i < self->trigger_count; ++i) + free(self->triggers[i].buffer); + + free(self->triggers); + self->triggers = NULL; + + self->trigger_count = self->trigger_capacity = 0; + } + + if (self->lboards) { + free(self->lboards); + self->lboards = NULL; + + self->lboard_count = self->lboard_capacity = 0; + } + + while (self->richpresence) { + rc_runtime_richpresence_t* previous = self->richpresence->previous; + + free(self->richpresence->buffer); + free(self->richpresence); + self->richpresence = previous; + } + + if (self->richpresence_display_buffer) { + free(self->richpresence_display_buffer); + self->richpresence_display_buffer = NULL; + } + + self->next_memref = 0; + self->memrefs = 0; +} + +static void rc_runtime_checksum(const char* memaddr, unsigned char* md5) { + md5_state_t state; + md5_init(&state); + md5_append(&state, (unsigned char*)memaddr, (int)strlen(memaddr)); + md5_finish(&state, md5); +} + +static void rc_runtime_deactivate_trigger_by_index(rc_runtime_t* self, unsigned index) { + if (self->triggers[index].owns_memrefs) { + /* if the trigger has one or more memrefs in its buffer, we can't free the buffer. + * just null out the trigger so the runtime processor will skip it + */ + rc_reset_trigger(self->triggers[index].trigger); + self->triggers[index].trigger = NULL; + } + else { + /* trigger doesn't own any memrefs, go ahead and free it, then replace it with the last trigger */ + free(self->triggers[index].buffer); + + if (--self->trigger_count > index) + memcpy(&self->triggers[index], &self->triggers[self->trigger_count], sizeof(rc_runtime_trigger_t)); + } +} + +void rc_runtime_deactivate_achievement(rc_runtime_t* self, unsigned id) { + unsigned i; + + for (i = 0; i < self->trigger_count; ++i) { + if (self->triggers[i].id == id && self->triggers[i].trigger != NULL) + rc_runtime_deactivate_trigger_by_index(self, i); + } +} + +int rc_runtime_activate_achievement(rc_runtime_t* self, unsigned id, const char* memaddr, lua_State* L, int funcs_idx) { + void* trigger_buffer; + rc_trigger_t* trigger; + rc_parse_state_t parse; + unsigned char md5[16]; + int size; + char owns_memref; + unsigned i; + + if (memaddr == NULL) + return RC_INVALID_MEMORY_OPERAND; + + rc_runtime_checksum(memaddr, md5); + + /* check to see if the id is already registered with an active trigger */ + for (i = 0; i < self->trigger_count; ++i) { + if (self->triggers[i].id == id && self->triggers[i].trigger != NULL) { + if (memcmp(self->triggers[i].md5, md5, 16) == 0) { + /* if the checksum hasn't changed, we can reuse the existing item */ + rc_reset_trigger(self->triggers[i].trigger); + return RC_OK; + } + + /* checksum has changed, deactivate the the item */ + rc_runtime_deactivate_trigger_by_index(self, i); + + /* deactivate may reorder the list so we should continue from the current index. however, we + * assume that only one trigger is active per id, so having found that, just stop scanning. + */ + break; + } + } + + /* check to see if a disabled trigger for the specific id matches the trigger being registered */ + for (i = 0; i < self->trigger_count; ++i) { + if (self->triggers[i].id == id && memcmp(self->triggers[i].md5, md5, 16) == 0) { + /* retrieve the trigger pointer from the buffer */ + size = 0; + trigger = (rc_trigger_t*)rc_alloc(self->triggers[i].buffer, &size, sizeof(rc_trigger_t), RC_ALIGNOF(rc_trigger_t), 0); + self->triggers[i].trigger = trigger; + + rc_reset_trigger(trigger); + return RC_OK; + } + } + + /* item has not been previously registered, determine how much space we need for it, and allocate it */ + size = rc_trigger_size(memaddr); + if (size < 0) + return size; + + trigger_buffer = malloc(size); + if (!trigger_buffer) + return RC_OUT_OF_MEMORY; + + /* populate the item, using the communal memrefs pool */ + rc_init_parse_state(&parse, trigger_buffer, L, funcs_idx); + parse.first_memref = &self->memrefs; + trigger = RC_ALLOC(rc_trigger_t, &parse); + rc_parse_trigger_internal(trigger, &memaddr, &parse); + rc_destroy_parse_state(&parse); + + if (parse.offset < 0) { + free(trigger_buffer); + *self->next_memref = NULL; /* disassociate any memrefs allocated by the failed parse */ + return parse.offset; + } + + /* if at least one memref was allocated within the trigger, we can't free the buffer when the trigger is deactivated */ + owns_memref = (*self->next_memref != NULL); + if (owns_memref) { + /* advance through the new memrefs so we're ready for the next allocation */ + do { + self->next_memref = &(*self->next_memref)->next; + } while (*self->next_memref != NULL); + } + + /* grow the trigger buffer if necessary */ + if (self->trigger_count == self->trigger_capacity) { + self->trigger_capacity += 32; + if (!self->triggers) + self->triggers = (rc_runtime_trigger_t*)malloc(self->trigger_capacity * sizeof(rc_runtime_trigger_t)); + else + self->triggers = (rc_runtime_trigger_t*)realloc(self->triggers, self->trigger_capacity * sizeof(rc_runtime_trigger_t)); + } + + /* assign the new trigger */ + self->triggers[self->trigger_count].id = id; + self->triggers[self->trigger_count].trigger = trigger; + self->triggers[self->trigger_count].buffer = trigger_buffer; + memcpy(self->triggers[self->trigger_count].md5, md5, 16); + self->triggers[self->trigger_count].owns_memrefs = owns_memref; + ++self->trigger_count; + + /* reset it, and return it */ + trigger->memrefs = NULL; + rc_reset_trigger(trigger); + return RC_OK; +} + +rc_trigger_t* rc_runtime_get_achievement(const rc_runtime_t* self, unsigned id) +{ + unsigned i; + + for (i = 0; i < self->trigger_count; ++i) { + if (self->triggers[i].id == id && self->triggers[i].trigger != NULL) + return self->triggers[i].trigger; + } + + return NULL; +} + +static void rc_runtime_deactivate_lboard_by_index(rc_runtime_t* self, unsigned index) { + if (self->lboards[index].owns_memrefs) { + /* if the lboard has one or more memrefs in its buffer, we can't free the buffer. + * just null out the lboard so the runtime processor will skip it + */ + rc_reset_lboard(self->lboards[index].lboard); + self->lboards[index].lboard = NULL; + } + else { + /* lboard doesn't own any memrefs, go ahead and free it, then replace it with the last lboard */ + free(self->lboards[index].buffer); + + if (--self->lboard_count > index) + memcpy(&self->lboards[index], &self->lboards[self->lboard_count], sizeof(rc_runtime_lboard_t)); + } +} + +void rc_runtime_deactivate_lboard(rc_runtime_t* self, unsigned id) { + unsigned i; + + for (i = 0; i < self->lboard_count; ++i) { + if (self->lboards[i].id == id && self->lboards[i].lboard != NULL) + rc_runtime_deactivate_lboard_by_index(self, i); + } +} + +int rc_runtime_activate_lboard(rc_runtime_t* self, unsigned id, const char* memaddr, lua_State* L, int funcs_idx) { + void* lboard_buffer; + unsigned char md5[16]; + rc_lboard_t* lboard; + rc_parse_state_t parse; + int size; + char owns_memref; + unsigned i; + + if (memaddr == 0) + return RC_INVALID_MEMORY_OPERAND; + + rc_runtime_checksum(memaddr, md5); + + /* check to see if the id is already registered with an active lboard */ + for (i = 0; i < self->lboard_count; ++i) { + if (self->lboards[i].id == id && self->lboards[i].lboard != NULL) { + if (memcmp(self->lboards[i].md5, md5, 16) == 0) { + /* if the checksum hasn't changed, we can reuse the existing item */ + rc_reset_lboard(self->lboards[i].lboard); + return RC_OK; + } + + /* checksum has changed, deactivate the the item */ + rc_runtime_deactivate_lboard_by_index(self, i); + + /* deactivate may reorder the list so we should continue from the current index. however, we + * assume that only one trigger is active per id, so having found that, just stop scanning. + */ + break; + } + } + + /* check to see if a disabled lboard for the specific id matches the lboard being registered */ + for (i = 0; i < self->lboard_count; ++i) { + if (self->lboards[i].id == id && memcmp(self->lboards[i].md5, md5, 16) == 0) { + /* retrieve the lboard pointer from the buffer */ + size = 0; + lboard = (rc_lboard_t*)rc_alloc(self->lboards[i].buffer, &size, sizeof(rc_lboard_t), RC_ALIGNOF(rc_lboard_t), 0); + self->lboards[i].lboard = lboard; + + rc_reset_lboard(lboard); + return RC_OK; + } + } + + /* item has not been previously registered, determine how much space we need for it, and allocate it */ + size = rc_lboard_size(memaddr); + if (size < 0) + return size; + + lboard_buffer = malloc(size); + if (!lboard_buffer) + return RC_OUT_OF_MEMORY; + + /* populate the item, using the communal memrefs pool */ + rc_init_parse_state(&parse, lboard_buffer, L, funcs_idx); + lboard = RC_ALLOC(rc_lboard_t, &parse); + parse.first_memref = &self->memrefs; + rc_parse_lboard_internal(lboard, memaddr, &parse); + rc_destroy_parse_state(&parse); + + if (parse.offset < 0) { + free(lboard_buffer); + *self->next_memref = NULL; /* disassociate any memrefs allocated by the failed parse */ + return parse.offset; + } + + /* if at least one memref was allocated within the trigger, we can't free the buffer when the trigger is deactivated */ + owns_memref = (*self->next_memref != NULL); + if (owns_memref) { + /* advance through the new memrefs so we're ready for the next allocation */ + do { + self->next_memref = &(*self->next_memref)->next; + } while (*self->next_memref != NULL); + } + + /* grow the lboard buffer if necessary */ + if (self->lboard_count == self->lboard_capacity) { + self->lboard_capacity += 16; + if (!self->lboards) + self->lboards = (rc_runtime_lboard_t*)malloc(self->lboard_capacity * sizeof(rc_runtime_lboard_t)); + else + self->lboards = (rc_runtime_lboard_t*)realloc(self->lboards, self->lboard_capacity * sizeof(rc_runtime_lboard_t)); + } + + /* assign the new lboard */ + self->lboards[self->lboard_count].id = id; + self->lboards[self->lboard_count].value = 0; + self->lboards[self->lboard_count].lboard = lboard; + self->lboards[self->lboard_count].buffer = lboard_buffer; + memcpy(self->lboards[self->lboard_count].md5, md5, 16); + self->lboards[self->lboard_count].owns_memrefs = owns_memref; + ++self->lboard_count; + + /* reset it, and return it */ + lboard->memrefs = NULL; + rc_reset_lboard(lboard); + return RC_OK; +} + +rc_lboard_t* rc_runtime_get_lboard(const rc_runtime_t* self, unsigned id) +{ + unsigned i; + + for (i = 0; i < self->lboard_count; ++i) { + if (self->lboards[i].id == id && self->lboards[i].lboard != NULL) + return self->lboards[i].lboard; + } + + return NULL; +} + +int rc_runtime_activate_richpresence(rc_runtime_t* self, const char* script, lua_State* L, int funcs_idx) { + rc_richpresence_t* richpresence; + rc_runtime_richpresence_t* previous; + rc_richpresence_display_t* display; + rc_parse_state_t parse; + int size; + + if (script == NULL) + return RC_MISSING_DISPLAY_STRING; + + size = rc_richpresence_size(script); + if (size < 0) + return size; + + if (!self->richpresence_display_buffer) { + self->richpresence_display_buffer = (char*)malloc(RC_RICHPRESENCE_DISPLAY_BUFFER_SIZE * sizeof(char)); + if (!self->richpresence_display_buffer) + return RC_OUT_OF_MEMORY; + } + self->richpresence_display_buffer[0] = '\0'; + + previous = self->richpresence; + if (previous) { + if (!previous->owns_memrefs) { + free(previous->buffer); + previous = previous->previous; + } + } + + self->richpresence = (rc_runtime_richpresence_t*)malloc(sizeof(rc_runtime_richpresence_t)); + if (!self->richpresence) + return RC_OUT_OF_MEMORY; + + self->richpresence->previous = previous; + self->richpresence->owns_memrefs = 0; + self->richpresence->buffer = malloc(size); + + if (!self->richpresence->buffer) + return RC_OUT_OF_MEMORY; + + rc_init_parse_state(&parse, self->richpresence->buffer, L, funcs_idx); + self->richpresence->richpresence = richpresence = RC_ALLOC(rc_richpresence_t, &parse); + parse.first_memref = &self->memrefs; + rc_parse_richpresence_internal(richpresence, script, &parse); + rc_destroy_parse_state(&parse); + + if (parse.offset < 0) { + free(self->richpresence->buffer); + free(self->richpresence); + self->richpresence = previous; + *self->next_memref = NULL; /* disassociate any memrefs allocated by the failed parse */ + return parse.offset; + } + + /* if at least one memref was allocated within the rich presence, we can't free the buffer when the rich presence is deactivated */ + self->richpresence->owns_memrefs = (*self->next_memref != NULL); + if (self->richpresence->owns_memrefs) { + /* advance through the new memrefs so we're ready for the next allocation */ + do { + self->next_memref = &(*self->next_memref)->next; + } while (*self->next_memref != NULL); + } + + richpresence->memrefs = NULL; + self->richpresence_update_timer = 0; + + if (!richpresence->first_display || !richpresence->first_display->display) { + /* non-existant rich presence, treat like static empty string */ + *self->richpresence_display_buffer = '\0'; + self->richpresence->richpresence = NULL; + } + else if (richpresence->first_display->next || /* has conditional display strings */ + richpresence->first_display->display->next || /* has macros */ + richpresence->first_display->display->value.conditions) { /* is only a macro */ + /* dynamic rich presence - reset all of the conditions */ + display = richpresence->first_display; + while (display != NULL) { + rc_reset_trigger(&display->trigger); + display = display->next; + } + + rc_evaluate_richpresence(self->richpresence->richpresence, self->richpresence_display_buffer, RC_RICHPRESENCE_DISPLAY_BUFFER_SIZE - 1, NULL, NULL, L); + } + else { + /* static rich presence - copy the static string */ + const char* src = richpresence->first_display->display->text; + char* dst = self->richpresence_display_buffer; + const char* end = dst + RC_RICHPRESENCE_DISPLAY_BUFFER_SIZE - 1; + while (*src && dst < end) + *dst++ = *src++; + *dst = '\0'; + + /* by setting self->richpresence to null, it won't be evaluated in do_frame() */ + self->richpresence = NULL; + } + + return RC_OK; +} + +const char* rc_runtime_get_richpresence(const rc_runtime_t* self) +{ + if (self->richpresence_display_buffer) + return self->richpresence_display_buffer; + + return ""; +} + +void rc_runtime_do_frame(rc_runtime_t* self, rc_runtime_event_handler_t event_handler, rc_peek_t peek, void* ud, lua_State* L) { + rc_runtime_event_t runtime_event; + unsigned i; + + runtime_event.value = 0; + + rc_update_memref_values(self->memrefs, peek, ud); + + for (i = 0; i < self->trigger_count; ++i) { + rc_trigger_t* trigger = self->triggers[i].trigger; + int trigger_state; + + if (!trigger) + continue; + + trigger_state = trigger->state; + + switch (rc_evaluate_trigger(trigger, peek, ud, L)) + { + case RC_TRIGGER_STATE_RESET: + runtime_event.type = RC_RUNTIME_EVENT_ACHIEVEMENT_RESET; + runtime_event.id = self->triggers[i].id; + event_handler(&runtime_event); + break; + + case RC_TRIGGER_STATE_TRIGGERED: + runtime_event.type = RC_RUNTIME_EVENT_ACHIEVEMENT_TRIGGERED; + runtime_event.id = self->triggers[i].id; + event_handler(&runtime_event); + break; + + case RC_TRIGGER_STATE_PAUSED: + if (trigger_state != RC_TRIGGER_STATE_PAUSED) { + runtime_event.type = RC_RUNTIME_EVENT_ACHIEVEMENT_PAUSED; + runtime_event.id = self->triggers[i].id; + event_handler(&runtime_event); + } + break; + + case RC_TRIGGER_STATE_PRIMED: + if (trigger_state != RC_TRIGGER_STATE_PRIMED) { + runtime_event.type = RC_RUNTIME_EVENT_ACHIEVEMENT_PRIMED; + runtime_event.id = self->triggers[i].id; + event_handler(&runtime_event); + } + break; + + case RC_TRIGGER_STATE_ACTIVE: + if (trigger_state != RC_TRIGGER_STATE_ACTIVE) { + runtime_event.type = RC_RUNTIME_EVENT_ACHIEVEMENT_ACTIVATED; + runtime_event.id = self->triggers[i].id; + event_handler(&runtime_event); + } + break; + } + } + + for (i = 0; i < self->lboard_count; ++i) { + rc_lboard_t* lboard = self->lboards[i].lboard; + int lboard_state; + + if (!lboard) + continue; + + lboard_state = lboard->state; + switch (rc_evaluate_lboard(lboard, &runtime_event.value, peek, ud, L)) + { + case RC_LBOARD_STATE_STARTED: /* leaderboard is running */ + if (lboard_state != RC_LBOARD_STATE_STARTED) { + self->lboards[i].value = runtime_event.value; + + runtime_event.type = RC_RUNTIME_EVENT_LBOARD_STARTED; + runtime_event.id = self->lboards[i].id; + event_handler(&runtime_event); + } + else if (runtime_event.value != self->lboards[i].value) { + self->lboards[i].value = runtime_event.value; + + runtime_event.type = RC_RUNTIME_EVENT_LBOARD_UPDATED; + runtime_event.id = self->lboards[i].id; + event_handler(&runtime_event); + } + break; + + case RC_LBOARD_STATE_CANCELED: + if (lboard_state != RC_LBOARD_STATE_CANCELED) { + runtime_event.type = RC_RUNTIME_EVENT_LBOARD_CANCELED; + runtime_event.id = self->lboards[i].id; + event_handler(&runtime_event); + } + break; + + case RC_LBOARD_STATE_TRIGGERED: + if (lboard_state != RC_RUNTIME_EVENT_LBOARD_TRIGGERED) { + runtime_event.type = RC_RUNTIME_EVENT_LBOARD_TRIGGERED; + runtime_event.id = self->lboards[i].id; + event_handler(&runtime_event); + } + break; + } + } + + if (self->richpresence && self->richpresence->richpresence) { + if (self->richpresence_update_timer == 0) { + /* generate into a temporary buffer so we don't get a partially updated string if it's read while its being updated */ + char buffer[RC_RICHPRESENCE_DISPLAY_BUFFER_SIZE]; + int len = rc_evaluate_richpresence(self->richpresence->richpresence, buffer, RC_RICHPRESENCE_DISPLAY_BUFFER_SIZE - 1, peek, ud, L); + + /* copy into the real buffer - write the 0 terminator first to ensure reads don't overflow the buffer */ + if (len > 0) { + buffer[RC_RICHPRESENCE_DISPLAY_BUFFER_SIZE - 1] = '\0'; + memcpy(self->richpresence_display_buffer, buffer, RC_RICHPRESENCE_DISPLAY_BUFFER_SIZE); + } + + /* schedule the next update for 60 frames later - most systems use a 60 fps framerate (some use more 50 or 75) + * since we're only sending to the server every two minutes, that's only every 7200 frames while active, which + * is evenly divisible by 50, 60, and 75. + */ + self->richpresence_update_timer = 59; + } + else { + self->richpresence_update_timer--; + } + } +} + +void rc_runtime_reset(rc_runtime_t* self) { + unsigned i; + + for (i = 0; i < self->trigger_count; ++i) { + if (self->triggers[i].trigger) + rc_reset_trigger(self->triggers[i].trigger); + } + + for (i = 0; i < self->lboard_count; ++i) { + if (self->lboards[i].lboard) + rc_reset_lboard(self->lboards[i].lboard); + } + + if (self->richpresence) { + rc_richpresence_display_t* display = self->richpresence->richpresence->first_display; + while (display != 0) { + rc_reset_trigger(&display->trigger); + display = display->next; + } + } +} diff --git a/deps/rcheevos/src/rcheevos/runtime_progress.c b/deps/rcheevos/src/rcheevos/runtime_progress.c new file mode 100644 index 0000000000..a57b7321b3 --- /dev/null +++ b/deps/rcheevos/src/rcheevos/runtime_progress.c @@ -0,0 +1,445 @@ +#include "internal.h" + +#include "../rhash/md5.h" + +#include + +#define RC_RUNTIME_MARKER 0x0A504152 /* RAP\n */ + +#define RC_RUNTIME_CHUNK_MEMREFS 0x4645524D /* MREF */ +#define RC_RUNTIME_CHUNK_ACHIEVEMENT 0x56484341 /* ACHV */ + +#define RC_RUNTIME_CHUNK_DONE 0x454E4F44 /* DONE */ + +typedef struct rc_runtime_progress_t { + rc_runtime_t* runtime; + + int offset; + unsigned char* buffer; + + int chunk_size_offset; + + lua_State* L; +} rc_runtime_progress_t; + +#define RC_TRIGGER_STATE_UNUPDATED 0x7F + +#define RC_MEMREF_FLAG_PREV_IS_PRIOR 0x00010000 + +static void rc_runtime_progress_write_uint(rc_runtime_progress_t* progress, unsigned value) +{ + if (progress->buffer) { + progress->buffer[progress->offset + 0] = value & 0xFF; value >>= 8; + progress->buffer[progress->offset + 1] = value & 0xFF; value >>= 8; + progress->buffer[progress->offset + 2] = value & 0xFF; value >>= 8; + progress->buffer[progress->offset + 3] = value & 0xFF; + } + + progress->offset += 4; +} + +static unsigned rc_runtime_progress_read_uint(rc_runtime_progress_t* progress) +{ + unsigned value = progress->buffer[progress->offset + 0] | + (progress->buffer[progress->offset + 1] << 8) | + (progress->buffer[progress->offset + 2] << 16) | + (progress->buffer[progress->offset + 3] << 24); + + progress->offset += 4; + return value; +} + +static void rc_runtime_progress_write_md5(rc_runtime_progress_t* progress, unsigned char* md5) +{ + if (progress->buffer) + memcpy(&progress->buffer[progress->offset], md5, 16); + + progress->offset += 16; +} + +static int rc_runtime_progress_match_md5(rc_runtime_progress_t* progress, unsigned char* md5) +{ + int result = 0; + if (progress->buffer) + result = (memcmp(&progress->buffer[progress->offset], md5, 16) == 0); + + progress->offset += 16; + + return result; +} + +static void rc_runtime_progress_start_chunk(rc_runtime_progress_t* progress, unsigned chunk_id) +{ + rc_runtime_progress_write_uint(progress, chunk_id); + + progress->chunk_size_offset = progress->offset; + + progress->offset += 4; +} + +static void rc_runtime_progress_end_chunk(rc_runtime_progress_t* progress) +{ + unsigned length; + int offset; + + progress->offset = (progress->offset + 3) & ~0x03; /* align to 4 byte boundary */ + + if (progress->buffer) { + /* ignore chunk size field when calculating chunk size */ + length = (unsigned)(progress->offset - progress->chunk_size_offset - 4); + + /* temporarily update the write pointer to write the chunk size field */ + offset = progress->offset; + progress->offset = progress->chunk_size_offset; + rc_runtime_progress_write_uint(progress, length); + progress->offset = offset; + } +} + +static void rc_runtime_progress_init(rc_runtime_progress_t* progress, rc_runtime_t* runtime, lua_State* L) +{ + memset(progress, 0, sizeof(rc_runtime_progress_t)); + progress->runtime = runtime; + progress->L = L; +} + +static int rc_runtime_progress_write_memrefs(rc_runtime_progress_t* progress) +{ + rc_memref_value_t* memref = progress->runtime->memrefs; + unsigned int flags = 0; + + rc_runtime_progress_start_chunk(progress, RC_RUNTIME_CHUNK_MEMREFS); + + while (memref) { + flags = memref->memref.size; + if (memref->previous == memref->prior) + flags |= RC_MEMREF_FLAG_PREV_IS_PRIOR; + + rc_runtime_progress_write_uint(progress, memref->memref.address); + rc_runtime_progress_write_uint(progress, flags); + rc_runtime_progress_write_uint(progress, memref->value); + rc_runtime_progress_write_uint(progress, memref->prior); + + memref = memref->next; + } + + rc_runtime_progress_end_chunk(progress); + return RC_OK; +} + +static int rc_runtime_progress_read_memrefs(rc_runtime_progress_t* progress) +{ + unsigned entries; + unsigned address, flags, value, prior; + char size; + rc_memref_value_t* memref; + + /* re-read the chunk size to determine how many memrefs are present */ + progress->offset -= 4; + entries = rc_runtime_progress_read_uint(progress) / 16; + + while (entries != 0) { + address = rc_runtime_progress_read_uint(progress); + flags = rc_runtime_progress_read_uint(progress); + value = rc_runtime_progress_read_uint(progress); + prior = rc_runtime_progress_read_uint(progress); + + size = flags & 0xFF; + + memref = progress->runtime->memrefs; + while (memref) { + if (memref->memref.address == address && memref->memref.size == size) { + memref->value = value; + memref->previous = (flags & RC_MEMREF_FLAG_PREV_IS_PRIOR) ? prior : value; + memref->prior = prior; + } + + memref = memref->next; + } + + --entries; + } + + return RC_OK; +} + +static int rc_runtime_progress_write_condset(rc_runtime_progress_t* progress, rc_condset_t* condset) +{ + rc_condition_t* cond; + + rc_runtime_progress_write_uint(progress, condset->is_paused); + + cond = condset->conditions; + while (cond) { + rc_runtime_progress_write_uint(progress, cond->current_hits); + rc_runtime_progress_write_uint(progress, cond->is_true); + + cond = cond->next; + } + + return RC_OK; +} + +static int rc_runtime_progress_read_condset(rc_runtime_progress_t* progress, rc_condset_t* condset) +{ + rc_condition_t* cond; + + condset->is_paused = rc_runtime_progress_read_uint(progress); + + cond = condset->conditions; + while (cond) { + cond->current_hits = rc_runtime_progress_read_uint(progress); + cond->is_true = rc_runtime_progress_read_uint(progress) & 0xFF; + + cond = cond->next; + } + + return RC_OK; +} + +static int rc_runtime_progress_write_trigger(rc_runtime_progress_t* progress, rc_trigger_t* trigger) +{ + rc_condset_t* condset; + int result; + + rc_runtime_progress_write_uint(progress, trigger->state); + rc_runtime_progress_write_uint(progress, trigger->measured_value); + + if (trigger->requirement) { + result = rc_runtime_progress_write_condset(progress, trigger->requirement); + if (result != RC_OK) + return result; + } + + condset = trigger->alternative; + while (condset) + { + result = rc_runtime_progress_write_condset(progress, condset); + if (result != RC_OK) + return result; + + condset = condset->next; + } + + return RC_OK; +} + +static int rc_runtime_progress_read_trigger(rc_runtime_progress_t* progress, rc_trigger_t* trigger) +{ + rc_condset_t* condset; + int result; + + trigger->state = rc_runtime_progress_read_uint(progress); + trigger->measured_value = rc_runtime_progress_read_uint(progress); + + if (trigger->requirement) { + result = rc_runtime_progress_read_condset(progress, trigger->requirement); + if (result != RC_OK) + return result; + } + + condset = trigger->alternative; + while (condset) + { + result = rc_runtime_progress_read_condset(progress, condset); + if (result != RC_OK) + return result; + + condset = condset->next; + } + + return RC_OK; +} + +static int rc_runtime_progress_write_achievements(rc_runtime_progress_t* progress) +{ + unsigned i; + int result; + + for (i = 0; i < progress->runtime->trigger_count; ++i) + { + rc_runtime_trigger_t* runtime_trigger = &progress->runtime->triggers[i]; + if (!runtime_trigger->trigger) + continue; + + switch (runtime_trigger->trigger->state) + { + case RC_TRIGGER_STATE_INACTIVE: + case RC_TRIGGER_STATE_TRIGGERED: + /* don't store state for inactive or triggered achievements */ + break; + + default: + break; + } + + rc_runtime_progress_start_chunk(progress, RC_RUNTIME_CHUNK_ACHIEVEMENT); + rc_runtime_progress_write_uint(progress, runtime_trigger->id); + rc_runtime_progress_write_md5(progress, runtime_trigger->md5); + + result = rc_runtime_progress_write_trigger(progress, runtime_trigger->trigger); + if (result != RC_OK) + return result; + + rc_runtime_progress_end_chunk(progress); + } + + return RC_OK; +} + +static int rc_runtime_progress_read_achievement(rc_runtime_progress_t* progress) +{ + unsigned id = rc_runtime_progress_read_uint(progress); + unsigned i; + + for (i = 0; i < progress->runtime->trigger_count; ++i) { + rc_runtime_trigger_t* runtime_trigger = &progress->runtime->triggers[i]; + if (runtime_trigger->id == id && runtime_trigger->trigger != NULL) { + /* ignore triggered and waiting achievements */ + if (runtime_trigger->trigger->state == RC_TRIGGER_STATE_UNUPDATED) { + /* only update state if definition hasn't changed (md5 matches) */ + if (rc_runtime_progress_match_md5(progress, runtime_trigger->md5)) + return rc_runtime_progress_read_trigger(progress, runtime_trigger->trigger); + break; + } + } + } + + return RC_OK; +} + +static int rc_runtime_progress_serialize_internal(rc_runtime_progress_t* progress) +{ + md5_state_t state; + unsigned char md5[16]; + int result; + + rc_runtime_progress_write_uint(progress, RC_RUNTIME_MARKER); + + if ((result = rc_runtime_progress_write_memrefs(progress)) != RC_OK) + return result; + + if ((result = rc_runtime_progress_write_achievements(progress)) != RC_OK) + return result; + + rc_runtime_progress_write_uint(progress, RC_RUNTIME_CHUNK_DONE); + rc_runtime_progress_write_uint(progress, 16); + + if (progress->buffer) { + md5_init(&state); + md5_append(&state, progress->buffer, progress->offset); + md5_finish(&state, md5); + } + + rc_runtime_progress_write_md5(progress, md5); + + return RC_OK; +} + +int rc_runtime_progress_size(const rc_runtime_t* runtime, lua_State* L) +{ + rc_runtime_progress_t progress; + int result; + + rc_runtime_progress_init(&progress, (rc_runtime_t*)runtime, L); + + result = rc_runtime_progress_serialize_internal(&progress); + if (result != RC_OK) + return result; + + return progress.offset; +} + +int rc_runtime_serialize_progress(void* buffer, const rc_runtime_t* runtime, lua_State* L) +{ + rc_runtime_progress_t progress; + + rc_runtime_progress_init(&progress, (rc_runtime_t*)runtime, L); + progress.buffer = (unsigned char*)buffer; + + return rc_runtime_progress_serialize_internal(&progress); +} + +int rc_runtime_deserialize_progress(rc_runtime_t* runtime, const unsigned char* serialized, lua_State* L) +{ + rc_runtime_progress_t progress; + md5_state_t state; + unsigned char md5[16]; + unsigned chunk_id; + unsigned chunk_size; + unsigned next_chunk_offset; + unsigned i; + int result = RC_OK; + + rc_runtime_progress_init(&progress, runtime, L); + progress.buffer = (unsigned char*)serialized; + + if (rc_runtime_progress_read_uint(&progress) != RC_RUNTIME_MARKER) { + rc_runtime_reset(runtime); + return RC_INVALID_STATE; + } + + for (i = 0; i < runtime->trigger_count; ++i) { + rc_runtime_trigger_t* runtime_trigger = &runtime->triggers[i]; + if (runtime_trigger->trigger) { + switch (runtime_trigger->trigger->state) + { + case RC_TRIGGER_STATE_INACTIVE: + case RC_TRIGGER_STATE_TRIGGERED: + /* don't update state for inactive or triggered achievements */ + break; + + default: + /* mark active achievements as unupdated. anything that's still unupdated + * after deserializing the progress will be reset to waiting */ + runtime_trigger->trigger->state = RC_TRIGGER_STATE_UNUPDATED; + break; + } + } + } + + do { + chunk_id = rc_runtime_progress_read_uint(&progress); + chunk_size = rc_runtime_progress_read_uint(&progress); + next_chunk_offset = progress.offset + chunk_size; + + switch (chunk_id) + { + case RC_RUNTIME_CHUNK_MEMREFS: + result = rc_runtime_progress_read_memrefs(&progress); + break; + + case RC_RUNTIME_CHUNK_ACHIEVEMENT: + result = rc_runtime_progress_read_achievement(&progress); + break; + + case RC_RUNTIME_CHUNK_DONE: + md5_init(&state); + md5_append(&state, progress.buffer, progress.offset); + md5_finish(&state, md5); + if (!rc_runtime_progress_match_md5(&progress, md5)) + result = RC_INVALID_STATE; + break; + + default: + if (chunk_size & 0xFFFF0000) + result = RC_INVALID_STATE; /* assume unknown chunk > 64KB is invalid */ + break; + } + + progress.offset = next_chunk_offset; + } while (result == RC_OK && chunk_id != RC_RUNTIME_CHUNK_DONE); + + if (result != RC_OK) { + rc_runtime_reset(runtime); + } + else { + for (i = 0; i < runtime->trigger_count; ++i) { + rc_trigger_t* trigger = runtime->triggers[i].trigger; + if (trigger && trigger->state == RC_TRIGGER_STATE_UNUPDATED) + rc_reset_trigger(trigger); + } + } + + return result; +} diff --git a/deps/rcheevos/src/rcheevos/term.c b/deps/rcheevos/src/rcheevos/term.c deleted file mode 100644 index 266dc0570c..0000000000 --- a/deps/rcheevos/src/rcheevos/term.c +++ /dev/null @@ -1,103 +0,0 @@ -#include "internal.h" - -rc_term_t* rc_parse_term(const char** memaddr, int is_indirect, rc_parse_state_t* parse) { - rc_term_t* self; - const char* aux; - char size; - int ret2; - - aux = *memaddr; - self = RC_ALLOC(rc_term_t, parse); - self->invert = 0; - - ret2 = rc_parse_operand(&self->operand1, &aux, 0, is_indirect, parse); - - if (ret2 < 0) { - parse->offset = ret2; - return 0; - } - - if (*aux == '*') { - aux++; - - if (*aux == '~') { - aux++; - self->invert = 1; - } - - ret2 = rc_parse_operand(&self->operand2, &aux, 0, is_indirect, parse); - - if (ret2 < 0) { - parse->offset = ret2; - return 0; - } - - if (self->invert) { - switch (self->operand2.type) { - case RC_OPERAND_ADDRESS: - case RC_OPERAND_DELTA: - case RC_OPERAND_PRIOR: - size = self->operand2.value.memref->memref.size; - break; - default: - size = RC_MEMSIZE_32_BITS; - break; - } - - switch (size) { - case RC_MEMSIZE_BIT_0: - case RC_MEMSIZE_BIT_1: - case RC_MEMSIZE_BIT_2: - case RC_MEMSIZE_BIT_3: - case RC_MEMSIZE_BIT_4: - case RC_MEMSIZE_BIT_5: - case RC_MEMSIZE_BIT_6: - case RC_MEMSIZE_BIT_7: - /* invert is already 1 */ - break; - - case RC_MEMSIZE_LOW: - case RC_MEMSIZE_HIGH: - self->invert = 0xf; - break; - - case RC_MEMSIZE_8_BITS: - self->invert = 0xffU; - break; - - case RC_MEMSIZE_16_BITS: - self->invert = 0xffffU; - break; - - case RC_MEMSIZE_24_BITS: - self->invert = 0xffffffU; - break; - - case RC_MEMSIZE_32_BITS: - self->invert = 0xffffffffU; - break; - } - } - } - else { - self->operand2.type = RC_OPERAND_CONST; - self->operand2.value.num = 1; - } - - *memaddr = aux; - return self; -} - -int rc_evaluate_term(rc_term_t* self, rc_eval_state_t* eval_state) { - /* Operands are usually memory references and are always retrieved as unsigned. The floating - * point operand is signed, and will automatically make the result signed. Otherwise, multiply - * by the secondary operand (which is usually 1) and cast to signed. - */ - unsigned value = rc_evaluate_operand(&self->operand1, eval_state); - - if (self->operand2.type != RC_OPERAND_FP) { - return (int)(value * (rc_evaluate_operand(&self->operand2, eval_state) ^ self->invert)); - } - - return (int)((double)value * self->operand2.value.dbl); -} diff --git a/deps/rcheevos/src/rcheevos/trigger.c b/deps/rcheevos/src/rcheevos/trigger.c index fdb9002fb8..73f0e7839c 100644 --- a/deps/rcheevos/src/rcheevos/trigger.c +++ b/deps/rcheevos/src/rcheevos/trigger.c @@ -1,10 +1,7 @@ #include "internal.h" #include -#if !defined( __CELLOS_LV2__) && !defined(__MWERKS__) -#include -#endif -#include +#include /* memset */ void rc_parse_trigger_internal(rc_trigger_t* self, const char** memaddr, rc_parse_state_t* parse) { rc_condset_t** next; @@ -36,7 +33,7 @@ void rc_parse_trigger_internal(rc_trigger_t* self, const char** memaddr, rc_pars next = &(*next)->next; } - + *next = 0; *memaddr = aux; @@ -62,7 +59,7 @@ rc_trigger_t* rc_parse_trigger(void* buffer, const char* memaddr, lua_State* L, rc_trigger_t* self; rc_parse_state_t parse; rc_init_parse_state(&parse, buffer, L, funcs_ndx); - + self = RC_ALLOC(rc_trigger_t, &parse); rc_init_parse_state_memrefs(&parse, &self->memrefs); @@ -92,14 +89,15 @@ int rc_evaluate_trigger(rc_trigger_t* self, rc_peek_t peek, void* ud, lua_State* rc_condset_t* condset; int ret; char is_paused; + char is_primed; /* previously triggered, do nothing - return INACTIVE so caller doesn't report a repeated trigger */ if (self->state == RC_TRIGGER_STATE_TRIGGERED) - return RC_TRIGGER_STATE_INACTIVE; + return RC_TRIGGER_STATE_INACTIVE; rc_update_memref_values(self->memrefs, peek, ud); - /* not yet active, only update the memrefs - so deltas are corrent when it becomes active */ + /* not yet active, only update the memrefs - so deltas are correct when it becomes active */ if (self->state == RC_TRIGGER_STATE_INACTIVE) return RC_TRIGGER_STATE_INACTIVE; @@ -109,22 +107,41 @@ int rc_evaluate_trigger(rc_trigger_t* self, rc_peek_t peek, void* ud, lua_State* eval_state.peek_userdata = ud; eval_state.L = L; - ret = self->requirement != 0 ? rc_test_condset(self->requirement, &eval_state) : 1; - condset = self->alternative; + if (self->requirement != NULL) { + ret = rc_test_condset(self->requirement, &eval_state); + is_paused = self->requirement->is_paused; + is_primed = eval_state.primed; + } else { + ret = 1; + is_paused = 0; + is_primed = 1; + } + condset = self->alternative; if (condset) { int sub = 0; + char sub_paused = 1; + char sub_primed = 0; do { sub |= rc_test_condset(condset, &eval_state); - condset = condset->next; - } - while (condset != 0); + sub_paused &= condset->is_paused; + sub_primed |= eval_state.primed; + condset = condset->next; + } while (condset != 0); + + /* to trigger, the core must be true and at least one alt must be true */ ret &= sub; + is_primed &= sub_primed; + + /* if the core is not paused, all alts must be paused to count as a paused trigger */ + is_paused |= sub_paused; } - self->measured_value = eval_state.measured_value; + /* if paused, the measured value may not be captured, keep the old value */ + if (!is_paused) + self->measured_value = eval_state.measured_value; /* if the state is WAITING and the trigger is ready to fire, ignore it and reset the hit counts */ /* otherwise, if the state is WAITING, proceed to activating the trigger */ @@ -138,6 +155,10 @@ int rc_evaluate_trigger(rc_trigger_t* self, rc_peek_t peek, void* ud, lua_State* /* if any ResetIf condition was true, reset the hit counts */ rc_reset_trigger_hitcounts(self); + /* if the measured value came from a hit count, reset it too */ + if (eval_state.measured_from_hits) + self->measured_value = 0; + /* if there were hit counts to clear, return RESET, but don't change the state */ if (self->has_hits) { self->has_hits = 0; @@ -146,6 +167,7 @@ int rc_evaluate_trigger(rc_trigger_t* self, rc_peek_t peek, void* ud, lua_State* /* any hits that were tallied were just reset */ eval_state.has_hits = 0; + is_primed = 0; } else if (ret) { /* trigger was triggered */ @@ -156,20 +178,16 @@ int rc_evaluate_trigger(rc_trigger_t* self, rc_peek_t peek, void* ud, lua_State* /* did not trigger this frame - update the information we'll need for next time */ self->has_hits = eval_state.has_hits; - /* check to see if the trigger is paused */ - is_paused = (self->requirement != NULL) ? self->requirement->is_paused : 0; - if (!is_paused) { - /* if the core is not paused, all alts must be paused to count as a paused trigger */ - is_paused = (self->alternative != NULL); - for (condset = self->alternative; condset != NULL; condset = condset->next) { - if (!condset->is_paused) { - is_paused = 0; - break; - } - } + if (is_paused) { + self->state = RC_TRIGGER_STATE_PAUSED; + } + else if (is_primed) { + self->state = RC_TRIGGER_STATE_PRIMED; + } + else { + self->state = RC_TRIGGER_STATE_ACTIVE; } - self->state = is_paused ? RC_TRIGGER_STATE_PAUSED : RC_TRIGGER_STATE_ACTIVE; return self->state; } @@ -184,4 +202,6 @@ void rc_reset_trigger(rc_trigger_t* self) { rc_reset_trigger_hitcounts(self); self->state = RC_TRIGGER_STATE_WAITING; + self->measured_value = 0; + self->has_hits = 0; } diff --git a/deps/rcheevos/src/rcheevos/value.c b/deps/rcheevos/src/rcheevos/value.c index fcbc6c21e2..2414dada16 100644 --- a/deps/rcheevos/src/rcheevos/value.c +++ b/deps/rcheevos/src/rcheevos/value.c @@ -1,9 +1,7 @@ #include "internal.h" -#if !defined( __CELLOS_LV2__) && !defined(__MWERKS__) -#include -#endif -#include +#include /* memset */ +#include /* isdigit */ static void rc_parse_cond_value(rc_value_t* self, const char** memaddr, rc_parse_state_t* parse) { rc_condition_t** next; @@ -12,12 +10,10 @@ static void rc_parse_cond_value(rc_value_t* self, const char** memaddr, rc_parse has_measured = 0; in_add_address = 0; - self->expressions = 0; - /* this largely duplicates rc_parse_condset, but we cannot call it directly, as we need to check the + /* this largely duplicates rc_parse_condset, but we cannot call it directly, as we need to check the * type of each condition as we go */ self->conditions = RC_ALLOC(rc_condset_t, parse); - self->conditions->next = 0; self->conditions->has_pause = 0; next = &self->conditions->conditions; @@ -49,7 +45,7 @@ static void rc_parse_cond_value(rc_value_t* self, const char** memaddr, rc_parse return; } has_measured = 1; - if ((*next)->required_hits == 0 && (*next)->oper != RC_CONDITION_NONE) + if ((*next)->required_hits == 0 && (*next)->oper != RC_OPERATOR_NONE) (*next)->required_hits = (unsigned)-1; break; @@ -69,42 +65,125 @@ static void rc_parse_cond_value(rc_value_t* self, const char** memaddr, rc_parse (*memaddr)++; } - *next = 0; - if (!has_measured) { parse->offset = RC_MISSING_VALUE_MEASURED; } + + if (parse->buffer) { + *next = 0; + self->conditions->next = 0; + } } -void rc_parse_value_internal(rc_value_t* self, const char** memaddr, rc_parse_state_t* parse) { - rc_expression_t** next; +void rc_parse_legacy_value(rc_value_t* self, const char** memaddr, rc_parse_state_t* parse) { + rc_condition_t** next; + rc_condset_t** next_clause; + rc_condition_t* cond; + char buffer[64] = "A:"; + const char* buffer_ptr; + char* ptr; + int end_of_clause; - /* if it starts with a condition flag (M: A: B: C:), parse the conditions */ - if ((*memaddr)[1] == ':') { - rc_parse_cond_value(self, memaddr, parse); - return; - } + /* convert legacy format into condset */ + self->conditions = RC_ALLOC(rc_condset_t, parse); + self->conditions->has_pause = 0; - self->conditions = 0; - next = &self->expressions; + next = &self->conditions->conditions; + next_clause = &self->conditions->next; for (;;) { - *next = rc_parse_expression(memaddr, parse); + ptr = &buffer[2]; + end_of_clause = 0; + do { + switch (**memaddr) { + case '_': /* add next */ + case '$': /* maximum of */ + case '\0': /* end of string */ + case ':': /* end of leaderboard clause */ + case ')': /* end of rich presence macro */ + end_of_clause = 1; + *ptr = '\0'; + break; + + case '*': + *ptr++ = '*'; + + buffer_ptr = *memaddr + 1; + if (*buffer_ptr == '-') { + /* negative value automatically needs prefix, 'f' handles both float and digits, so use it */ + *ptr++ = 'f'; + } + else { + /* if it looks like a floating point number, add the 'f' prefix */ + while (isdigit(*buffer_ptr)) + ++buffer_ptr; + if (*buffer_ptr == '.') + *ptr++ = 'f'; + } + break; + + default: + *ptr++ = **memaddr; + break; + } + + ++(*memaddr); + } while (!end_of_clause); + + buffer_ptr = buffer; + cond = rc_parse_condition(&buffer_ptr, parse, 0); if (parse->offset < 0) { return; } - next = &(*next)->next; + switch (cond->oper) { + case RC_OPERATOR_MULT: + case RC_OPERATOR_DIV: + case RC_OPERATOR_AND: + case RC_OPERATOR_NONE: + break; - if (**memaddr != '$') { - break; + default: + parse->offset = RC_INVALID_OPERATOR; + return; } - (*memaddr)++; - } + cond->pause = 0; + *next = cond; - *next = 0; + switch ((*memaddr)[-1]) { + case '_': /* add next */ + next = &cond->next; + break; + + case '$': /* max of */ + cond->type = RC_CONDITION_MEASURED; + cond->next = 0; + *next_clause = RC_ALLOC(rc_condset_t, parse); + (*next_clause)->has_pause = 0; + next = &(*next_clause)->conditions; + next_clause = &(*next_clause)->next; + break; + + default: /* end of valid string */ + --(*memaddr); /* undo the increment we performed when copying the string */ + cond->type = RC_CONDITION_MEASURED; + cond->next = 0; + *next_clause = 0; + return; + } + } +} + +void rc_parse_value_internal(rc_value_t* self, const char** memaddr, rc_parse_state_t* parse) { + /* if it starts with a condition flag (M: A: B: C:), parse the conditions */ + if ((*memaddr)[1] == ':') { + rc_parse_cond_value(self, memaddr, parse); + } + else { + rc_parse_legacy_value(self, memaddr, parse); + } } int rc_value_size(const char* memaddr) { @@ -123,7 +202,7 @@ rc_value_t* rc_parse_value(void* buffer, const char* memaddr, lua_State* L, int rc_value_t* self; rc_parse_state_t parse; rc_init_parse_state(&parse, buffer, L, funcs_ndx); - + self = RC_ALLOC(rc_value_t, &parse); rc_init_parse_state_memrefs(&parse, &self->memrefs); @@ -133,26 +212,11 @@ rc_value_t* rc_parse_value(void* buffer, const char* memaddr, lua_State* L, int return parse.offset >= 0 ? self : 0; } -static int rc_evaluate_expr_value(rc_value_t* self, rc_eval_state_t* eval_state) { - rc_expression_t* exp; - int value, max; - - exp = self->expressions; - max = rc_evaluate_expression(exp, eval_state); - - for (exp = exp->next; exp != 0; exp = exp->next) { - value = rc_evaluate_expression(exp, eval_state); - - if (value > max) { - max = value; - } - } - - return max; -} - int rc_evaluate_value(rc_value_t* self, rc_peek_t peek, void* ud, lua_State* L) { rc_eval_state_t eval_state; + rc_condset_t* condset; + int result = 0; + memset(&eval_state, 0, sizeof(eval_state)); eval_state.peek = peek; eval_state.peek_userdata = ud; @@ -160,10 +224,17 @@ int rc_evaluate_value(rc_value_t* self, rc_peek_t peek, void* ud, lua_State* L) rc_update_memref_values(self->memrefs, peek, ud); - if (self->expressions) { - return rc_evaluate_expr_value(self, &eval_state); + rc_test_condset(self->conditions, &eval_state); + result = (int)eval_state.measured_value; + + condset = self->conditions->next; + while (condset != NULL) { + rc_test_condset(condset, &eval_state); + if ((int)eval_state.measured_value > result) + result = (int)eval_state.measured_value; + + condset = condset->next; } - rc_test_condset(self->conditions, &eval_state); - return (int)eval_state.measured_value; + return result; } diff --git a/deps/rcheevos/src/rhash/hash.c b/deps/rcheevos/src/rhash/hash.c new file mode 100644 index 0000000000..f69e696b5b --- /dev/null +++ b/deps/rcheevos/src/rhash/hash.c @@ -0,0 +1,1491 @@ +#ifdef RARCH_INTERNAL + /* explicit path to avoid conflict with libretro-common/include/rhash.h */ + #include "../../include/rhash.h" +#else + #include "rhash.h" +#endif + +#include "../rcheevos/compat.h" + +#include "md5.h" + +#include + +/* arbitrary limit to prevent allocating and hashing large files */ +#define MAX_BUFFER_SIZE 64 * 1024 * 1024 + +const char* rc_path_get_filename(const char* path); + +/* ===================================================== */ + +static rc_hash_message_callback error_message_callback = NULL; +rc_hash_message_callback verbose_message_callback = NULL; + +void rc_hash_init_error_message_callback(rc_hash_message_callback callback) +{ + error_message_callback = callback; +} + +int rc_hash_error(const char* message) +{ + if (error_message_callback) + error_message_callback(message); + + return 0; +} + +void rc_hash_init_verbose_message_callback(rc_hash_message_callback callback) +{ + verbose_message_callback = callback; +} + +static void rc_hash_verbose(const char* message) +{ + if (verbose_message_callback) + verbose_message_callback(message); +} + +/* ===================================================== */ + +static struct rc_hash_filereader filereader_funcs; +static struct rc_hash_filereader* filereader = NULL; + +void rc_hash_init_custom_filereader(struct rc_hash_filereader* reader) +{ + memcpy(&filereader_funcs, reader, sizeof(filereader_funcs)); + filereader = &filereader_funcs; +} + +static void* filereader_open(const char* path) +{ + return fopen(path, "rb"); +} + +static void filereader_seek(void* file_handle, size_t offset, int origin) +{ + fseek((FILE*)file_handle, (long)offset, origin); +} + +static size_t filereader_tell(void* file_handle) +{ + return ftell((FILE*)file_handle); +} + +static size_t filereader_read(void* file_handle, void* buffer, size_t requested_bytes) +{ + return fread(buffer, 1, requested_bytes, (FILE*)file_handle); +} + +static void filereader_close(void* file_handle) +{ + fclose((FILE*)file_handle); +} + +void* rc_file_open(const char* path) +{ + void* handle; + + if (!filereader) + { + filereader_funcs.open = filereader_open; + filereader_funcs.seek = filereader_seek; + filereader_funcs.tell = filereader_tell; + filereader_funcs.read = filereader_read; + filereader_funcs.close = filereader_close; + + filereader = &filereader_funcs; + } + + handle = filereader->open(path); + if (handle && verbose_message_callback) + { + char message[1024]; + snprintf(message, sizeof(message), "Opened %s", rc_path_get_filename(path)); + verbose_message_callback(message); + } + + return handle; +} + +void rc_file_seek(void* file_handle, size_t offset, int origin) +{ + if (filereader) + filereader->seek(file_handle, offset, origin); +} + +size_t rc_file_tell(void* file_handle) +{ + return (filereader) ? filereader->tell(file_handle) : 0; +} + +size_t rc_file_read(void* file_handle, void* buffer, int requested_bytes) +{ + return (filereader) ? filereader->read(file_handle, buffer, requested_bytes) : 0; +} + +void rc_file_close(void* file_handle) +{ + if (filereader) + filereader->close(file_handle); +} + +/* ===================================================== */ + +static struct rc_hash_cdreader cdreader_funcs; +static struct rc_hash_cdreader* cdreader = NULL; + +void rc_hash_init_custom_cdreader(struct rc_hash_cdreader* reader) +{ + memcpy(&cdreader_funcs, reader, sizeof(cdreader_funcs)); + cdreader = &cdreader_funcs; +} + +static void* rc_cd_open_track(const char* path, uint32_t track) +{ + if (cdreader && cdreader->open_track) + return cdreader->open_track(path, track); + + rc_hash_error("no hook registered for cdreader_open_track"); + return NULL; +} + +static size_t rc_cd_read_sector(void* track_handle, uint32_t sector, void* buffer, size_t requested_bytes) +{ + if (cdreader && cdreader->read_sector) + return cdreader->read_sector(track_handle, sector, buffer, requested_bytes); + + rc_hash_error("no hook registered for cdreader_read_sector"); + return 0; +} + +static void rc_cd_close_track(void* track_handle) +{ + if (cdreader && cdreader->close_track) + { + cdreader->close_track(track_handle); + return; + } + + rc_hash_error("no hook registered for cdreader_close_track"); +} + +static uint32_t rc_cd_find_file_sector(void* track_handle, const char* path, unsigned* size) +{ + uint8_t buffer[2048], *tmp; + int sector; + size_t filename_length; + const char* slash; + + if (!track_handle) + return 0; + + filename_length = strlen(path); + slash = strrchr(path, '\\'); + if (slash) + { + /* find the directory record for the first part of the path */ + memcpy(buffer, path, slash - path); + buffer[slash - path] = '\0'; + + sector = rc_cd_find_file_sector(track_handle, (const char *)buffer, NULL); + if (!sector) + return 0; + + ++slash; + filename_length -= (slash - path); + path = slash; + } + else + { + /* find the cd information (always 16 frames in) */ + if (!rc_cd_read_sector(track_handle, 16, buffer, 256)) + return 0; + + /* the directory_record starts at 156, the sector containing the table of contents is 2 bytes into that. + * https://www.cdroller.com/htm/readdata.html + */ + sector = buffer[156 + 2] | (buffer[156 + 3] << 8) | (buffer[156 + 4] << 16); + } + + /* fetch and process the directory record */ + if (!rc_cd_read_sector(track_handle, sector, buffer, sizeof(buffer))) + return 0; + + tmp = buffer; + while (tmp < buffer + sizeof(buffer)) + { + if (!*tmp) + return 0; + + /* filename is 33 bytes into the record and the format is "FILENAME;version" or "DIRECTORY" */ + if ((tmp[33 + filename_length] == ';' || tmp[33 + filename_length] == '\0') && + strncasecmp((const char*)(tmp + 33), path, filename_length) == 0) + { + sector = tmp[2] | (tmp[3] << 8) | (tmp[4] << 16); + + if (verbose_message_callback) + { + snprintf((char*)buffer, sizeof(buffer), "Found %s at sector %d", path, sector); + verbose_message_callback((const char*)buffer); + } + + if (size) + *size = tmp[10] | (tmp[11] << 8) | (tmp[12] << 16) | (tmp[13] << 24); + + return sector; + } + + /* the first byte of the record is the length of the record */ + tmp += *tmp; + } + + return 0; +} + +/* ===================================================== */ + +const char* rc_path_get_filename(const char* path) +{ + const char* ptr = path + strlen(path); + do + { + if (ptr[-1] == '/' || ptr[-1] == '\\') + break; + + --ptr; + } while (ptr > path); + + return ptr; +} + +static const char* rc_path_get_extension(const char* path) +{ + const char* ptr = path + strlen(path); + do + { + if (ptr[-1] == '.') + break; + + --ptr; + } while (ptr > path); + + return ptr; +} + +int rc_path_compare_extension(const char* path, const char* ext) +{ + size_t path_len = strlen(path); + size_t ext_len = strlen(ext); + const char* ptr = path + path_len - ext_len; + if (ptr[-1] != '.') + return 0; + + if (memcmp(ptr, ext, ext_len) == 0) + return 1; + + do + { + if (tolower(*ptr) != *ext) + return 0; + + ++ext; + ++ptr; + } while (*ptr); + + return 1; +} + +/* ===================================================== */ + +static int rc_hash_finalize(md5_state_t* md5, char hash[33]) +{ + md5_byte_t digest[16]; + + md5_finish(md5, digest); + + /* NOTE: sizeof(hash) is 4 because it's still treated like a pointer, despite specifying a size */ + snprintf(hash, 33, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", + digest[0], digest[1], digest[2], digest[3], digest[4], digest[5], digest[6], digest[7], + digest[8], digest[9], digest[10], digest[11], digest[12], digest[13], digest[14], digest[15] + ); + + if (verbose_message_callback) + { + char message[128]; + snprintf(message, sizeof(message), "Generated hash %s", hash); + verbose_message_callback(message); + } + + return 1; +} + +static int rc_hash_buffer(char hash[33], uint8_t* buffer, size_t buffer_size) +{ + md5_state_t md5; + md5_init(&md5); + + if (buffer_size > MAX_BUFFER_SIZE) + buffer_size = MAX_BUFFER_SIZE; + + md5_append(&md5, buffer, (int)buffer_size); + + if (verbose_message_callback) + { + char message[128]; + snprintf(message, sizeof(message), "Hashing %u byte buffer", (unsigned)buffer_size); + verbose_message_callback(message); + } + + return rc_hash_finalize(&md5, hash); +} + +static int rc_hash_3do(char hash[33], const char* path) +{ + uint8_t buffer[2048]; + const uint8_t operafs_identifier[7] = { 0x01, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x01 }; + void* track_handle; + md5_state_t md5; + int sector; + int block_size, block_location; + int offset, stop; + size_t size = 0; + + track_handle = rc_cd_open_track(path, 1); + if (!track_handle) + return rc_hash_error("Could not open track"); + + /* the Opera filesystem stores the volume information in the first 132 bytes of sector 0 + * https://github.com/barbeque/3dodump/blob/master/OperaFS-Format.md + */ + rc_cd_read_sector(track_handle, 0, buffer, 132); + + if (memcmp(buffer, operafs_identifier, sizeof(operafs_identifier)) == 0) + { + if (verbose_message_callback) + { + char message[128]; + snprintf(message, sizeof(message), "Found 3DO CD, title=%s", &buffer[0x28]); + verbose_message_callback(message); + } + + /* include the volume header in the hash */ + md5_init(&md5); + md5_append(&md5, buffer, 132); + + /* the block size is at offset 0x4C (assume 0x4C is always 0) */ + block_size = buffer[0x4D] * 65536 + buffer[0x4E] * 256 + buffer[0x4F]; + + /* the root directory block location is at offset 0x64 (and duplicated several + * times, but we just look at the primary record) (assume 0x64 is always 0)*/ + block_location = buffer[0x65] * 65536 + buffer[0x66] * 256 + buffer[0x67]; + + /* multiply the block index by the block size to get the real address */ + block_location *= block_size; + + /* convert that to a sector and read it */ + sector = block_location / 2048; + + do + { + rc_cd_read_sector(track_handle, sector, buffer, sizeof(buffer)); + + /* offset to start of entries is at offset 0x10 (assume 0x10 and 0x11 are always 0) */ + offset = buffer[0x12] * 256 + buffer[0x13]; + + /* offset to end of entries is at offset 0x0C (assume 0x0C is always 0) */ + stop = buffer[0x0D] * 65536 + buffer[0x0E] * 256 + buffer[0x0F]; + + while (offset < stop) + { + if (buffer[offset + 0x03] == 0x02) /* file */ + { + if (strcasecmp((char*)&buffer[offset + 0x20], "LaunchMe") == 0) + { + /* the block size is at offset 0x0C (assume 0x0C is always 0) */ + block_size = buffer[offset + 0x0D] * 65536 + buffer[offset + 0x0E] * 256 + buffer[offset + 0x0F]; + + /* the block location is at offset 0x44 (assume 0x44 is always 0) */ + block_location = buffer[offset + 0x45] * 65536 + buffer[offset + 0x46] * 256 + buffer[offset + 0x47]; + block_location *= block_size; + + /* the file size is at offset 0x10 (assume 0x10 is always 0) */ + size = buffer[offset + 0x11] * 65536 + buffer[offset + 0x12] * 256 + buffer[offset + 0x13]; + + if (verbose_message_callback) + { + char message[128]; + snprintf(message, sizeof(message), "Hashing header (%u bytes) and %s (%u bytes) ", 132, &buffer[offset + 0x20], (unsigned)size); + verbose_message_callback(message); + } + + break; + } + } + + /* the number of extra copies of the file is at offset 0x40 (assume 0x40-0x42 are always 0) */ + offset += 0x48 + buffer[offset + 0x43] * 4; + } + + if (size != 0) + break; + + /* did not find the file, see if the directory listing is continued in another sector */ + offset = buffer[0x02] * 256 + buffer[0x03]; + + /* no more sectors to search*/ + if (offset == 0xFFFF) + break; + + /* get next sector */ + offset *= block_size; + sector = (block_location + offset) / 2048; + } while (1); + + if (size == 0) + { + rc_cd_close_track(track_handle); + return rc_hash_error("Could not find LaunchMe"); + } + + sector = block_location / 2048; + + while (size > 2048) + { + rc_cd_read_sector(track_handle, sector, buffer, sizeof(buffer)); + md5_append(&md5, buffer, sizeof(buffer)); + + ++sector; + size -= 2048; + } + + rc_cd_read_sector(track_handle, sector, buffer, size); + md5_append(&md5, buffer, (int)size); + } + else + { + rc_cd_close_track(track_handle); + return rc_hash_error("Not a 3DO CD"); + } + + rc_cd_close_track(track_handle); + + return rc_hash_finalize(&md5, hash); +} + +static int rc_hash_arcade(char hash[33], const char* path) +{ + /* arcade hash is just the hash of the filename (no extension) - the cores are pretty stringent about having the right ROM data */ + const char* ptr = rc_path_get_filename(path); + const char* ext = rc_path_get_extension(ptr); + return rc_hash_buffer(hash, (uint8_t*)ptr, ext - ptr - 1); +} + +static int rc_hash_lynx(char hash[33], uint8_t* buffer, size_t buffer_size) +{ + /* if the file contains a header, ignore it */ + if (buffer[0] == 'L' && buffer[1] == 'Y' && buffer[2] == 'N' && buffer[3] == 'X' && buffer[4] == 0) + { + rc_hash_verbose("Ignoring LYNX header"); + + buffer += 64; + buffer_size -= 64; + } + + return rc_hash_buffer(hash, buffer, buffer_size); +} + +static int rc_hash_nes(char hash[33], uint8_t* buffer, size_t buffer_size) +{ + /* if the file contains a header, ignore it */ + if (buffer[0] == 'N' && buffer[1] == 'E' && buffer[2] == 'S' && buffer[3] == 0x1A) + { + rc_hash_verbose("Ignoring NES header"); + + buffer += 16; + buffer_size -= 16; + } + else if (buffer[0] == 'F' && buffer[1] == 'D' && buffer[2] == 'S' && buffer[3] == 0x1A) + { + rc_hash_verbose("Ignoring FDS header"); + + buffer += 16; + buffer_size -= 16; + } + + return rc_hash_buffer(hash, buffer, buffer_size); +} + +static int rc_hash_nintendo_ds(char hash[33], const char* path) +{ + uint8_t header[512]; + uint8_t* hash_buffer; + unsigned int hash_size, arm9_size, arm9_addr, arm7_size, arm7_addr, icon_addr; + size_t num_read; + int offset = 0; + md5_state_t md5; + void* file_handle; + + file_handle = rc_file_open(path); + if (!file_handle) + return rc_hash_error("Could not open file"); + + rc_file_seek(file_handle, 0, SEEK_SET); + if (rc_file_read(file_handle, header, sizeof(header)) != 512) + return rc_hash_error("Failed to read header"); + + if (header[0] == 0x2E && header[1] == 0x00 && header[2] == 0x00 && header[3] == 0xEA && + header[0xB0] == 0x44 && header[0xB1] == 0x46 && header[0xB2] == 0x96 && header[0xB3] == 0) + { + /* SuperCard header detected, ignore it */ + rc_hash_verbose("Ignoring SuperCard header"); + + offset = 512; + rc_file_seek(file_handle, offset, SEEK_SET); + rc_file_read(file_handle, header, sizeof(header)); + } + + arm9_addr = header[0x20] | (header[0x21] << 8) | (header[0x22] << 16) | (header[0x23] << 24); + arm9_size = header[0x2C] | (header[0x2D] << 8) | (header[0x2E] << 16) | (header[0x2F] << 24); + arm7_addr = header[0x30] | (header[0x31] << 8) | (header[0x32] << 16) | (header[0x33] << 24); + arm7_size = header[0x3C] | (header[0x3D] << 8) | (header[0x3E] << 16) | (header[0x3F] << 24); + icon_addr = header[0x68] | (header[0x69] << 8) | (header[0x6A] << 16) | (header[0x6B] << 24); + + if (arm9_size + arm7_size > 16 * 1024 * 1024) + { + /* sanity check - code blocks are typically less than 1MB each - assume not a DS ROM */ + snprintf((char*)header, sizeof(header), "arm9 code size (%u) + arm7 code size (%u) exceeds 16MB", arm9_size, arm7_size); + return rc_hash_error((const char*)header); + } + + hash_size = 0xA00; + if (arm9_size > hash_size) + hash_size = arm9_size; + if (arm7_size > hash_size) + hash_size = arm7_size; + + hash_buffer = (uint8_t*)malloc(hash_size); + if (!hash_buffer) + { + rc_file_close(file_handle); + + snprintf((char*)header, sizeof(header), "Failed to allocate %u bytes", hash_size); + return rc_hash_error((const char*)header); + } + + md5_init(&md5); + + rc_hash_verbose("Hashing 352 byte header"); + md5_append(&md5, header, 0x160); + + if (verbose_message_callback) + { + snprintf((char*)header, sizeof(header), "Hashing %u byte arm9 code (at %08X)", arm9_size, arm9_addr); + verbose_message_callback((const char*)header); + } + + rc_file_seek(file_handle, arm9_addr + offset, SEEK_SET); + rc_file_read(file_handle, hash_buffer, arm9_size); + md5_append(&md5, hash_buffer, arm9_size); + + if (verbose_message_callback) + { + snprintf((char*)header, sizeof(header), "Hashing %u byte arm7 code (at %08X)", arm7_size, arm7_addr); + verbose_message_callback((const char*)header); + } + + rc_file_seek(file_handle, arm7_addr + offset, SEEK_SET); + rc_file_read(file_handle, hash_buffer, arm7_size); + md5_append(&md5, hash_buffer, arm7_size); + + if (verbose_message_callback) + { + snprintf((char*)header, sizeof(header), "Hashing 2560 byte icon and labels data (at %08X)", icon_addr); + verbose_message_callback((const char*)header); + } + + rc_file_seek(file_handle, icon_addr + offset, SEEK_SET); + num_read = rc_file_read(file_handle, hash_buffer, 0xA00); + if (num_read < 0xA00) + { + /* some homebrew games don't provide a full icon block, and no data after the icon block. + * if we didn't get a full icon block, fill the remaining portion with 0s + */ + if (verbose_message_callback) + { + snprintf((char*)header, sizeof(header), "Warning: only got %u bytes for icon and labels data, 0-padding to 2560 bytes", (unsigned)num_read); + verbose_message_callback((const char*)header); + } + + memset(&hash_buffer[num_read], 0, 0xA00 - num_read); + } + md5_append(&md5, hash_buffer, 0xA00); + + free(hash_buffer); + rc_file_close(file_handle); + + return rc_hash_finalize(&md5, hash); +} + +static int rc_hash_pce_cd(char hash[33], const char* path) +{ + uint8_t buffer[2048]; + void* track_handle; + md5_state_t md5; + int sector, num_sectors; + unsigned size; + + track_handle = rc_cd_open_track(path, 0); + if (!track_handle) + return rc_hash_error("Could not open track"); + + /* the PC-Engine uses the second sector to specify boot information and program name. + * the string "PC Engine CD-ROM SYSTEM" should exist at 32 bytes into the sector + * http://shu.sheldows.com/shu/download/pcedocs/pce_cdrom.html + */ + rc_cd_read_sector(track_handle, 1, buffer, 128); + + /* normal PC Engine CD will have a header block in sector 1 */ + if (strncmp("PC Engine CD-ROM SYSTEM", (const char*)&buffer[32], 23) == 0) + { + /* the title of the disc is the last 22 bytes of the header */ + md5_init(&md5); + md5_append(&md5, &buffer[106], 22); + + if (verbose_message_callback) + { + char message[128]; + buffer[128] = '\0'; + snprintf(message, sizeof(message), "Found PC Engine CD, title=%s", &buffer[106]); + verbose_message_callback(message); + } + + /* the first three bytes specify the sector of the program data, and the fourth byte + * is the number of sectors. + */ + sector = buffer[0] * 65536 + buffer[1] * 256 + buffer[2]; + num_sectors = buffer[3]; + + if (verbose_message_callback) + { + char message[128]; + snprintf(message, sizeof(message), "Hashing %d sectors starting at sector %d", num_sectors, sector); + verbose_message_callback(message); + } + + while (num_sectors > 0) + { + rc_cd_read_sector(track_handle, sector, buffer, sizeof(buffer)); + md5_append(&md5, buffer, sizeof(buffer)); + + ++sector; + --num_sectors; + } + } + /* GameExpress CDs use a standard Joliet filesystem - locate and hash the BOOT.BIN */ + else if ((sector = rc_cd_find_file_sector(track_handle, "BOOT.BIN", &size)) != 0 && size < MAX_BUFFER_SIZE) + { + md5_init(&md5); + while (size > sizeof(buffer)) + { + rc_cd_read_sector(track_handle, sector, buffer, sizeof(buffer)); + md5_append(&md5, buffer, sizeof(buffer)); + + ++sector; + size -= sizeof(buffer); + } + + if (size > 0) + { + rc_cd_read_sector(track_handle, sector, buffer, size); + md5_append(&md5, buffer, size); + } + } + else + { + rc_cd_close_track(track_handle); + return rc_hash_error("Not a PC Engine CD"); + } + + rc_cd_close_track(track_handle); + + return rc_hash_finalize(&md5, hash); +} + +static int rc_hash_psx(char hash[33], const char* path) +{ + uint8_t buffer[2048]; + char exe_name[64] = ""; + char* ptr; + char* start; + void* track_handle; + uint32_t sector; + unsigned size; + size_t num_read; + int result = 0; + md5_state_t md5; + + track_handle = rc_cd_open_track(path, 1); + if (!track_handle) + return rc_hash_error("Could not open track"); + + sector = rc_cd_find_file_sector(track_handle, "SYSTEM.CNF", NULL); + if (!sector) + { + sector = rc_cd_find_file_sector(track_handle, "PSX.EXE", &size); + if (sector) + strcpy(exe_name, "PSX.EXE"); + } + else + { + size = (unsigned)rc_cd_read_sector(track_handle, sector, buffer, sizeof(buffer) - 1); + buffer[size] = '\0'; + + for (ptr = (char*)buffer; *ptr; ++ptr) + { + if (strncmp(ptr, "BOOT", 4) == 0) + { + ptr += 4; + while (isspace(*ptr)) + ++ptr; + + if (*ptr == '=') + { + ++ptr; + while (isspace(*ptr)) + ++ptr; + + if (strncmp(ptr, "cdrom:", 6) == 0) + ptr += 6; + if (*ptr == '\\') + ++ptr; + + start = ptr; + while (!isspace(*ptr) && *ptr != ';') + ++ptr; + + size = (unsigned)(ptr - start); + if (size >= sizeof(exe_name)) + size = sizeof(exe_name) - 1; + + memcpy(exe_name, start, size); + exe_name[size] = '\0'; + + if (verbose_message_callback) + { + snprintf((char*)buffer, sizeof(buffer), "Looking for boot executable: %s", exe_name); + verbose_message_callback((const char*)buffer); + } + + sector = rc_cd_find_file_sector(track_handle, exe_name, &size); + break; + } + } + + /* advance to end of line */ + while (*ptr && *ptr != '\n') + ++ptr; + } + } + + if (!sector) + { + rc_hash_error("Could not locate primary executable"); + } + else if ((num_read = rc_cd_read_sector(track_handle, sector, buffer, sizeof(buffer))) < sizeof(buffer)) + { + rc_hash_error("Could not read primary executable"); + } + else + { + if (memcmp(buffer, "PS-X EXE", 7) != 0) + { + if (verbose_message_callback) + { + char message[128]; + snprintf(message, sizeof(message), "%s did not contain PS-X EXE marker", exe_name); + verbose_message_callback(message); + } + } + else + { + /* the PS-X EXE header specifies the executable size as a 4-byte value 28 bytes into the header, which doesn't + * include the header itself. We want to include the header in the hash, so append another 2048 to that value. + */ + size = (((uint8_t)buffer[31] << 24) | ((uint8_t)buffer[30] << 16) | ((uint8_t)buffer[29] << 8) | (uint8_t)buffer[28]) + 2048; + } + + if (size > MAX_BUFFER_SIZE) + size = MAX_BUFFER_SIZE; + + if (verbose_message_callback) + { + char message[128]; + snprintf(message, sizeof(message), "Hashing %s title (%u bytes) and contents (%u bytes) ", exe_name, (unsigned)strlen(exe_name), size); + verbose_message_callback(message); + } + + /* there's also a few games that are use a singular engine and only differ via their data files. luckily, they have + * unique serial numbers, and use the serial number as the boot file in the standard way. include the boot file in the hash + */ + md5_init(&md5); + md5_append(&md5, (md5_byte_t*)exe_name, (int)strlen(exe_name)); + + do + { + md5_append(&md5, buffer, (int)num_read); + + size -= (unsigned)num_read; + if (size == 0) + break; + + ++sector; + if (size >= sizeof(buffer)) + num_read = rc_cd_read_sector(track_handle, sector, buffer, sizeof(buffer)); + else + num_read = rc_cd_read_sector(track_handle, sector, buffer, size); + } while (num_read > 0); + + result = rc_hash_finalize(&md5, hash); + } + + rc_cd_close_track(track_handle); + + return result; +} + +static int rc_hash_sega_cd(char hash[33], const char* path) +{ + uint8_t buffer[512]; + void* track_handle; + + track_handle = rc_cd_open_track(path, 1); + if (!track_handle) + return rc_hash_error("Could not open track"); + + /* the first 512 bytes of sector 0 are a volume header and ROM header that uniquely identify the game. + * After that is an arbitrary amount of code that ensures the game is being run in the correct region. + * Then more arbitrary code follows that actually starts the boot process. Somewhere in there, the + * primary executable is loaded. In many cases, a single game will have multiple executables, so even + * if we could determine the primary one, it's just the tip of the iceberg. As such, we've decided that + * hashing the volume and ROM headers is sufficient for identifying the game, and we'll have to trust + * that our players aren't modifying anything else on the disc. + */ + rc_cd_read_sector(track_handle, 0, buffer, sizeof(buffer)); + + return rc_hash_buffer(hash, buffer, sizeof(buffer)); +} + +static int rc_hash_snes(char hash[33], uint8_t* buffer, size_t buffer_size) +{ + /* if the file contains a header, ignore it */ + uint32_t calc_size = ((uint32_t)buffer_size / 0x2000) * 0x2000; + if (buffer_size - calc_size == 512) + { + rc_hash_verbose("Ignoring SNES header"); + + buffer += 512; + buffer_size -= 512; + } + + return rc_hash_buffer(hash, buffer, buffer_size); +} + +int rc_hash_generate_from_buffer(char hash[33], int console_id, uint8_t* buffer, size_t buffer_size) +{ + switch (console_id) + { + default: + { + char message[128]; + snprintf(message, sizeof(message), "Unsupported console for buffer hash: %d", console_id); + return rc_hash_error(message); + } + + case RC_CONSOLE_APPLE_II: + case RC_CONSOLE_ATARI_2600: + case RC_CONSOLE_ATARI_7800: + case RC_CONSOLE_ATARI_JAGUAR: + case RC_CONSOLE_COLECOVISION: + case RC_CONSOLE_GAMEBOY: + case RC_CONSOLE_GAMEBOY_ADVANCE: + case RC_CONSOLE_GAMEBOY_COLOR: + case RC_CONSOLE_GAME_GEAR: + case RC_CONSOLE_INTELLIVISION: + case RC_CONSOLE_MASTER_SYSTEM: + case RC_CONSOLE_MEGA_DRIVE: + case RC_CONSOLE_NEOGEO_POCKET: + case RC_CONSOLE_NINTENDO_64: + case RC_CONSOLE_ORIC: + case RC_CONSOLE_PC_ENGINE: /* NOTE: does not support PCEngine CD */ + case RC_CONSOLE_PC8800: + case RC_CONSOLE_POKEMON_MINI: + case RC_CONSOLE_SEGA_32X: + case RC_CONSOLE_SG1000: + case RC_CONSOLE_VECTREX: + case RC_CONSOLE_VIRTUAL_BOY: + case RC_CONSOLE_WONDERSWAN: + return rc_hash_buffer(hash, buffer, buffer_size); + + case RC_CONSOLE_ATARI_LYNX: + return rc_hash_lynx(hash, buffer, buffer_size); + + case RC_CONSOLE_NINTENDO: + return rc_hash_nes(hash, buffer, buffer_size); + + case RC_CONSOLE_SUPER_NINTENDO: + return rc_hash_snes(hash, buffer, buffer_size); + } +} + +static int rc_hash_whole_file(char hash[33], int console_id, const char* path) +{ + md5_state_t md5; + uint8_t* buffer; + size_t size; + const size_t buffer_size = 65536; + void* file_handle; + int result = 0; + + file_handle = rc_file_open(path); + if (!file_handle) + return rc_hash_error("Could not open file"); + + rc_file_seek(file_handle, 0, SEEK_END); + size = rc_file_tell(file_handle); + + if (verbose_message_callback) + { + char message[1024]; + if (size > MAX_BUFFER_SIZE) + snprintf(message, sizeof(message), "Hashing first %u bytes (of %u bytes) of %s", MAX_BUFFER_SIZE, (unsigned)size, rc_path_get_filename(path)); + else + snprintf(message, sizeof(message), "Hashing %s (%u bytes)", rc_path_get_filename(path), (unsigned)size); + verbose_message_callback(message); + } + + if (size > MAX_BUFFER_SIZE) + size = MAX_BUFFER_SIZE; + + md5_init(&md5); + + buffer = (uint8_t*)malloc(buffer_size); + if (buffer) + { + rc_file_seek(file_handle, 0, SEEK_SET); + while (size >= buffer_size) + { + rc_file_read(file_handle, buffer, (int)buffer_size); + md5_append(&md5, buffer, (int)buffer_size); + size -= buffer_size; + } + + if (size > 0) + { + rc_file_read(file_handle, buffer, (int)size); + md5_append(&md5, buffer, (int)size); + } + + free(buffer); + result = rc_hash_finalize(&md5, hash); + } + + rc_file_close(file_handle); + return result; +} + +static int rc_hash_buffered_file(char hash[33], int console_id, const char* path) +{ + uint8_t* buffer; + size_t size; + int result = 0; + void* file_handle; + + file_handle = rc_file_open(path); + if (!file_handle) + return rc_hash_error("Could not open file"); + + rc_file_seek(file_handle, 0, SEEK_END); + size = rc_file_tell(file_handle); + + if (verbose_message_callback) + { + char message[1024]; + if (size > MAX_BUFFER_SIZE) + snprintf(message, sizeof(message), "Buffering first %u bytes (of %d bytes) of %s", MAX_BUFFER_SIZE, (unsigned)size, rc_path_get_filename(path)); + else + snprintf(message, sizeof(message), "Buffering %s (%d bytes)", rc_path_get_filename(path), (unsigned)size); + verbose_message_callback(message); + } + + if (size > MAX_BUFFER_SIZE) + size = MAX_BUFFER_SIZE; + + buffer = (uint8_t*)malloc(size); + if (buffer) + { + rc_file_seek(file_handle, 0, SEEK_SET); + rc_file_read(file_handle, buffer, (int)size); + + result = rc_hash_generate_from_buffer(hash, console_id, buffer, size); + + free(buffer); + } + + rc_file_close(file_handle); + return result; +} + +static const char* rc_hash_get_first_item_from_playlist(const char* path) +{ + char buffer[1024]; + char* disc_path; + char* ptr, *start; + size_t num_read; + void* file_handle; + + file_handle = rc_file_open(path); + if (!file_handle) + { + rc_hash_error("Could not open playlist"); + return NULL; + } + + num_read = rc_file_read(file_handle, buffer, sizeof(buffer) - 1); + buffer[num_read] = '\0'; + + rc_file_close(file_handle); + + ptr = start = buffer; + /* ignore empty and commented lines */ + while (*ptr == '#' || *ptr == '\r' || *ptr == '\n') + { + while (*ptr && *ptr != '\n') + ++ptr; + if (*ptr) + ++ptr; + start = ptr; + } + + /* find and extract the current line */ + while (*ptr && *ptr != '\n') + ++ptr; + if (ptr > start && ptr[-1] == '\r') + --ptr; + *ptr = '\0'; + + if (verbose_message_callback) + { + char message[1024]; + snprintf(message, sizeof(message), "Extracted %s from playlist", buffer); + verbose_message_callback(message); + } + + ptr = (char*)rc_path_get_filename(path); + num_read = (ptr - path) + strlen(start) + 1; + + disc_path = (char*)malloc(num_read); + if (!disc_path) + return NULL; + + memcpy(disc_path, path, ptr - path); + strcpy(disc_path + (ptr - path), start); + return disc_path; +} + +static int rc_hash_generate_from_playlist(char hash[33], int console_id, const char* path) +{ + int result; + const char* disc_path; + + if (verbose_message_callback) + { + char message[1024]; + snprintf(message, sizeof(message), "Processing playlist: %s", rc_path_get_filename(path)); + verbose_message_callback(message); + } + + disc_path = rc_hash_get_first_item_from_playlist(path); + if (!disc_path) + return rc_hash_error("Failed to get first item from playlist"); + + result = rc_hash_generate_from_file(hash, console_id, disc_path); + + free((void*)disc_path); + return result; +} + +int rc_hash_generate_from_file(char hash[33], int console_id, const char* path) +{ + switch (console_id) + { + default: + { + char buffer[128]; + snprintf(buffer, sizeof(buffer), "Unsupported console for file hash: %d", console_id); + return rc_hash_error(buffer); + } + + case RC_CONSOLE_APPLE_II: + case RC_CONSOLE_ATARI_2600: + case RC_CONSOLE_ATARI_7800: + case RC_CONSOLE_ATARI_JAGUAR: + case RC_CONSOLE_COLECOVISION: + case RC_CONSOLE_GAMEBOY: + case RC_CONSOLE_GAMEBOY_ADVANCE: + case RC_CONSOLE_GAMEBOY_COLOR: + case RC_CONSOLE_GAME_GEAR: + case RC_CONSOLE_INTELLIVISION: + case RC_CONSOLE_MASTER_SYSTEM: + case RC_CONSOLE_MEGA_DRIVE: + case RC_CONSOLE_NEOGEO_POCKET: + case RC_CONSOLE_NINTENDO_64: + case RC_CONSOLE_ORIC: + case RC_CONSOLE_POKEMON_MINI: + case RC_CONSOLE_SEGA_32X: + case RC_CONSOLE_SG1000: + case RC_CONSOLE_VECTREX: + case RC_CONSOLE_VIRTUAL_BOY: + case RC_CONSOLE_WONDERSWAN: + /* generic whole-file hash - don't buffer */ + return rc_hash_whole_file(hash, console_id, path); + + case RC_CONSOLE_ATARI_LYNX: + case RC_CONSOLE_NINTENDO: + case RC_CONSOLE_SUPER_NINTENDO: + /* additional logic whole-file hash - buffer then call rc_hash_generate_from_buffer */ + return rc_hash_buffered_file(hash, console_id, path); + + case RC_CONSOLE_3DO: + if (rc_path_compare_extension(path, "m3u")) + return rc_hash_generate_from_playlist(hash, console_id, path); + + return rc_hash_3do(hash, path); + + case RC_CONSOLE_ARCADE: + return rc_hash_arcade(hash, path); + + case RC_CONSOLE_NINTENDO_DS: + return rc_hash_nintendo_ds(hash, path); + + case RC_CONSOLE_PC_ENGINE: + if (rc_path_compare_extension(path, "cue") || rc_path_compare_extension(path, "chd")) + return rc_hash_pce_cd(hash, path); + + if (rc_path_compare_extension(path, "m3u")) + return rc_hash_generate_from_playlist(hash, console_id, path); + + return rc_hash_whole_file(hash, console_id, path); + + case RC_CONSOLE_PC8800: + if (rc_path_compare_extension(path, "m3u")) + return rc_hash_generate_from_playlist(hash, console_id, path); + + return rc_hash_whole_file(hash, console_id, path); + + case RC_CONSOLE_PLAYSTATION: + if (rc_path_compare_extension(path, "m3u")) + return rc_hash_generate_from_playlist(hash, console_id, path); + + return rc_hash_psx(hash, path); + + case RC_CONSOLE_SEGA_CD: + case RC_CONSOLE_SATURN: + if (rc_path_compare_extension(path, "m3u")) + return rc_hash_generate_from_playlist(hash, console_id, path); + + return rc_hash_sega_cd(hash, path); + } +} + +void rc_hash_initialize_iterator(struct rc_hash_iterator* iterator, const char* path, uint8_t* buffer, size_t buffer_size) +{ + int need_path = !buffer; + + memset(iterator, 0, sizeof(*iterator)); + iterator->buffer = buffer; + iterator->buffer_size = buffer_size; + + iterator->consoles[0] = 0; + + do + { + const char* ext = rc_path_get_extension(path); + switch (tolower(*ext--)) + { + case 'a': + if (rc_path_compare_extension(ext, "a78")) + { + iterator->consoles[0] = RC_CONSOLE_ATARI_7800; + } + break; + + case 'b': + if (rc_path_compare_extension(ext, "bin")) + { + if (buffer_size == 0) + { + /* raw bin file may be a CD track. if it's more than 32MB, try a CD hash. */ + void* file = rc_file_open(path); + if (file) + { + size_t size; + + rc_file_seek(file, 0, SEEK_END); + size = rc_file_tell(file); + rc_file_close(file); + + if (size > 32 * 1024 * 1024) + { + /* 3DO and Sega CD are the only cores that supports directly opening the bin file. */ + iterator->consoles[0] = RC_CONSOLE_3DO; + iterator->consoles[1] = RC_CONSOLE_SEGA_CD; + + /* fallback to megadrive - see comment below */ + iterator->consoles[2] = RC_CONSOLE_MEGA_DRIVE; + break; + } + } + } + + /* bin is associated with MegaDrive, Sega32X and Atari 2600. Since they all use the same + * hashing algorithm, only specify one of them */ + iterator->consoles[0] = RC_CONSOLE_MEGA_DRIVE; + } + break; + + case 'c': + if (rc_path_compare_extension(ext, "cue") || rc_path_compare_extension(ext, "chd")) + { + iterator->consoles[0] = RC_CONSOLE_PLAYSTATION; + iterator->consoles[1] = RC_CONSOLE_PC_ENGINE; + iterator->consoles[2] = RC_CONSOLE_3DO; + /* SEGA CD hash doesn't have any logic to ensure it's being used against a SEGA CD, so it should always be last */ + iterator->consoles[3] = RC_CONSOLE_SEGA_CD; + need_path = 1; + } + else if (rc_path_compare_extension(ext, "col")) + { + iterator->consoles[0] = RC_CONSOLE_COLECOVISION; + } + break; + + case 'd': + if (rc_path_compare_extension(ext, "dsk")) + { + iterator->consoles[0] = RC_CONSOLE_APPLE_II; + } + else if (rc_path_compare_extension(ext, "d88")) + { + iterator->consoles[0] = RC_CONSOLE_PC8800; + } + break; + + case 'f': + if (rc_path_compare_extension(ext, "fig")) + { + iterator->consoles[0] = RC_CONSOLE_SUPER_NINTENDO; + } + else if (rc_path_compare_extension(ext, "fds")) + { + iterator->consoles[0] = RC_CONSOLE_NINTENDO; + } + break; + + case 'g': + if (rc_path_compare_extension(ext, "gba")) + { + iterator->consoles[0] = RC_CONSOLE_GAMEBOY_ADVANCE; + } + else if (rc_path_compare_extension(ext, "gbc")) + { + iterator->consoles[0] = RC_CONSOLE_GAMEBOY_COLOR; + } + else if (rc_path_compare_extension(ext, "gb")) + { + iterator->consoles[0] = RC_CONSOLE_GAMEBOY; + } + else if (rc_path_compare_extension(ext, "gg")) + { + iterator->consoles[0] = RC_CONSOLE_GAME_GEAR; + } + break; + + case 'i': + if (rc_path_compare_extension(ext, "iso")) + { + iterator->consoles[0] = RC_CONSOLE_3DO; + iterator->consoles[1] = RC_CONSOLE_SEGA_CD; + need_path = 1; + } + break; + + case 'j': + if (rc_path_compare_extension(ext, "jag")) + { + iterator->consoles[0] = RC_CONSOLE_ATARI_JAGUAR; + } + break; + + case 'l': + if (rc_path_compare_extension(ext, "lnx")) + { + iterator->consoles[0] = RC_CONSOLE_ATARI_LYNX; + } + break; + + case 'm': + if (rc_path_compare_extension(ext, "m3u")) + { + const char* disc_path = rc_hash_get_first_item_from_playlist(path); + if (disc_path) + { + path = iterator->path = disc_path; + continue; /* retry with disc_path */ + } + } + else if (rc_path_compare_extension(ext, "md")) + { + iterator->consoles[0] = RC_CONSOLE_MEGA_DRIVE; + } + else if (rc_path_compare_extension(ext, "min")) + { + iterator->consoles[0] = RC_CONSOLE_POKEMON_MINI; + } + break; + + case 'n': + if (rc_path_compare_extension(ext, "nes")) + { + iterator->consoles[0] = RC_CONSOLE_NINTENDO; + } + else if (rc_path_compare_extension(ext, "nds")) + { + iterator->consoles[0] = RC_CONSOLE_NINTENDO_DS; + } + else if (rc_path_compare_extension(ext, "n64")) + { + iterator->consoles[0] = RC_CONSOLE_NINTENDO_64; + } + else if (rc_path_compare_extension(ext, "ngc")) + { + iterator->consoles[0] = RC_CONSOLE_NEOGEO_POCKET; + } + break; + + case 'p': + if (rc_path_compare_extension(ext, "pce")) + { + iterator->consoles[0] = RC_CONSOLE_PC_ENGINE; + } + break; + + case 's': + if (rc_path_compare_extension(ext, "smc") || rc_path_compare_extension(ext, "sfc")) + { + iterator->consoles[0] = RC_CONSOLE_SUPER_NINTENDO; + } + else if (rc_path_compare_extension(ext, "sg")) + { + iterator->consoles[0] = RC_CONSOLE_SG1000; + } + else if (rc_path_compare_extension(ext, "sgx")) + { + iterator->consoles[0] = RC_CONSOLE_PC_ENGINE; + } + break; + + case 't': + if (rc_path_compare_extension(ext, "tap")) + { + iterator->consoles[0] = RC_CONSOLE_ORIC; + } + break; + + case 'v': + if (rc_path_compare_extension(ext, "vb")) + { + iterator->consoles[0] = RC_CONSOLE_VIRTUAL_BOY; + } + break; + + case 'w': + if (rc_path_compare_extension(ext, "wsc")) + { + iterator->consoles[0] = RC_CONSOLE_WONDERSWAN; + } + break; + + case 'z': + if (rc_path_compare_extension(ext, "zip")) + { + /* decompressing zip file not supported */ + iterator->consoles[0] = RC_CONSOLE_ARCADE; + need_path = 1; + } + break; + } + + if (verbose_message_callback) + { + char message[256]; + int count = 0; + while (iterator->consoles[count]) + ++count; + + snprintf(message, sizeof(message), "Found %d potential consoles for %s file extension", count, ext); + verbose_message_callback(message); + } + + /* loop is only for specific cases that redirect to another file - like m3u */ + break; + } while (1); + + if (need_path && !iterator->path) + iterator->path = strdup(path); + + /* if we didn't match the extension, default to something that does a whole file hash */ + if (!iterator->consoles[0]) + iterator->consoles[0] = RC_CONSOLE_GAMEBOY; +} + +void rc_hash_destroy_iterator(struct rc_hash_iterator* iterator) +{ + if (iterator->path) + { + free((void*)iterator->path); + iterator->path = NULL; + } +} + +int rc_hash_iterate(char hash[33], struct rc_hash_iterator* iterator) +{ + int next_console; + int result = 0; + + do + { + next_console = iterator->consoles[iterator->index]; + if (next_console == 0) + { + hash[0] = '\0'; + break; + } + + ++iterator->index; + + if (verbose_message_callback) + { + char message[128]; + snprintf(message, sizeof(message), "Trying console %d", next_console); + verbose_message_callback(message); + } + + if (iterator->buffer) + result = rc_hash_generate_from_buffer(hash, next_console, iterator->buffer, iterator->buffer_size); + else + result = rc_hash_generate_from_file(hash, next_console, iterator->path); + + } while (!result); + + return result; +} diff --git a/deps/rcheevos/src/rhash/md5.h b/deps/rcheevos/src/rhash/md5.h new file mode 100644 index 0000000000..8f100b176b --- /dev/null +++ b/deps/rcheevos/src/rhash/md5.h @@ -0,0 +1,18 @@ +#ifndef RC_MD5_H +#define RC_MD5_H + +/* NOTE: this is NOT the md5.h included in the rcheevos repository. It provides the same + * functionality using code already present in RetroArch */ + +/* android build has libretro-common/include in path, but not the base directory. + * other builds prioritize rcheevos/include over libretro-common/include. + * to ensure we get the correct include file, use a complicated relative path */ +#include <../../../libretro-common/include/rhash.h> + +#define md5_state_t MD5_CTX +#define md5_byte_t unsigned char +#define md5_init(state) MD5_Init(state) +#define md5_append(state, buffer, size) MD5_Update(state, buffer, size) +#define md5_finish(state, hash) MD5_Final(hash, state) + +#endif diff --git a/deps/rcheevos/src/rurl/url.c b/deps/rcheevos/src/rurl/url.c index 5ac67aa361..465d1bb2b4 100644 --- a/deps/rcheevos/src/rurl/url.c +++ b/deps/rcheevos/src/rurl/url.c @@ -1,15 +1,7 @@ #include "rurl.h" -#ifdef RARCH_INTERNAL -#include /* libretro-common/include/rhash.h */ -#define md5_state_t MD5_CTX -#define md5_byte_t unsigned char -#define md5_init(state) MD5_Init(state) -#define md5_append(state, buffer, size) MD5_Update(state, buffer, size) -#define md5_finish(state, hash) MD5_Final(hash, state) -#else -#include "..\rhash\md5.h" -#endif +#include "../rcheevos/compat.h" +#include "../rhash/md5.h" #include #include @@ -25,37 +17,41 @@ static int rc_url_encode(char* encoded, size_t len, const char* str) { case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '-': case '_': case '.': case '~': - if (len >= 2) { - *encoded++ = *str++; - len--; - } - else { + if (len < 2) return -1; - } + *encoded++ = *str++; + --len; break; - + + case ' ': + if (len < 2) + return -1; + + *encoded++ = '+'; + ++str; + --len; + break; + default: - if (len >= 4) { - snprintf(encoded, len, "%%%02x", (unsigned char)*str); - encoded += 3; - str++; - len -= 3; - } - else { + if (len < 4) return -1; - } + snprintf(encoded, len, "%%%02x", (unsigned char)*str); + encoded += 3; + ++str; + len -= 3; break; - - case 0: + + case '\0': *encoded = 0; return 0; } } } -int rc_url_award_cheevo(char* buffer, size_t size, const char* user_name, const char* login_token, unsigned cheevo_id, int hardcore) { +int rc_url_award_cheevo(char* buffer, size_t size, const char* user_name, const char* login_token, + unsigned cheevo_id, int hardcore, const char* game_hash) { char urle_user_name[64]; char urle_login_token[64]; int written; @@ -63,11 +59,11 @@ int rc_url_award_cheevo(char* buffer, size_t size, const char* user_name, const if (rc_url_encode(urle_user_name, sizeof(urle_user_name), user_name) != 0) { return -1; } - + if (rc_url_encode(urle_login_token, sizeof(urle_login_token), login_token) != 0) { return -1; } - + written = snprintf( buffer, size, @@ -78,10 +74,14 @@ int rc_url_award_cheevo(char* buffer, size_t size, const char* user_name, const hardcore ? 1 : 0 ); + if (game_hash && strlen(game_hash) == 32 && (size - (size_t)written) >= 35) { + written += snprintf(buffer + written, size - (size_t)written, "&m=%s", game_hash); + } + return (size_t)written >= size ? -1 : 0; } -int rc_url_submit_lboard(char* buffer, size_t size, const char* user_name, const char* login_token, unsigned lboard_id, int value, const char* game_hash) { +int rc_url_submit_lboard(char* buffer, size_t size, const char* user_name, const char* login_token, unsigned lboard_id, int value) { char urle_user_name[64]; char urle_login_token[64]; char signature[64]; @@ -92,7 +92,7 @@ int rc_url_submit_lboard(char* buffer, size_t size, const char* user_name, const if (rc_url_encode(urle_user_name, sizeof(urle_user_name), user_name) != 0) { return -1; } - + if (rc_url_encode(urle_login_token, sizeof(urle_login_token), login_token) != 0) { return -1; } @@ -115,20 +115,15 @@ int rc_url_submit_lboard(char* buffer, size_t size, const char* user_name, const hash[ 8], hash[ 9], hash[10], hash[11],hash[12], hash[13], hash[14], hash[15] ); - if (game_hash && strlen(game_hash) == 32 && (size - (size_t)written) >= 35) { - written += snprintf(buffer + written, size - (size_t)written, "&m=%s", game_hash); - } - return (size_t)written >= size ? -1 : 0; } -int rc_url_get_gameid(char* buffer, size_t size, unsigned char hash[16]) { +int rc_url_get_gameid(char* buffer, size_t size, const char* hash) { int written = snprintf( buffer, size, - "http://retroachievements.org/dorequest.php?r=gameid&m=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", - hash[ 0], hash[ 1], hash[ 2], hash[ 3], hash[ 4], hash[ 5], hash[ 6], hash[ 7], - hash[ 8], hash[ 9], hash[10], hash[11],hash[12], hash[13], hash[14], hash[15] + "http://retroachievements.org/dorequest.php?r=gameid&m=%s", + hash ); return (size_t)written >= size ? -1 : 0; @@ -142,11 +137,11 @@ int rc_url_get_patch(char* buffer, size_t size, const char* user_name, const cha if (rc_url_encode(urle_user_name, sizeof(urle_user_name), user_name) != 0) { return -1; } - + if (rc_url_encode(urle_login_token, sizeof(urle_login_token), login_token) != 0) { return -1; } - + written = snprintf( buffer, size, @@ -178,11 +173,11 @@ int rc_url_login_with_password(char* buffer, size_t size, const char* user_name, if (rc_url_encode(urle_user_name, sizeof(urle_user_name), user_name) != 0) { return -1; } - + if (rc_url_encode(urle_password, sizeof(urle_password), password) != 0) { return -1; } - + written = snprintf( buffer, size, @@ -202,11 +197,11 @@ int rc_url_login_with_token(char* buffer, size_t size, const char* user_name, co if (rc_url_encode(urle_user_name, sizeof(urle_user_name), user_name) != 0) { return -1; } - + if (rc_url_encode(urle_login_token, sizeof(urle_login_token), login_token) != 0) { return -1; } - + written = snprintf( buffer, size, @@ -226,11 +221,11 @@ int rc_url_get_unlock_list(char* buffer, size_t size, const char* user_name, con if (rc_url_encode(urle_user_name, sizeof(urle_user_name), user_name) != 0) { return -1; } - + if (rc_url_encode(urle_login_token, sizeof(urle_login_token), login_token) != 0) { return -1; } - + written = snprintf( buffer, size, @@ -252,11 +247,11 @@ int rc_url_post_playing(char* buffer, size_t size, const char* user_name, const if (rc_url_encode(urle_user_name, sizeof(urle_user_name), user_name) != 0) { return -1; } - + if (rc_url_encode(urle_login_token, sizeof(urle_login_token), login_token) != 0) { return -1; } - + written = snprintf( buffer, size, @@ -268,3 +263,111 @@ int rc_url_post_playing(char* buffer, size_t size, const char* user_name, const return (size_t)written >= size ? -1 : 0; } + +static int rc_url_append_param_equals(char* buffer, size_t buffer_size, size_t buffer_offset, const char* param) +{ + int written = 0; + size_t param_len; + + if (buffer_offset >= buffer_size) + return -1; + + if (buffer_offset) { + buffer += buffer_offset; + buffer_size -= buffer_offset; + + if (buffer[-1] != '?') { + *buffer++ = '&'; + buffer_size--; + written = 1; + } + } + + param_len = strlen(param); + if (param_len + 1 >= buffer_size) + return -1; + memcpy(buffer, param, param_len); + buffer[param_len] = '='; + + written += (int)param_len + 1; + return written + (int)buffer_offset; +} + +static int rc_url_append_unum(char* buffer, size_t buffer_size, size_t* buffer_offset, const char* param, unsigned value) +{ + int written = rc_url_append_param_equals(buffer, buffer_size, *buffer_offset, param); + if (written > 0) { + char num[16]; + int chars = sprintf(num, "%u", value); + + if (chars + written < (int)buffer_size) + { + memcpy(&buffer[written], num, chars + 1); + *buffer_offset = written + chars; + return 0; + } + } + + return -1; +} + +static int rc_url_append_str(char* buffer, size_t buffer_size, size_t* buffer_offset, const char* param, const char* value) +{ + int written = rc_url_append_param_equals(buffer, buffer_size, *buffer_offset, param); + if (written > 0) + { + buffer += written; + buffer_size -= written; + + if (rc_url_encode(buffer, buffer_size, value) == 0) + { + written += (int)strlen(buffer); + *buffer_offset = written; + return 0; + } + } + + return -1; +} + +static int rc_url_build_dorequest(char* url_buffer, size_t url_buffer_size, size_t* buffer_offset, + const char* api, const char* user_name) +{ + const char* base_url = "http://retroachievements.org/dorequest.php"; + size_t written = strlen(base_url); + int failure = 0; + + if (url_buffer_size < written + 1) + return -1; + memcpy(url_buffer, base_url, written); + url_buffer[written++] = '?'; + + failure |= rc_url_append_str(url_buffer, url_buffer_size, &written, "r", api); + failure |= rc_url_append_str(url_buffer, url_buffer_size, &written, "u", user_name); + + *buffer_offset += written; + return failure; +} + +int rc_url_ping(char* url_buffer, size_t url_buffer_size, char* post_buffer, size_t post_buffer_size, + const char* user_name, const char* login_token, unsigned gameid, const char* rich_presence) +{ + size_t written = 0; + int failure = rc_url_build_dorequest(url_buffer, url_buffer_size, &written, "ping", user_name); + failure |= rc_url_append_unum(url_buffer, url_buffer_size, &written, "g", gameid); + + written = 0; + failure |= rc_url_append_str(post_buffer, post_buffer_size, &written, "t", login_token); + + if (rich_presence && *rich_presence) + failure |= rc_url_append_str(post_buffer, post_buffer_size, &written, "m", rich_presence); + + if (failure) { + if (url_buffer_size) + url_buffer[0] = '\0'; + if (post_buffer_size) + post_buffer[0] = '\0'; + } + + return failure; +} diff --git a/griffin/griffin.c b/griffin/griffin.c index 5a49927fda..2464aa23ad 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -181,17 +181,20 @@ ACHIEVEMENTS #include "../cheevos-new/parser.c" #include "../deps/rcheevos/src/rcheevos/alloc.c" +#include "../deps/rcheevos/src/rcheevos/compat.c" #include "../deps/rcheevos/src/rcheevos/condition.c" #include "../deps/rcheevos/src/rcheevos/condset.c" -#include "../deps/rcheevos/src/rcheevos/expression.c" +#include "../deps/rcheevos/src/rcheevos/consoleinfo.c" #include "../deps/rcheevos/src/rcheevos/format.c" #include "../deps/rcheevos/src/rcheevos/lboard.c" +#include "../deps/rcheevos/src/rcheevos/memref.c" #include "../deps/rcheevos/src/rcheevos/operand.c" -#include "../deps/rcheevos/src/rcheevos/term.c" +#include "../deps/rcheevos/src/rcheevos/richpresence.c" +#include "../deps/rcheevos/src/rcheevos/runtime.c" +#include "../deps/rcheevos/src/rcheevos/runtime_progress.c" #include "../deps/rcheevos/src/rcheevos/trigger.c" #include "../deps/rcheevos/src/rcheevos/value.c" -#include "../deps/rcheevos/src/rcheevos/memref.c" -#include "../deps/rcheevos/src/rcheevos/richpresence.c" +#include "../deps/rcheevos/src/rhash/hash.c" #include "../deps/rcheevos/src/rurl/url.c" #endif From 81a623c2b698c39e3d8c79d31fff1cc9eb6748ea Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 May 2020 16:49:16 +0200 Subject: [PATCH 044/192] Style nits --- retroarch.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/retroarch.c b/retroarch.c index 2fb60cd4c9..e9cad2b88a 100644 --- a/retroarch.c +++ b/retroarch.c @@ -4864,15 +4864,15 @@ static void handle_translation_cb( rpng_t *rpng = NULL; /* PNG coming back from the url */ image_width = - ((uint32_t) ((uint8_t)raw_image_file_data[16])<<24)+ - ((uint32_t) ((uint8_t)raw_image_file_data[17])<<16)+ - ((uint32_t) ((uint8_t)raw_image_file_data[18])<<8)+ - ((uint32_t) ((uint8_t)raw_image_file_data[19])<<0); + ((uint32_t) ((uint8_t)raw_image_file_data[16]) << 24)+ + ((uint32_t) ((uint8_t)raw_image_file_data[17]) << 16)+ + ((uint32_t) ((uint8_t)raw_image_file_data[18]) << 8)+ + ((uint32_t) ((uint8_t)raw_image_file_data[19]) << 0); image_height = - ((uint32_t) ((uint8_t)raw_image_file_data[20])<<24)+ - ((uint32_t) ((uint8_t)raw_image_file_data[21])<<16)+ - ((uint32_t) ((uint8_t)raw_image_file_data[22])<<8)+ - ((uint32_t) ((uint8_t)raw_image_file_data[23])<<0); + ((uint32_t) ((uint8_t)raw_image_file_data[20]) << 24)+ + ((uint32_t) ((uint8_t)raw_image_file_data[21]) << 16)+ + ((uint32_t) ((uint8_t)raw_image_file_data[22]) << 8)+ + ((uint32_t) ((uint8_t)raw_image_file_data[23]) << 0); rpng = rpng_alloc(); if (!rpng) @@ -14543,10 +14543,10 @@ static int16_t input_state_device( /* Avoid detecting the turbo button being held as multiple toggles */ if (!input_driver_turbo_btns.frame_enable[port]) - input_driver_turbo_btns.turbo_pressed[port] &= ~(1<<31); + input_driver_turbo_btns.turbo_pressed[port] &= ~(1 << 31); else if (input_driver_turbo_btns.turbo_pressed[port]>=0) { - input_driver_turbo_btns.turbo_pressed[port] |= (1<<31); + input_driver_turbo_btns.turbo_pressed[port] |= (1 << 31); /* Toggle turbo for selected buttons. */ if (!input_driver_turbo_btns.enable[port]) { @@ -14569,7 +14569,7 @@ static int16_t input_state_device( input_driver_turbo_btns.mode1_enable[port] ^= 1; } - if (input_driver_turbo_btns.turbo_pressed[port] & 1<<31) + if (input_driver_turbo_btns.turbo_pressed[port] & (1 << 31)) { /* Avoid detecting buttons being held as multiple toggles */ if (!res) @@ -29668,9 +29668,9 @@ unsigned get_gamepad_input_override(void) void set_gamepad_input_override(unsigned i, bool val) { if (val) - gamepad_input_override = gamepad_input_override | (1< Date: Mon, 11 May 2020 17:07:37 +0200 Subject: [PATCH 045/192] (Qt) Cleanups --- menu/menu_setting.c | 14 ++++ menu/menu_setting.h | 2 + ui/drivers/qt/qt_playlist.cpp | 2 +- ui/drivers/qt/settingswidgets.cpp | 102 +++++++++++++----------------- 4 files changed, 62 insertions(+), 58 deletions(-) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index e238daf488..d0cd342925 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -824,6 +824,20 @@ int setting_generic_action_ok_default(rarch_setting_t *setting, bool wraparound) return 0; } +void setting_generic_handle_change(rarch_setting_t *setting) +{ + settings_t *settings = config_get_ptr(); + + settings->modified = true; + + if (setting->change_handler) + setting->change_handler(setting); + + if (setting->cmd_trigger.idx && !setting->cmd_trigger.triggered) + command_event(setting->cmd_trigger.idx, NULL); +} + + static void setting_get_string_representation_int_gpu_index(rarch_setting_t *setting, char *s, size_t len) { diff --git a/menu/menu_setting.h b/menu/menu_setting.h index fe0f9108f2..66934069e0 100644 --- a/menu/menu_setting.h +++ b/menu/menu_setting.h @@ -127,6 +127,8 @@ int menu_action_handle_setting(rarch_setting_t *setting, enum setting_type menu_setting_get_browser_selection_type( rarch_setting_t *setting); +void setting_generic_handle_change(rarch_setting_t *setting); + void general_write_handler(rarch_setting_t *setting); void general_read_handler(rarch_setting_t *setting); diff --git a/ui/drivers/qt/qt_playlist.cpp b/ui/drivers/qt/qt_playlist.cpp index 5e7cf62906..b614cf03ef 100644 --- a/ui/drivers/qt/qt_playlist.cpp +++ b/ui/drivers/qt/qt_playlist.cpp @@ -263,7 +263,7 @@ void PlaylistModel::onImageLoaded(const QImage image, const QModelIndex &index, m_pendingImages.remove(path); } -inline static bool comp_hash_name_key_lower(const QHash &lhs, const QHash &rhs) +static inline bool comp_hash_name_key_lower(const QHash &lhs, const QHash &rhs) { return lhs.value("name").toLower() < rhs.value("name").toLower(); } diff --git a/ui/drivers/qt/settingswidgets.cpp b/ui/drivers/qt/settingswidgets.cpp index ff82764d47..3845c85d91 100644 --- a/ui/drivers/qt/settingswidgets.cpp +++ b/ui/drivers/qt/settingswidgets.cpp @@ -23,20 +23,8 @@ extern "C" { static const QRegularExpression decimalsRegex("%.(\\d)f"); -inline void handleChange(rarch_setting_t *setting) -{ - settings_t *settings = config_get_ptr(); - - settings->modified = true; - - if (setting->change_handler) - setting->change_handler(setting); - - if (setting->cmd_trigger.idx && !setting->cmd_trigger.triggered) - command_event(setting->cmd_trigger.idx, NULL); -} - -inline void addSublabelAndWhatsThis(QWidget *widget, rarch_setting_t *setting) +static inline void add_sublabel_and_whats_this( + QWidget *widget, rarch_setting_t *setting) { struct menu_file_list_cbs cbs = {}; char tmp[512]; @@ -56,14 +44,14 @@ inline void addSublabelAndWhatsThis(QWidget *widget, rarch_setting_t *setting) widget->setWhatsThis(tmp); } -static QString sanitizeAmpersand(QString input) +static QString sanitize_ampersand(QString input) { return input.replace("&", "&&"); } -inline QString formLabel(rarch_setting_t *setting) +static inline QString form_label(rarch_setting_t *setting) { - return QString(sanitizeAmpersand(setting->short_description)) + ":"; + return QString(sanitize_ampersand(setting->short_description)) + ":"; } FormLayout::FormLayout(QWidget *parent) : @@ -86,61 +74,61 @@ void FormLayout::addUIntRadioButtons(rarch_setting_t *setting) void FormLayout::addUIntComboBox(rarch_setting_t *setting) { if (setting && setting->short_description) - addRow(formLabel(setting), new UIntComboBox(setting)); + addRow(form_label(setting), new UIntComboBox(setting)); } void FormLayout::addStringComboBox(rarch_setting_t *setting) { if (setting && setting->short_description) - addRow(formLabel(setting), new StringComboBox(setting)); + addRow(form_label(setting), new StringComboBox(setting)); } void FormLayout::addStringLineEdit(rarch_setting_t *setting) { if (setting && setting->short_description) - addRow(formLabel(setting), new StringLineEdit(setting)); + addRow(form_label(setting), new StringLineEdit(setting)); } void FormLayout::addPasswordLineEdit(rarch_setting_t *setting) { if (setting && setting->short_description) - addRow(formLabel(setting), new PasswordLineEdit(setting)); + addRow(form_label(setting), new PasswordLineEdit(setting)); } void FormLayout::addUIntSpinBox(rarch_setting_t *setting) { if (setting && setting->short_description) - addRow(formLabel(setting), new UIntSpinBox(setting)); + addRow(form_label(setting), new UIntSpinBox(setting)); } void FormLayout::addSizeSpinBox(rarch_setting_t *setting, unsigned scale) { if (setting && setting->short_description) - addRow(formLabel(setting), new SizeSpinBox(setting, scale)); + addRow(form_label(setting), new SizeSpinBox(setting, scale)); } void FormLayout::addFloatSpinBox(rarch_setting_t *setting) { if (setting && setting->short_description) - addRow(formLabel(setting), new FloatSpinBox(setting)); + addRow(form_label(setting), new FloatSpinBox(setting)); } void FormLayout::addDirectorySelector(rarch_setting_t *setting) { if (setting && setting->short_description) - addRow(formLabel(setting), new DirectorySelector(setting)); + addRow(form_label(setting), new DirectorySelector(setting)); } void FormLayout::addFileSelector(rarch_setting_t *setting) { if (setting && setting->short_description) - addRow(formLabel(setting), new FileSelector(setting)); + addRow(form_label(setting), new FileSelector(setting)); } void FormLayout::addFloatSliderAndSpinBox(rarch_setting_t *setting) { if (setting && setting->short_description) - addRow(formLabel(setting), new FloatSliderAndSpinBox(setting)); + addRow(form_label(setting), new FloatSliderAndSpinBox(setting)); } void FormLayout::addUIntColorButton(const QString &title, msg_hash_enums r, msg_hash_enums g, msg_hash_enums b) @@ -266,7 +254,7 @@ void SettingsGroup::addBindButton(rarch_setting_t *setting) } CheckBox::CheckBox(rarch_setting_t *setting, QWidget *parent) : - QCheckBox(sanitizeAmpersand(setting->short_description), parent) + QCheckBox(sanitize_ampersand(setting->short_description), parent) ,m_setting(setting) ,m_value(setting->value.target.boolean) { @@ -276,7 +264,7 @@ CheckBox::CheckBox(rarch_setting_t *setting, QWidget *parent) : connect(this, SIGNAL(toggled(bool)), this, SLOT(onClicked(bool))); connect(this, SIGNAL(clicked(bool)), this, SLOT(onClicked(bool))); - addSublabelAndWhatsThis(this, m_setting); + add_sublabel_and_whats_this(this, m_setting); } CheckBox::CheckBox(const char *setting, QWidget *parent) : @@ -293,7 +281,7 @@ void CheckBox::onClicked(bool checked) { *m_value = checked; - handleChange(m_setting); + setting_generic_handle_change(m_setting); } void CheckBox::paintEvent(QPaintEvent *event) @@ -325,7 +313,7 @@ CheckableSettingsGroup::CheckableSettingsGroup(rarch_setting_t *setting, QWidget connect(this, SIGNAL(clicked(bool)), this, SLOT(onClicked(bool))); - addSublabelAndWhatsThis(this, m_setting); + add_sublabel_and_whats_this(this, m_setting); } } @@ -343,7 +331,7 @@ void CheckableSettingsGroup::onClicked(bool checked) { *m_value = checked; - handleChange(m_setting); + setting_generic_handle_change(m_setting); } void CheckableSettingsGroup::paintEvent(QPaintEvent *event) @@ -383,14 +371,14 @@ CheckableIcon::CheckableIcon(rarch_setting_t *setting, const QIcon &icon, QWidge connect(this, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool))); - addSublabelAndWhatsThis(this, m_setting); + add_sublabel_and_whats_this(this, m_setting); } void CheckableIcon::onToggled(bool checked) { *m_value = QAbstractButton::isChecked(); - handleChange(m_setting); + setting_generic_handle_change(m_setting); QAbstractButton::setChecked(checked); } @@ -415,7 +403,7 @@ StringLineEdit::StringLineEdit(rarch_setting_t *setting, QWidget *parent) : { connect(this, SIGNAL(editingFinished()), this, SLOT(onEditingFinished())); - addSublabelAndWhatsThis(this, m_setting); + add_sublabel_and_whats_this(this, m_setting); } StringLineEdit::StringLineEdit(const char *setting, QWidget *parent) : @@ -427,7 +415,7 @@ void StringLineEdit::onEditingFinished() { strlcpy(m_value, text().toUtf8().data(), m_setting->size); - handleChange(m_setting); + setting_generic_handle_change(m_setting); setModified(false); } @@ -458,7 +446,7 @@ StringComboBox::StringComboBox(rarch_setting_t *setting, QWidget *parent) : connect(this, SIGNAL(currentTextChanged(const QString&)), this, SLOT(onCurrentTextChanged(const QString&))); - addSublabelAndWhatsThis(this, m_setting); + add_sublabel_and_whats_this(this, m_setting); } StringComboBox::StringComboBox(const char *setting, QWidget *parent) : @@ -470,7 +458,7 @@ void StringComboBox::onCurrentTextChanged(const QString &text) { strlcpy(m_value, text.toUtf8().data(), sizeof(m_value)); - handleChange(m_setting); + setting_generic_handle_change(m_setting); } void StringComboBox::paintEvent(QPaintEvent *event) @@ -491,7 +479,7 @@ UIntComboBox::UIntComboBox(rarch_setting_t *setting, QWidget *parent) : connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int))); - addSublabelAndWhatsThis(this, m_setting); + add_sublabel_and_whats_this(this, m_setting); } UIntComboBox::UIntComboBox(rarch_setting_t *setting, double min, double max, QWidget *parent) : @@ -503,7 +491,7 @@ UIntComboBox::UIntComboBox(rarch_setting_t *setting, double min, double max, QWi connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int))); - addSublabelAndWhatsThis(this, m_setting); + add_sublabel_and_whats_this(this, m_setting); } void UIntComboBox::populate(double min, double max) @@ -562,7 +550,7 @@ void UIntComboBox::onCurrentIndexChanged(int index) *m_value = currentData().toUInt(); - handleChange(m_setting); + setting_generic_handle_change(m_setting); } void UIntComboBox::paintEvent(QPaintEvent *event) @@ -583,7 +571,7 @@ UIntSpinBox::UIntSpinBox(rarch_setting_t *setting, QWidget *parent) : connect(this, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int))); - addSublabelAndWhatsThis(this, m_setting); + add_sublabel_and_whats_this(this, m_setting); } UIntSpinBox::UIntSpinBox(msg_hash_enums enum_idx, QWidget *parent) : @@ -594,7 +582,7 @@ UIntSpinBox::UIntSpinBox(msg_hash_enums enum_idx, QWidget *parent) : void UIntSpinBox::onValueChanged(int value) { *m_value = value; - handleChange(m_setting); + setting_generic_handle_change(m_setting); } void UIntSpinBox::paintEvent(QPaintEvent *event) @@ -626,7 +614,7 @@ SizeSpinBox::SizeSpinBox(rarch_setting_t *setting, unsigned scale, QWidget *pare connect(this, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int))); - addSublabelAndWhatsThis(this, m_setting); + add_sublabel_and_whats_this(this, m_setting); } SizeSpinBox::SizeSpinBox(msg_hash_enums enum_idx, unsigned scale, QWidget *parent) : @@ -637,7 +625,7 @@ SizeSpinBox::SizeSpinBox(msg_hash_enums enum_idx, unsigned scale, QWidget *paren void SizeSpinBox::onValueChanged(int value) { *m_value = value * m_scale; - handleChange(m_setting); + setting_generic_handle_change(m_setting); } void SizeSpinBox::paintEvent(QPaintEvent *event) @@ -689,7 +677,7 @@ UIntRadioButton::UIntRadioButton(const QString &text, rarch_setting_t *setting, void UIntRadioButton::onClicked(bool) { *m_target = m_value; - handleChange(m_setting); + setting_generic_handle_change(m_setting); } void UIntRadioButton::paintEvent(QPaintEvent *event) @@ -743,7 +731,7 @@ UIntRadioButtons::UIntRadioButtons(rarch_setting_t *setting, QWidget *parent) : *setting->value.target.unsigned_integer = orig_value; } - addSublabelAndWhatsThis(this, m_setting); + add_sublabel_and_whats_this(this, m_setting); connect(m_buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(onButtonClicked(int))); } @@ -761,7 +749,7 @@ void UIntRadioButtons::onButtonClicked(int id) { *m_value = id; - handleChange(m_setting); + setting_generic_handle_change(m_setting); } IntSpinBox::IntSpinBox(rarch_setting_t *setting, QWidget *parent) : @@ -776,13 +764,13 @@ IntSpinBox::IntSpinBox(rarch_setting_t *setting, QWidget *parent) : connect(this, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int))); - addSublabelAndWhatsThis(this, m_setting); + add_sublabel_and_whats_this(this, m_setting); } void IntSpinBox::onValueChanged(int value) { *m_value = value; - handleChange(m_setting); + setting_generic_handle_change(m_setting); } void IntSpinBox::paintEvent(QPaintEvent *event) @@ -826,14 +814,14 @@ FloatSpinBox::FloatSpinBox(rarch_setting_t *setting, QWidget *parent) : setSingleStep(setting->step); connect(this, SIGNAL(valueChanged(double)), this, SLOT(onValueChanged(double))); - addSublabelAndWhatsThis(this, m_setting); + add_sublabel_and_whats_this(this, m_setting); } void FloatSpinBox::onValueChanged(double value) { *m_value = (float)value; - handleChange(m_setting); + setting_generic_handle_change(m_setting); } void FloatSpinBox::paintEvent(QPaintEvent *event) @@ -861,7 +849,7 @@ PathButton::PathButton(rarch_setting_t *setting, QWidget *parent) : { connect(this, SIGNAL(clicked(bool)), this, SLOT(onClicked(bool))); - addSublabelAndWhatsThis(this, m_setting); + add_sublabel_and_whats_this(this, m_setting); } PathButton::PathButton(const char *setting, QWidget *parent) : @@ -888,7 +876,7 @@ void DirectoryButton::onClicked(bool) { strlcpy(m_setting->value.target.string, QDir::toNativeSeparators(dir).toUtf8().data(), m_setting->size); - handleChange(m_setting); + setting_generic_handle_change(m_setting); } emit changed(); @@ -906,7 +894,7 @@ void FileButton::onClicked(bool) { strlcpy(m_setting->value.target.string, QDir::toNativeSeparators(file).toUtf8().data(), m_setting->size); - handleChange(m_setting); + setting_generic_handle_change(m_setting); } emit changed(); @@ -967,14 +955,14 @@ FloatSlider::FloatSlider(rarch_setting_t *setting, QWidget *parent) : connect(this, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int))); - addSublabelAndWhatsThis(this, m_setting); + add_sublabel_and_whats_this(this, m_setting); } void FloatSlider::onValueChanged(int value) { *m_value = (float)value / m_precision; - handleChange(m_setting); + setting_generic_handle_change(m_setting); } void FloatSlider::paintEvent(QPaintEvent *event) From 6a4a522244d23db30fcd6890eb5c7dd93c2ac8a2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 May 2020 17:19:55 +0200 Subject: [PATCH 046/192] Cut down on some code duplication and turn retroarch_validate_game_options static --- menu/cbs/menu_cbs_ok.c | 29 +---------------------- retroarch.c | 36 ++++++++++++++++++++++++++++- retroarch.h | 4 ++-- ui/drivers/qt/coreoptionsdialog.cpp | 32 +------------------------ 4 files changed, 39 insertions(+), 62 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 35a9c6038a..180ceeace8 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -4640,37 +4640,10 @@ default_action_ok_download(action_ok_update_databases, MENU_ENUM_LABEL_CB_UPDATE default_action_ok_download(action_ok_update_cheats, MENU_ENUM_LABEL_CB_UPDATE_CHEATS) default_action_ok_download(action_ok_update_autoconfig_profiles, MENU_ENUM_LABEL_CB_UPDATE_AUTOCONFIG_PROFILES) -/* creates folder and core options stub file for subsequent runs */ static int action_ok_option_create(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - char game_path[PATH_MAX_LENGTH]; - config_file_t *conf = NULL; - - game_path[0] = '\0'; - - if (!retroarch_validate_game_options(game_path, sizeof(game_path), true)) - { - runloop_msg_queue_push( - msg_hash_to_str(MSG_ERROR_SAVING_CORE_OPTIONS_FILE), - 1, 100, true, - NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); - return 0; - } - - if (!(conf = config_file_new_from_path_to_string(game_path))) - if (!(conf = config_file_new_alloc())) - return false; - - if (config_file_write(conf, game_path, true)) - { - runloop_msg_queue_push( - msg_hash_to_str(MSG_CORE_OPTIONS_FILE_CREATED_SUCCESSFULLY), - 1, 100, true, - NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); - path_set(RARCH_PATH_CORE_OPTIONS, game_path); - } - config_file_free(conf); + create_folder_and_core_options(); return 0; } diff --git a/retroarch.c b/retroarch.c index e9cad2b88a..a1ba412700 100644 --- a/retroarch.c +++ b/retroarch.c @@ -26169,7 +26169,7 @@ static void retroarch_parse_input_and_config(int argc, char *argv[]) dir_set(RARCH_DIR_SAVESTATE, global->name.savestate); } -bool retroarch_validate_game_options(char *s, size_t len, bool mkdir) +static bool retroarch_validate_game_options(char *s, size_t len, bool mkdir) { char *config_directory = NULL; size_t str_size = PATH_MAX_LENGTH * sizeof(char); @@ -29678,3 +29678,37 @@ void reset_gamepad_input_override(void) gamepad_input_override = 0; } #endif + +/* creates folder and core options stub file for subsequent runs */ +bool create_folder_and_core_options(void) +{ + char game_path[PATH_MAX_LENGTH]; + config_file_t *conf = NULL; + + game_path[0] = '\0'; + + if (!retroarch_validate_game_options(game_path, sizeof(game_path), true)) + { + runloop_msg_queue_push( + msg_hash_to_str(MSG_ERROR_SAVING_CORE_OPTIONS_FILE), + 1, 100, true, + NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + return false; + } + + if (!(conf = config_file_new_from_path_to_string(game_path))) + if (!(conf = config_file_new_alloc())) + return false; + + if (config_file_write(conf, game_path, true)) + { + runloop_msg_queue_push( + msg_hash_to_str(MSG_CORE_OPTIONS_FILE_CREATED_SUCCESSFULLY), + 1, 100, true, + NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + path_set(RARCH_PATH_CORE_OPTIONS, game_path); + } + config_file_free(conf); + + return true; +} diff --git a/retroarch.h b/retroarch.h index d381d679ad..db93f87d15 100644 --- a/retroarch.h +++ b/retroarch.h @@ -301,8 +301,6 @@ void retroarch_override_setting_unset(enum rarch_override_setting enum_idx, void bool retroarch_override_setting_is_set(enum rarch_override_setting enum_idx, void *data); -bool retroarch_validate_game_options(char *s, size_t len, bool mkdir); - bool retroarch_is_forced_fullscreen(void); void retroarch_set_current_core_type( @@ -2007,6 +2005,8 @@ void retroarch_init_task_queue(void); bool is_input_keyboard_display_on(void); +/* creates folder and core options stub file for subsequent runs */ +bool create_folder_and_core_options(void); /* Input overrides */ diff --git a/ui/drivers/qt/coreoptionsdialog.cpp b/ui/drivers/qt/coreoptionsdialog.cpp index 3d5a560f3a..4d26f80789 100644 --- a/ui/drivers/qt/coreoptionsdialog.cpp +++ b/ui/drivers/qt/coreoptionsdialog.cpp @@ -122,38 +122,8 @@ void CoreOptionsDialog::reload() void CoreOptionsDialog::onSaveGameSpecificOptions() { - char game_path[PATH_MAX_LENGTH]; - config_file_t *conf = NULL; - - game_path[0] = '\0'; - - if (!retroarch_validate_game_options(game_path, sizeof(game_path), true)) - { + if (!create_folder_and_core_options()) QMessageBox::critical(this, msg_hash_to_str(MSG_ERROR), msg_hash_to_str(MSG_ERROR_SAVING_CORE_OPTIONS_FILE)); - return; - } - - if (!(conf = config_file_new_from_path_to_string(game_path))) - { - if (!(conf = config_file_new_alloc())) - { - QMessageBox::critical(this, msg_hash_to_str(MSG_ERROR), msg_hash_to_str(MSG_ERROR_SAVING_CORE_OPTIONS_FILE)); - return; - } - } - - if (config_file_write(conf, game_path, true)) - { - runloop_msg_queue_push( - msg_hash_to_str(MSG_CORE_OPTIONS_FILE_CREATED_SUCCESSFULLY), - 1, 100, true, NULL, - MESSAGE_QUEUE_ICON_DEFAULT, - MESSAGE_QUEUE_CATEGORY_INFO - ); - path_set(RARCH_PATH_CORE_OPTIONS, game_path); - } - - config_file_free(conf); } void CoreOptionsDialog::onCoreOptionComboBoxCurrentIndexChanged(int index) From 43b890a2691f22314fadbe0b1f21b8860655b674 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Mon, 11 May 2020 16:27:19 +0100 Subject: [PATCH 047/192] (GLUI) Desktop View: When scrolling playlists, show last selected thumbnails while waiting for next entry to load --- menu/drivers/materialui.c | 136 ++++++++++++++++++++++++++++++-------- 1 file changed, 107 insertions(+), 29 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 601983d4d9..7ba0c9a2a8 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -1073,6 +1073,20 @@ typedef struct * Colour Themes END * ============================== */ +/* Animation defines */ +#define MUI_ANIM_DURATION_SCROLL 166.66667f +#define MUI_ANIM_DURATION_SCROLL_RESET 83.333333f +/* According to Material UI specifications, animations + * that affect a large portion of the screen should + * have a duration of between 250ms and 300ms. This + * should therefore be the value used for menu + * transitions - but even 250ms feels too slow... + * We compromise by setting a time of 200ms, which + * is the same as the 'short press' duration. + * This is reasonably fast, without making slide + * animations too 'jarring'... */ +#define MUI_ANIM_DURATION_MENU_TRANSITION 200.0f + /* Set a baseline aspect ratio of 4:3 for thumbnail * images */ #define MUI_THUMBNAIL_DEFAULT_ASPECT_RATIO 1.3333333f @@ -1096,6 +1110,13 @@ typedef struct * too easy to enqueue vast numbers of image * requests... */ #define MUI_THUMBNAIL_STREAM_DELAY_SCROLLBAR_DRAG 166.66667f +/* Thumbnail stream delay when viewing + * 'desktop'-layout playlists + * > In this case, thumbnails are loaded + * as the entry selection is changed. We + * therefore want the stream delay to match + * the scroll animation duration */ +#define MUI_THUMBNAIL_STREAM_DELAY_PLAYLIST_DESKTOP MUI_ANIM_DURATION_SCROLL /* Defines the various types of supported menu * list views @@ -1365,20 +1386,6 @@ typedef struct char last_played_fallback_str[255]; } materialui_status_bar_t; -/* Animation defines */ -#define MUI_ANIM_DURATION_SCROLL 166.66667f -#define MUI_ANIM_DURATION_SCROLL_RESET 83.333333f -/* According to Material UI specifications, animations - * that affect a large portion of the screen should - * have a duration of between 250ms and 300ms. This - * should therefore be the value used for menu - * transitions - but even 250ms feels too slow... - * We compromise by setting a time of 200ms, which - * is the same as the 'short press' duration. - * This is reasonably fast, without making slide - * animations too 'jarring'... */ -#define MUI_ANIM_DURATION_MENU_TRANSITION 200.0f - /* Defines common positions when referencing * the list of currently on screen menu entries * > Used to specify a target when the current @@ -1506,6 +1513,7 @@ typedef struct materialui_handle /* Thumbnail helpers */ gfx_thumbnail_path_data_t *thumbnail_path_data; + float thumbnail_stream_delay; unsigned thumbnail_width_max; unsigned thumbnail_height_max; bool primary_thumbnail_available; @@ -1514,6 +1522,12 @@ typedef struct materialui_handle size_t fullscreen_thumbnail_selection; float fullscreen_thumbnail_alpha; char fullscreen_thumbnail_label[255]; + /* > When viewing 'desktop'-layout playlists, + * need to cache the index of the last + * selected entry so we can keep displaying + * its thumbnails while waiting for next + * to load after the selection has changed */ + size_t desktop_thumbnail_last_selection; /* Status bar */ materialui_status_bar_t status_bar; @@ -2795,21 +2809,45 @@ static bool materialui_render_process_entry_playlist_desktop( unsigned thumbnail_upscale_threshold, bool network_on_demand_thumbnails) { - bool is_selected = (entry_idx == selection); + bool is_selected = (entry_idx == selection); + /* We want to load (and keep in memory) + * thumbnails for the currently selected + * entry *and* the last entry for which + * thumbnail data was available. This allows + * us to keep showing 'old' thumbnails in the + * sidebar while waiting for new ones to load + * (otherwise the sidebar is left blank, + * which looks ugly...) */ + bool is_on_screen = is_selected || + (entry_idx == mui->desktop_thumbnail_last_selection); - /* Load thumbnails for selected entry and free - * thumbnails for all other entries + /* Load thumbnails for selected (and last + * selected) entry and free thumbnails for + * all other entries * > Note that secondary thumbnail is force * enabled */ gfx_thumbnail_process_streams( mui->thumbnail_path_data, mui->playlist, entry_idx, &node->thumbnails.primary, &node->thumbnails.secondary, - is_selected, + is_on_screen, thumbnail_upscale_threshold, network_on_demand_thumbnails); + /* If this is *not* the currently selected + * entry, then our work is done */ + if (!is_selected) + return true; + + /* If thumbnails have been requested for the + * selected entry, then it has valid content + * to display in the sidebar -> cache this as + * the 'last selected' entry */ + if ((node->thumbnails.primary.status != GFX_THUMBNAIL_STATUS_UNKNOWN) && + (node->thumbnails.secondary.status != GFX_THUMBNAIL_STATUS_UNKNOWN)) + mui->desktop_thumbnail_last_selection = selection; + /* Fetch metadata for selected entry */ - if (is_selected && mui->status_bar.enabled) + if (mui->status_bar.enabled) { gfx_animation_ctx_tag alpha_tag = (uintptr_t)&mui->status_bar.alpha; @@ -2832,7 +2870,7 @@ static bool materialui_render_process_entry_playlist_desktop( /* Check if delay timer has elapsed */ mui->status_bar.delay_timer += gfx_animation_get_delta_time(); - if (mui->status_bar.delay_timer > gfx_thumbnail_get_stream_delay()) + if (mui->status_bar.delay_timer > mui->thumbnail_stream_delay) { settings_t *settings = config_get_ptr(); bool content_runtime_log = settings->bools.content_runtime_log; @@ -4219,12 +4257,35 @@ static void materialui_render_selected_entry_aux_playlist_desktop( mui->colors.entry_divider); /* Draw thumbnails */ - - /* > Primary */ if (node) + { + gfx_thumbnail_t *primary_thumbnail = &node->thumbnails.primary; + gfx_thumbnail_t *secondary_thumbnail = &node->thumbnails.secondary; + + /* If we have not yet requested thumbnails + * for the currently selected entry, keep + * drawing thumbnails for the last 'valid' + * entry instead (this ensures we always + * display *something* in the sidebar + * - leaving it blank is ugly...) */ + if ((primary_thumbnail->status == GFX_THUMBNAIL_STATUS_UNKNOWN) && + (secondary_thumbnail->status == GFX_THUMBNAIL_STATUS_UNKNOWN)) + { + materialui_node_t *last_node = (materialui_node_t*) + file_list_get_userdata_at_offset(list, + mui->desktop_thumbnail_last_selection); + + if (last_node) + { + primary_thumbnail = &last_node->thumbnails.primary; + secondary_thumbnail = &last_node->thumbnails.secondary; + } + } + + /* Draw primary */ materialui_draw_thumbnail( mui, - &node->thumbnails.primary, + primary_thumbnail, userdata, video_width, video_height, @@ -4232,17 +4293,17 @@ static void materialui_render_selected_entry_aux_playlist_desktop( thumbnail_y, 1.0f); - /* > Secondary */ - if (node) + /* Draw secondary */ materialui_draw_thumbnail( mui, - &node->thumbnails.secondary, + secondary_thumbnail, userdata, video_width, video_height, thumbnail_x, thumbnail_y + (float)mui->thumbnail_height_max + (float)mui->margin, 1.0f); + } /* Draw status bar */ if (mui->status_bar.enabled) @@ -6754,6 +6815,22 @@ static void materialui_update_list_view(materialui_handle_t *mui) materialui_set_thumbnail_dimensions(mui); materialui_set_secondary_thumbnail_enable(mui, settings); + /* Miscellaneous post-list-switch configuration: + * > Set appropriate thumbnail stream delay */ + mui->thumbnail_stream_delay = + (mui->list_view_type == MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP) ? + MUI_THUMBNAIL_STREAM_DELAY_PLAYLIST_DESKTOP : + MUI_THUMBNAIL_STREAM_DELAY_DEFAULT; + gfx_thumbnail_set_stream_delay(mui->thumbnail_stream_delay); + /* > Reset 'desktop'-layout last selected + * entry index (we only need to do this if + * list_view_type == MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP, + * but it's faster to always set the variable + * than it is to perform a check...) */ + mui->desktop_thumbnail_last_selection = 0; + + /* List view configuration complete - signal + * that entry dimensions must be recalculated */ mui->need_compute = true; } @@ -7049,7 +7126,8 @@ static void *materialui_init(void **userdata, bool video_is_threaded) materialui_init_nav_bar(mui); /* Set initial thumbnail stream delay */ - gfx_thumbnail_set_stream_delay(MUI_THUMBNAIL_STREAM_DELAY_DEFAULT); + mui->thumbnail_stream_delay = MUI_THUMBNAIL_STREAM_DELAY_DEFAULT; + gfx_thumbnail_set_stream_delay(mui->thumbnail_stream_delay); /* Set thumbnail fade duration to default */ gfx_thumbnail_set_fade_duration(-1.0f); @@ -8644,8 +8722,8 @@ static int materialui_pointer_up(void *userdata, * list will continue to 'drift' in drag direction */ menu_input_set_pointer_y_accel(0.0f); - /* Reset thumbnail stream delay to default */ - gfx_thumbnail_set_stream_delay(MUI_THUMBNAIL_STREAM_DELAY_DEFAULT); + /* Reset thumbnail stream delay */ + gfx_thumbnail_set_stream_delay(mui->thumbnail_stream_delay); mui->scrollbar.dragged = false; return 0; From ef4261e1f81c7ada058e66e6d1f5e33b5f6a57f6 Mon Sep 17 00:00:00 2001 From: Autechre Date: Mon, 11 May 2020 23:33:05 +0200 Subject: [PATCH 048/192] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 7d54fa359c..0312660099 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ - LINUX/XDG: Use GenericName correctly in desktop entry - MAC/COCOA: Fix mouse cursor tracking - MENU/MATERIALUI: Add desktop-style playlist view mode +- MENU/MATERIALUI: Desktop View: When scrolling playlists, show last selected thumbnails while waiting for next entry to load - NETPLAY: Fix regressions introduced in 1.8.5 - RGUI: Add option to always stretch menu to fill the screen - WIIU: Enable graphics widgets From 96cfa57d1bc8782ecd18e48d5affb09bc2a1c729 Mon Sep 17 00:00:00 2001 From: Autechre Date: Mon, 11 May 2020 23:33:23 +0200 Subject: [PATCH 049/192] Update CHANGES.md --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 0312660099..3b397b42fd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,7 +4,7 @@ - LINUX/XDG: Use GenericName correctly in desktop entry - MAC/COCOA: Fix mouse cursor tracking - MENU/MATERIALUI: Add desktop-style playlist view mode -- MENU/MATERIALUI: Desktop View: When scrolling playlists, show last selected thumbnails while waiting for next entry to load +- MENU/MATERIALUI/DESKTOPVIEW: When scrolling playlists, show last selected thumbnails while waiting for next entry to load - NETPLAY: Fix regressions introduced in 1.8.5 - RGUI: Add option to always stretch menu to fill the screen - WIIU: Enable graphics widgets From 4093616e09884fed9b50c5c4a53ac8da3fc80f29 Mon Sep 17 00:00:00 2001 From: Jamiras Date: Mon, 11 May 2020 16:24:29 -0600 Subject: [PATCH 050/192] make sure texture pointer is null when load fails --- cheevos-new/badges.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cheevos-new/badges.c b/cheevos-new/badges.c index 627363198d..d1895b9167 100644 --- a/cheevos-new/badges.c +++ b/cheevos-new/badges.c @@ -54,7 +54,7 @@ void cheevos_set_menu_badge(int index, const char *badge, bool locked) uintptr_t cheevos_get_menu_badge_texture(int index) { if (index < CHEEVOS_MENU_BADGE_LIMIT) - return cheevos_badge_menu_texture_list[index]; + return cheevos_badge_menu_texture_list[index]; return 0; } @@ -65,7 +65,7 @@ uintptr_t cheevos_get_badge_texture(const char *badge, bool locked) { char badge_file[24]; char fullpath[PATH_MAX_LENGTH]; - uintptr_t tex; + uintptr_t tex = 0; if (!badge) return 0; @@ -76,8 +76,9 @@ uintptr_t cheevos_get_badge_texture(const char *badge, bool locked) PATH_MAX_LENGTH * sizeof(char), APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_CHEEVOS_BADGES); - gfx_display_reset_textures_list(badge_file, fullpath, - &tex, TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL); + if (!gfx_display_reset_textures_list(badge_file, fullpath, + &tex, TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL)) + tex = 0; return tex; } From cc52f140d03764c25be320dabaa5b35160b84d70 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 12 May 2020 02:10:36 +0200 Subject: [PATCH 051/192] 3ds: Add ID for frodo --- pkg/ctr/Makefile.cores | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/ctr/Makefile.cores b/pkg/ctr/Makefile.cores index 06c2665574..c8bab93010 100644 --- a/pkg/ctr/Makefile.cores +++ b/pkg/ctr/Makefile.cores @@ -160,6 +160,13 @@ else ifeq ($(LIBRETRO), freechaf) APP_ICON = pkg/ctr/assets/default.png APP_BANNER = pkg/ctr/assets/libretro_banner.png +else ifeq ($(LIBRETRO), frodo) + APP_TITLE = Frodo + APP_PRODUCT_CODE = RARCH-FRODO + APP_UNIQUE_ID = 0xBACB9 + APP_ICON = pkg/ctr/assets/default.png + APP_BANNER = pkg/ctr/assets/libretro_banner.png + else ifeq ($(LIBRETRO), freeintv) APP_TITLE = FreeIntv APP_AUTHOR = various From cc73de48d6fe3ee82f2739da9f20484102cfe03b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 11 May 2020 19:15:01 +0200 Subject: [PATCH 052/192] Fix dos compilation --- Makefile.griffin | 39 +++++++++++++++ dist-scripts/dist-cores.sh | 8 +++- gfx/drivers/vga_gfx.c | 98 +++++++++++++++++++------------------- input/drivers/dos_input.c | 2 +- 4 files changed, 96 insertions(+), 51 deletions(-) diff --git a/Makefile.griffin b/Makefile.griffin index 62cab16a8f..8638508d4c 100644 --- a/Makefile.griffin +++ b/Makefile.griffin @@ -868,6 +868,45 @@ else ifneq (,$(findstring unix,$(platform))) EXT_INTER_TARGET := $(TARGET_NAME) INCLUDE += -Ilibretro-common/include -Igfx/include -Ideps -Ideps/stb -Ideps/rcheevos/include -Ideps/SPIRV-Cross -Ideps/glslang -I. LIBS += -ldl -lm -lpthread -lGL -ludev -lpulse -lX11 -lX11-xcb -lXxf86vm +else ifeq (dos,$(platform)) + HAVE_AUDIOMIXER := 1 + HAVE_RPNG := 1 + HAVE_RJPEG := 1 + HAVE_RBMP := 1 + HAVE_RTGA := 1 + HAVE_ZLIB := 1 + HAVE_7ZIP := 1 + HAVE_NETWORKING := 0 + HAVE_NETWORK_CMD := 0 + HAVE_NETPLAYDISCOVERY := 0 + HAVE_OVERLAY := 1 + HAVE_VIDEO_LAYOUT := 0 + HAVE_MATERIALUI := 1 + HAVE_XMB := 1 + HAVE_STB_FONT := 1 + HAVE_THREADS := 0 + HAVE_LIBRETRODB := 1 + HAVE_COMMAND := 1 + HAVE_STDIN_CMD := 1 + HAVE_CMD := 1 + HAVE_DYLIB := 0 + HAVE_DYNAMIC := 0 + HAVE_GRIFFIN_CPP := 0 + WANT_GLSLANG := 0 + HAVE_CONFIGFILE := 1 + CC=i586-pc-msdosdjgpp-gcc + CXX=i586-pc-msdosdjgpp-g++ + + ifeq ($(DEBUG), 1) + LDFLAGS += -g + endif + + PLATCFLAGS += -DHAVE_SHADERPIPELINE -DHAVE_OZONE -DHAVE_CC_RESAMPLER -DRC_DISABLE_LUA -DHAVE_FBO -DHAVE_GL_SYNC -DHAVE_IMAGEVIEWER -DHAVE_LANGEXTRA -DHAVE_RUNAHEAD -DHAVE_GFX_WIDGETS -DHAVE_CONFIGFILE -DHAVE_SPIRV_CROSS -DHAVE_STB_FONT -DHAVE_ONLINE_UPDATER -DHAVE_UPDATE_ASSETS -DHAVE_UPDATE_CORES -DHAVE_XMB -DRARCH_INTERNAL -DHAVE_XCB -DRARCH_MOBILE + EXT_TARGET := $(TARGET_NAME)_dos.exe + EXT_INTER_TARGET := $(TARGET_NAME)_dos.exe + INCLUDE += -Ilibretro-common/include -Igfx/include -Ideps -Ideps/stb -Ideps/SPIRV-Cross -Ideps/glslang -I. + LIBS += -lm + LIBDIRS += -L. endif ifneq (,$(findstring msvc,$(platform))) diff --git a/dist-scripts/dist-cores.sh b/dist-scripts/dist-cores.sh index a120bad14b..4001d0b530 100755 --- a/dist-scripts/dist-cores.sh +++ b/dist-scripts/dist-cores.sh @@ -125,6 +125,10 @@ EXE_PATH=${CELL_SDK}/host-win32/bin GENPS3ISO_PATH=${PS3TOOLS_PATH}/ODE/genps3iso_v2.5 SCETOOL_PATH=${PS3TOOLS_PATH}/scetool/scetool.exe SCETOOL_FLAGS_ODE="--sce-type=SELF --compress-data=TRUE --self-type=APP --key-revision=04 --self-fw-version=0003004100000000 --self-app-version=0001000000000000 --self-auth-id=1010000001000003 --self-vendor-id=01000002 --self-cap-flags=00000000000000000000000000000000000000000000003b0000000100040000 --encrypt" +elif [ $PLATFORM = "dos" ]; then + platform=dos + MAKEFILE_GRIFFIN=yes + EXT=a fi # Cleanup Salamander core if it exists @@ -301,7 +305,9 @@ for f in `ls -v *_${platform}.${EXT}`; do elif [ $PLATFORM = "ngc" ] ; then mv -f ../retroarch_${platform}.dol ../pkg/${platform}/${name}_libretro_${platform}.dol elif [ $PLATFORM = "wii" ] ; then - mv -f ../retroarch_${platform}.dol ../pkg/${platform}/${name}_libretro_${platform}.dol + mv -f ../retroarch_${platform}.dol ../pkg/${platform}/${name}_libretro_${platform}.dol + elif [ $PLATFORM = "dos" ] ; then + mv -f ../retroarch_${platform}.exe ../pkg/${platform}/${name}_libretro_${platform}.exe elif [ $PLATFORM = "emscripten" ] ; then mkdir -p ../pkg/emscripten/ mv -f ../${name}_libretro.js ../pkg/emscripten/${name}_libretro.js diff --git a/gfx/drivers/vga_gfx.c b/gfx/drivers/vga_gfx.c index 3299512ceb..f59fe49e54 100644 --- a/gfx/drivers/vga_gfx.c +++ b/gfx/drivers/vga_gfx.c @@ -106,22 +106,22 @@ static void *vga_gfx_init(const video_info_t *video, *input = NULL; *input_data = NULL; - vga->video_width = video->width; - vga->video_height = video->height; - vga->rgb32 = video->rgb32; + vga->vga_video_width = video->width; + vga->vga_video_height = video->height; + vga->vga_rgb32 = video->rgb32; if (video->rgb32) { - vga->video_pitch = video->width * 4; - vga->video_bits = 32; + vga->vga_video_pitch = video->width * 4; + vga->vga_video_bits = 32; } else { - vga->video_pitch = video->width * 2; - vga->video_bits = 16; + vga->vga_video_pitch = video->width * 2; + vga->vga_video_bits = 16; } - vga->frame = (unsigned char*)malloc(VGA_WIDTH * VGA_HEIGHT); + vga->vga_frame = (unsigned char*)malloc(VGA_WIDTH * VGA_HEIGHT); vga_gfx_create(); @@ -152,32 +152,32 @@ static bool vga_gfx_frame(void *data, const void *frame, menu_driver_frame(video_info); #endif - if ( vga->video_width != frame_width || - vga->video_height != frame_height || - vga->video_pitch != pitch) + if ( vga->vga_video_width != frame_width || + vga->vga_video_height != frame_height || + vga->vga_video_pitch != pitch) { if (frame_width > 4 && frame_height > 4) { - vga->video_width = frame_width; - vga->video_height = frame_height; - vga->video_pitch = pitch; + vga->vga_video_width = frame_width; + vga->vga_video_height = frame_height; + vga->vga_video_pitch = pitch; } } - if (vga->menu_frame && video_info->menu_is_alive) + if (vga->vga_menu_frame && video_info->menu_is_alive) { - frame_to_copy = vga->menu_frame; - width = vga->menu_width; - height = vga->menu_height; - pitch = vga->menu_pitch; - bits = vga->menu_bits; + frame_to_copy = vga->vga_menu_frame; + width = vga->vga_menu_width; + height = vga->vga_menu_height; + pitch = vga->vga_menu_pitch; + bits = vga->vga_menu_bits; } else { - width = vga->video_width; - height = vga->video_height; - pitch = vga->video_pitch; - bits = vga->video_bits; + width = vga->vga_video_width; + height = vga->vga_video_height; + pitch = vga->vga_video_pitch; + bits = vga->vga_video_bits; if (frame_width == 4 && frame_height == 4 && (frame_width < width && frame_height < height)) draw = false; @@ -190,7 +190,7 @@ static bool vga_gfx_frame(void *data, const void *frame, { vga_vsync(); - if (frame_to_copy == vga->menu_frame) + if (frame_to_copy == vga->vga_menu_frame) dosmemput(frame_to_copy, MIN(VGA_WIDTH,width)*MIN(VGA_HEIGHT,height), 0xA0000); else @@ -217,11 +217,11 @@ static bool vga_gfx_frame(void *data, const void *frame, unsigned g = ((pixel & 0x07E0) >> 8); unsigned b = ((pixel & 0x001F) >> 3); - vga->frame[VGA_WIDTH * y + x] = (b << 6) | (g << 3) | r; + vga->vga_frame[VGA_WIDTH * y + x] = (b << 6) | (g << 3) | r; } } - dosmemput(vga->frame, VGA_WIDTH*VGA_HEIGHT, 0xA0000); + dosmemput(vga->vga_frame, VGA_WIDTH*VGA_HEIGHT, 0xA0000); } } } @@ -239,7 +239,7 @@ static bool vga_gfx_alive(void *data) { vga_t *vga = (vga_t*)data; /* TODO/FIXME - check if this is valid */ - video_driver_set_size(vga->video_width, vga->video_height); + video_driver_set_size(vga->vga_video_width, vga->vga_video_height); return true; } @@ -263,13 +263,13 @@ static void vga_gfx_free(void *data) if (!vga) return; - if (vga->frame) - free(vga->frame); - vga->frame = NULL; + if (vga->vga_frame) + free(vga->vga_frame); + vga->vga_frame = NULL; - if (vga->menu_frame) - free(vga->menu_frame); - vga->menu_frame = NULL; + if (vga->vga_menu_frame) + free(vga->vga_menu_frame); + vga->vga_menu_frame = NULL; vga_return_to_text_mode(); } @@ -294,18 +294,18 @@ static void vga_set_texture_frame(void *data, if (rgb32) pitch = width * 4; - if (vga->menu_frame) - free(vga->menu_frame); - vga->menu_frame = NULL; + if (vga->vga_menu_frame) + free(vga->vga_menu_frame); + vga->vga_menu_frame = NULL; - if ( !vga->menu_frame || - vga->menu_width != width || - vga->menu_height != height || - vga->menu_pitch != pitch) + if ( !vga->vga_menu_frame || + vga->vga_menu_width != width || + vga->vga_menu_height != height || + vga->vga_menu_pitch != pitch) if (pitch && height) - vga->menu_frame = (unsigned char*)malloc(VGA_WIDTH * VGA_HEIGHT); + vga->vga_menu_frame = (unsigned char*)malloc(VGA_WIDTH * VGA_HEIGHT); - if (vga->menu_frame && frame && pitch && height) + if (vga->vga_menu_frame && frame && pitch && height) { unsigned x, y; @@ -324,15 +324,15 @@ static void vga_set_texture_frame(void *data, unsigned r = ((pixel & 0xF000) >> 13); unsigned g = ((pixel & 0xF00) >> 9); unsigned b = ((pixel & 0xF0) >> 6); - vga->menu_frame[VGA_WIDTH * y + x] = (b << 6) | (g << 3) | r; + vga->vga_menu_frame[VGA_WIDTH * y + x] = (b << 6) | (g << 3) | r; } } } - vga->menu_width = width; - vga->menu_height = height; - vga->menu_pitch = pitch; - vga->menu_bits = rgb32 ? 32 : 16; + vga->vga_menu_width = width; + vga->vga_menu_height = height; + vga->vga_menu_pitch = pitch; + vga->vga_menu_bits = rgb32 ? 32 : 16; } } @@ -344,7 +344,7 @@ static uint32_t vga_get_flags(void *data) } static const video_poke_interface_t vga_poke_interface = { - vga_gfx_get_flags, + vga_get_flags, NULL, NULL, NULL, diff --git a/input/drivers/dos_input.c b/input/drivers/dos_input.c index 7877ddc424..3f55cc7d41 100644 --- a/input/drivers/dos_input.c +++ b/input/drivers/dos_input.c @@ -43,7 +43,7 @@ static bool dos_keyboard_port_input_pressed( const struct retro_keybind *binds, unsigned id) { if (id < RARCH_BIND_LIST_END) - return dos_key_state[DOS_KEYBOARD_PORT][rarch_keysym_lut[&binds[id].key]]; + return dos_key_state[DOS_KEYBOARD_PORT][rarch_keysym_lut[binds[id].key]]; return false; } From 7b351da0065355813d39430f0845dbf06b03ccff Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 11 May 2020 19:45:44 +0200 Subject: [PATCH 053/192] Fix crash with null audio driver --- retroarch.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/retroarch.c b/retroarch.c index a1ba412700..2a54db3519 100644 --- a/retroarch.c +++ b/retroarch.c @@ -19392,6 +19392,14 @@ static bool audio_driver_init_internal(bool audio_cb_inited) } audio_driver_find_driver(); + + if (current_audio == NULL || current_audio->init == NULL) + { + RARCH_ERR("Failed to initialize audio driver. Will continue without audio.\n"); + audio_driver_active = false; + return false; + } + #ifdef HAVE_THREADS if (audio_cb_inited) { From 67c3c93aec6cb84f9a5372ee6c6bda3f33e25e95 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 12 May 2020 01:04:39 +0200 Subject: [PATCH 054/192] dos fixes --- Makefile.griffin | 9 +- frontend/drivers/platform_dos.c | 127 ++++++++++++++++++------- gfx/drivers/vga_gfx.c | 4 +- libretro-common/include/retro_timers.h | 2 +- 4 files changed, 100 insertions(+), 42 deletions(-) diff --git a/Makefile.griffin b/Makefile.griffin index 8638508d4c..634ccc1472 100644 --- a/Makefile.griffin +++ b/Makefile.griffin @@ -882,7 +882,7 @@ else ifeq (dos,$(platform)) HAVE_OVERLAY := 1 HAVE_VIDEO_LAYOUT := 0 HAVE_MATERIALUI := 1 - HAVE_XMB := 1 + HAVE_XMB := 0 HAVE_STB_FONT := 1 HAVE_THREADS := 0 HAVE_LIBRETRODB := 1 @@ -901,9 +901,10 @@ else ifeq (dos,$(platform)) LDFLAGS += -g endif - PLATCFLAGS += -DHAVE_SHADERPIPELINE -DHAVE_OZONE -DHAVE_CC_RESAMPLER -DRC_DISABLE_LUA -DHAVE_FBO -DHAVE_GL_SYNC -DHAVE_IMAGEVIEWER -DHAVE_LANGEXTRA -DHAVE_RUNAHEAD -DHAVE_GFX_WIDGETS -DHAVE_CONFIGFILE -DHAVE_SPIRV_CROSS -DHAVE_STB_FONT -DHAVE_ONLINE_UPDATER -DHAVE_UPDATE_ASSETS -DHAVE_UPDATE_CORES -DHAVE_XMB -DRARCH_INTERNAL -DHAVE_XCB -DRARCH_MOBILE - EXT_TARGET := $(TARGET_NAME)_dos.exe - EXT_INTER_TARGET := $(TARGET_NAME)_dos.exe + PLATCFLAGS += -DHAVE_SHADERPIPELINE -DHAVE_CC_RESAMPLER -DRC_DISABLE_LUA -DHAVE_FBO -DHAVE_IMAGEVIEWER -DHAVE_LANGEXTRA -DHAVE_GFX_WIDGETS -DHAVE_CONFIGFILE -DHAVE_SPIRV_CROSS -DHAVE_STB_FONT -DRARCH_INTERNAL -DHAVE_XCB + TARGET_NAME := retrodos + EXT_TARGET := $(TARGET_NAME).exe + EXT_INTER_TARGET := $(TARGET_NAME).exe INCLUDE += -Ilibretro-common/include -Igfx/include -Ideps -Ideps/stb -Ideps/SPIRV-Cross -Ideps/glslang -I. LIBS += -lm LIBDIRS += -L. diff --git a/frontend/drivers/platform_dos.c b/frontend/drivers/platform_dos.c index 1d49f313cd..af8a312a97 100644 --- a/frontend/drivers/platform_dos.c +++ b/frontend/drivers/platform_dos.c @@ -21,59 +21,116 @@ static void frontend_dos_init(void *data) { - printf("Loading RetroArch...\n"); + printf("Loading RetroArch...\n"); } static void frontend_dos_shutdown(bool unused) { - (void)unused; + (void)unused; } static int frontend_dos_get_rating(void) { - return -1; + return -1; } enum frontend_architecture frontend_dos_get_architecture(void) { - return FRONTEND_ARCH_X86; + return FRONTEND_ARCH_X86; } static void frontend_dos_get_env_settings(int *argc, char *argv[], void *data, void *params_data) { + char base_path[PATH_MAX] = {0}; + int i; + + retro_main_log_file_init("retrodos.txt", false); + + strlcpy(base_path, "retrodos", sizeof(base_path)); + + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], base_path, + "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], base_path, + "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], base_path, + "autoconf", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); + + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], base_path, + "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); + + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], base_path, + "config", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_REMAP], + g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], + "remaps", sizeof(g_defaults.dirs[DEFAULT_DIR_REMAP])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], base_path, + "playlist", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_RECORD_CONFIG], base_path, + "recrdcfg", sizeof(g_defaults.dirs[DEFAULT_DIR_RECORD_CONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_RECORD_OUTPUT], base_path, + "records", sizeof(g_defaults.dirs[DEFAULT_DIR_RECORD_OUTPUT])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CURSOR], base_path, + "database/cursors", sizeof(g_defaults.dirs[DEFAULT_DIR_CURSOR])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], base_path, + "database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], base_path, + "shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], base_path, + "cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], base_path, + "overlay", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY])); +#ifdef HAVE_VIDEO_LAYOUT + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_LAYOUT], base_path, + "layouts", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_LAYOUT])); +#endif + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], base_path, + "download", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], base_path, + "scrnshot", sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS], base_path, + "thumbs", sizeof(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_LOGS], base_path, + "logs", sizeof(g_defaults.dirs[DEFAULT_DIR_LOGS])); + + for (i = 0; i < DEFAULT_DIR_LAST; i++) + { + const char *dir_path = g_defaults.dirs[i]; + if (!string_is_empty(dir_path)) + path_mkdir(dir_path); + } } frontend_ctx_driver_t frontend_ctx_dos = { - frontend_dos_get_env_settings,/* environment_get */ - frontend_dos_init, /* init */ - NULL, /* deinit */ - NULL, /* exitspawn */ - NULL, /* process_args */ - NULL, /* exec */ - NULL, /* set_fork */ - frontend_dos_shutdown, /* shutdown */ - NULL, /* get_name */ - NULL, /* get_os */ - frontend_dos_get_rating, /* get_rating */ - NULL, /* load_content */ - frontend_dos_get_architecture,/* get_architecture */ - NULL, /* get_powerstate */ - NULL, /* parse_drive_list */ - NULL, /* get_mem_total */ - NULL, /* get_mem_free */ - NULL, /* install_signal_handler */ - NULL, /* get_sighandler_state */ - NULL, /* set_sighandler_state */ - NULL, /* destroy_sighandler_state */ - NULL, /* attach_console */ - NULL, /* detach_console */ - NULL, /* watch_path_for_changes */ - NULL, /* check_for_path_changes */ - NULL, /* set_sustained_performance_mode */ - NULL, /* get_cpu_model_name */ - NULL, /* get_user_language */ - NULL, /* is_narrator_running */ - NULL, /* accessibility_speak */ - "dos", + frontend_dos_get_env_settings,/* environment_get */ + frontend_dos_init, /* init */ + NULL, /* deinit */ + NULL, /* exitspawn */ + NULL, /* process_args */ + NULL, /* exec */ + NULL, /* set_fork */ + frontend_dos_shutdown, /* shutdown */ + NULL, /* get_name */ + NULL, /* get_os */ + frontend_dos_get_rating, /* get_rating */ + NULL, /* load_content */ + frontend_dos_get_architecture,/* get_architecture */ + NULL, /* get_powerstate */ + NULL, /* parse_drive_list */ + NULL, /* get_mem_total */ + NULL, /* get_mem_free */ + NULL, /* install_signal_handler */ + NULL, /* get_sighandler_state */ + NULL, /* set_sighandler_state */ + NULL, /* destroy_sighandler_state */ + NULL, /* attach_console */ + NULL, /* detach_console */ + NULL, /* watch_path_for_changes */ + NULL, /* check_for_path_changes */ + NULL, /* set_sustained_performance_mode */ + NULL, /* get_cpu_model_name */ + NULL, /* get_user_language */ + NULL, /* is_narrator_running */ + NULL, /* accessibility_speak */ + "dos", }; diff --git a/gfx/drivers/vga_gfx.c b/gfx/drivers/vga_gfx.c index f59fe49e54..548d733dfd 100644 --- a/gfx/drivers/vga_gfx.c +++ b/gfx/drivers/vga_gfx.c @@ -33,7 +33,7 @@ static void vga_set_mode_13h(void) { - __dpmi_regs r; + __dpmi_regs r = {0}; r.x.ax = 0x13; __dpmi_int(0x10, &r); @@ -41,7 +41,7 @@ static void vga_set_mode_13h(void) static void vga_return_to_text_mode(void) { - __dpmi_regs r; + __dpmi_regs r = {0}; r.x.ax = 3; __dpmi_int(0x10, &r); diff --git a/libretro-common/include/retro_timers.h b/libretro-common/include/retro_timers.h index f82b9b352b..0e6dd923e7 100644 --- a/libretro-common/include/retro_timers.h +++ b/libretro-common/include/retro_timers.h @@ -68,7 +68,7 @@ extern int nanosleep(const struct timespec *rqtp, struct timespec *rmtp); static int nanosleepDOS(const struct timespec *rqtp, struct timespec *rmtp) { - usleep(1000000 * rqtp->tv_sec + rqtp->tv_nsec / 1000); + usleep(1000000L * rqtp->tv_sec + rqtp->tv_nsec / 1000); if (rmtp) rmtp->tv_sec = rmtp->tv_nsec=0; From 306fed32f6ea4d765c8d7a193384081ed193a63e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 12 May 2020 01:32:15 +0200 Subject: [PATCH 055/192] Fix djgpp clock --- libretro-common/features/features_cpu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index e0ab09682e..98fc1de570 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -247,9 +247,9 @@ retro_time_t cpu_features_get_time_usec(void) return tv.tv_sec * INT64_C(1000000) + (tv.tv_nsec + 500) / 1000; #elif defined(EMSCRIPTEN) return emscripten_get_now() * 1000; -#elif defined(PS2) - return clock()*1000; -#elif defined(__mips__) || defined(DJGPP) +#elif defined(PS2) || defined(DJGPP) + return clock()*(1000000LL/CLOCKS_PER_SEC); +#elif defined(__mips__) struct timeval tv; gettimeofday(&tv,NULL); return (1000000 * tv.tv_sec + tv.tv_usec); From 05500c6c39376201c46087ffca63a02e3f4ce22c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 12 May 2020 02:06:33 +0200 Subject: [PATCH 056/192] dos: Add 32-bit gfx support --- gfx/drivers/vga_gfx.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/gfx/drivers/vga_gfx.c b/gfx/drivers/vga_gfx.c index 548d733dfd..bbd58b4a4a 100644 --- a/gfx/drivers/vga_gfx.c +++ b/gfx/drivers/vga_gfx.c @@ -197,7 +197,26 @@ static bool vga_gfx_frame(void *data, const void *frame, { if (bits == 32) { - /* TODO/FIXME - needs to be implemented */ + unsigned x, y; + for (y = 0; y < VGA_HEIGHT; y++) + { + for (x = 0; x < VGA_WIDTH; x++) + { + /* scale incoming frame to fit the screen */ + unsigned scaled_x = (width * x) / VGA_WIDTH; + unsigned scaled_y = (height * y) / VGA_HEIGHT; + uint32_t pixel = ((uint32_t*)frame_to_copy)[width * scaled_y + scaled_x]; + + /* convert RGB888 to BGR332 */ + unsigned r = ((pixel & 0xFF0000) >> 21); + unsigned g = ((pixel & 0x00FF00) >> 13); + unsigned b = ((pixel & 0x0000FF) >> 6); + + vga->vga_frame[VGA_WIDTH * y + x] = (b << 6) | (g << 3) | r; + } + } + + dosmemput(vga->vga_frame, VGA_WIDTH*VGA_HEIGHT, 0xA0000); } else if (bits == 16) { From 6d184abf8495f453a64438a65d9ca9bc551bd77c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 12 May 2020 03:20:53 +0200 Subject: [PATCH 057/192] Fix dist-cores.sh for dos --- dist-scripts/dist-cores.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dist-scripts/dist-cores.sh b/dist-scripts/dist-cores.sh index 4001d0b530..cc7ad5107a 100755 --- a/dist-scripts/dist-cores.sh +++ b/dist-scripts/dist-cores.sh @@ -307,7 +307,8 @@ for f in `ls -v *_${platform}.${EXT}`; do elif [ $PLATFORM = "wii" ] ; then mv -f ../retroarch_${platform}.dol ../pkg/${platform}/${name}_libretro_${platform}.dol elif [ $PLATFORM = "dos" ] ; then - mv -f ../retroarch_${platform}.exe ../pkg/${platform}/${name}_libretro_${platform}.exe + mkdir -p ../pkg/${platform} + mv -f ../retrodos.exe ../pkg/${platform}/${name}_libretro_${platform}.exe elif [ $PLATFORM = "emscripten" ] ; then mkdir -p ../pkg/emscripten/ mv -f ../${name}_libretro.js ../pkg/emscripten/${name}_libretro.js From 1fabb661a68ff3863de0fa08eb746c4976c91755 Mon Sep 17 00:00:00 2001 From: Autechre Date: Tue, 12 May 2020 06:27:18 +0200 Subject: [PATCH 058/192] Update CHANGES.md --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 3b397b42fd..61f1acd167 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,7 @@ # Future +- 3DS: Add IDs for Frodo - 3DS: Enable basic networking / cheevos +- CHEEVOS/BUGFIX: Opening achievements list would crash RetroArch with badges enabled (on new games) - GLCORE: Switch to glcore video driver when requested by a core - LINUX/XDG: Use GenericName correctly in desktop entry - MAC/COCOA: Fix mouse cursor tracking From e8d2ea7a56c7e0160df2c9719729ed5343964b16 Mon Sep 17 00:00:00 2001 From: Autechre Date: Tue, 12 May 2020 06:27:57 +0200 Subject: [PATCH 059/192] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 61f1acd167..a7b94f8233 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ - 3DS: Add IDs for Frodo - 3DS: Enable basic networking / cheevos - CHEEVOS/BUGFIX: Opening achievements list would crash RetroArch with badges enabled (on new games) +- DOS/DJGPP: Add 32bit color support for cores - GLCORE: Switch to glcore video driver when requested by a core - LINUX/XDG: Use GenericName correctly in desktop entry - MAC/COCOA: Fix mouse cursor tracking From 3981b1cc82c90805726594c86d7a17fab2f41913 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 12 May 2020 08:02:55 +0200 Subject: [PATCH 060/192] (Qt) Cleanups --- ui/drivers/qt/ui_qt_load_core_window.cpp | 18 ++++++++---------- ui/drivers/qt/ui_qt_window.cpp | 21 +++++---------------- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/ui/drivers/qt/ui_qt_load_core_window.cpp b/ui/drivers/qt/ui_qt_load_core_window.cpp index a728bdead2..53c7b26147 100644 --- a/ui/drivers/qt/ui_qt_load_core_window.cpp +++ b/ui/drivers/qt/ui_qt_load_core_window.cpp @@ -41,7 +41,7 @@ extern "C" { } #endif -#define CORE_NAME_COLUMN 0 +#define CORE_NAME_COLUMN 0 #define CORE_VERSION_COLUMN 1 LoadCoreTableWidget::LoadCoreTableWidget(QWidget *parent) : @@ -150,18 +150,16 @@ void LoadCoreWindow::loadCore(const char *path) void LoadCoreWindow::onCoreEnterPressed() { - QTableWidgetItem *selectedCoreItem = NULL; - QString path; QByteArray pathArray; - const char *pathData = NULL; - QVariantHash hash; - - selectedCoreItem = m_table->item(m_table->currentRow(), CORE_NAME_COLUMN); - hash = selectedCoreItem->data(Qt::UserRole).toHash(); - path = hash["path"].toString(); + const char *pathData = NULL; + QTableWidgetItem *selectedCoreItem = + m_table->item(m_table->currentRow(), CORE_NAME_COLUMN); + QVariantHash hash = selectedCoreItem->data( + Qt::UserRole).toHash(); + QString path = hash["path"].toString(); pathArray.append(path); - pathData = pathArray.constData(); + pathData = pathArray.constData(); loadCore(pathData); } diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 124ea19d0c..9b97768b71 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -151,13 +151,11 @@ static void scan_finished_handler(retro_task_t *task, /* https://stackoverflow.com/questions/7246622/how-to-create-a-slider-with-a-non-linear-scale */ static double expScale(double inputValue, double midValue, double maxValue) { - double returnValue = 0; - double M = maxValue / midValue; - double C = log(pow(M - 1, 2)); - double B = maxValue / (exp(C) - 1); - double A = -1 * B; - - returnValue = A + B * exp(C * inputValue); + double M = maxValue / midValue; + double C = log(pow(M - 1, 2)); + double B = maxValue / (exp(C) - 1); + double A = -1 * B; + double returnValue = A + B * exp(C * inputValue); return returnValue; } @@ -2891,15 +2889,6 @@ void MainWindow::updateItemsCount() void MainWindow::keyPressEvent(QKeyEvent *event) { -#if 0 - if (event->key() == Qt::Key_F5) - { - event->accept(); - hide(); - - return; - } -#endif QMainWindow::keyPressEvent(event); } From 84369cf6ba322bbb2c391447da74b827cee1d8e8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 12 May 2020 08:49:41 +0200 Subject: [PATCH 061/192] (Win32) Cleanups --- gfx/display_servers/dispserv_win32.c | 72 +++++++++++++++------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/gfx/display_servers/dispserv_win32.c b/gfx/display_servers/dispserv_win32.c index 4bd4cf5ec6..4816923680 100644 --- a/gfx/display_servers/dispserv_win32.c +++ b/gfx/display_servers/dispserv_win32.c @@ -43,24 +43,27 @@ #ifdef __ITaskbarList3_INTERFACE_DEFINED__ #define HAS_TASKBAR_EXT -static ITaskbarList3 *g_taskbarList = NULL; - /* MSVC really doesn't want CINTERFACE to be used with shobjidl for some reason, but since we use C++ mode, * we need a workaround... so use the names of the COBJMACROS functions instead. */ #if defined(__cplusplus) && !defined(CINTERFACE) -#define ITaskbarList3_HrInit(x) g_taskbarList->HrInit() -#define ITaskbarList3_Release(x) g_taskbarList->Release() -#define ITaskbarList3_SetProgressState(a, b, c) g_taskbarList->SetProgressState(b, c) -#define ITaskbarList3_SetProgressValue(a, b, c, d) g_taskbarList->SetProgressValue(b, c, d) +#define ITaskbarList3_HrInit(x) (x)->HrInit() +#define ITaskbarList3_Release(x) (x)->Release() +#define ITaskbarList3_SetProgressState(a, b, c) (a)->SetProgressState(b, c) +#define ITaskbarList3_SetProgressValue(a, b, c, d) (a)->SetProgressValue(b, c, d) #endif #endif typedef struct { - unsigned opacity; - int progress; bool decorations; + int progress; + int crt_center; + unsigned opacity; + unsigned orig_width; + unsigned orig_height; + unsigned orig_refresh; + ITaskbarList3 *taskbar_list; } dispserv_win32_t; /* @@ -71,12 +74,7 @@ typedef struct be received by your application before it calls any ITaskbarList3 method. */ -static unsigned win32_orig_width = 0; -static unsigned win32_orig_height = 0; -static unsigned win32_orig_refresh = 0; -static int crt_center = 0; - -static void* win32_display_server_init(void) +static void *win32_display_server_init(void) { HRESULT hr; dispserv_win32_t *dispserv = (dispserv_win32_t*)calloc(1, sizeof(*dispserv)); @@ -90,23 +88,25 @@ static void* win32_display_server_init(void) #ifdef __cplusplus /* When compiling in C++ mode, GUIDs are references instead of pointers */ hr = CoCreateInstance(CLSID_TaskbarList, NULL, - CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (void**)&g_taskbarList); + CLSCTX_INPROC_SERVER, IID_ITaskbarList3, + (void**)&dispserv->taskbar_list); #else /* Mingw GUIDs are pointers instead of references since we're in C mode */ hr = CoCreateInstance(&CLSID_TaskbarList, NULL, - CLSCTX_INPROC_SERVER, &IID_ITaskbarList3, (void**)&g_taskbarList); + CLSCTX_INPROC_SERVER, &IID_ITaskbarList3, + (void**)&dispserv->taskbar_list); #endif if (SUCCEEDED(hr)) { - hr = ITaskbarList3_HrInit(g_taskbarList); + hr = ITaskbarList3_HrInit(dispserv->taskbar_list); if (!SUCCEEDED(hr)) RARCH_ERR("[dispserv]: HrInit of ITaskbarList3 failed.\n"); } else { - g_taskbarList = NULL; + dispserv->taskbar_list = NULL; RARCH_ERR("[dispserv]: CoCreateInstance of ITaskbarList3 failed.\n"); } #endif @@ -118,15 +118,19 @@ static void win32_display_server_destroy(void *data) { dispserv_win32_t *dispserv = (dispserv_win32_t*)data; - if (win32_orig_width > 0 && win32_orig_height > 0) - video_display_server_set_resolution(win32_orig_width, win32_orig_height, - win32_orig_refresh, (float)win32_orig_refresh, crt_center, 0, 0); + if (dispserv->orig_width > 0 && dispserv->orig_height > 0) + video_display_server_set_resolution( + dispserv->orig_width, + dispserv->orig_height, + dispserv->orig_refresh, + (float)dispserv->orig_refresh, + dispserv->crt_center, 0, 0); #ifdef HAS_TASKBAR_EXT - if (g_taskbarList) + if (dispserv->taskbar_list) { - ITaskbarList3_Release(g_taskbarList); - g_taskbarList = NULL; + ITaskbarList3_Release(dispserv->taskbar_list); + dispserv->taskbar_list = NULL; } #endif @@ -170,29 +174,29 @@ static bool win32_display_server_set_window_progress(void *data, int progress, b serv->progress = progress; #ifdef HAS_TASKBAR_EXT - if (!g_taskbarList || !win32_taskbar_is_created()) + if (!serv->taskbar_list || !win32_taskbar_is_created()) return false; if (progress == -1) { if (ITaskbarList3_SetProgressState( - g_taskbarList, hwnd, TBPF_INDETERMINATE) != S_OK) + serv->taskbar_list, hwnd, TBPF_INDETERMINATE) != S_OK) return false; } else if (finished) { if (ITaskbarList3_SetProgressState( - g_taskbarList, hwnd, TBPF_NOPROGRESS) != S_OK) + serv->taskbar_list, hwnd, TBPF_NOPROGRESS) != S_OK) return false; } else if (progress >= 0) { if (ITaskbarList3_SetProgressState( - g_taskbarList, hwnd, TBPF_NORMAL) != S_OK) + serv->taskbar_list, hwnd, TBPF_NORMAL) != S_OK) return false; if (ITaskbarList3_SetProgressValue( - g_taskbarList, hwnd, progress, 100) != S_OK) + serv->taskbar_list, hwnd, progress, 100) != S_OK) return false; } #endif @@ -227,11 +231,11 @@ static bool win32_display_server_set_resolution(void *data, win32_get_video_output(&curDevmode, -1, sizeof(curDevmode)); - if (win32_orig_width == 0) - win32_orig_width = GetSystemMetrics(SM_CXSCREEN); - win32_orig_refresh = curDevmode.dmDisplayFrequency; - if (win32_orig_height == 0) - win32_orig_height = GetSystemMetrics(SM_CYSCREEN); + if (serv->orig_width == 0) + serv->orig_width = GetSystemMetrics(SM_CXSCREEN); + serv->orig_refresh = curDevmode.dmDisplayFrequency; + if (serv->orig_height == 0) + serv->orig_height = GetSystemMetrics(SM_CYSCREEN); /* Used to stop super resolution bug */ if (width == curDevmode.dmPelsWidth) From 57bbf7c944adabecf7678a4933b753f2b0ac1ac5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 12 May 2020 08:56:57 +0200 Subject: [PATCH 062/192] (gfx widgets) Rearrange variables --- gfx/gfx_widgets.c | 137 +++++++++++++++++++++++----------------------- 1 file changed, 69 insertions(+), 68 deletions(-) diff --git a/gfx/gfx_widgets.c b/gfx/gfx_widgets.c index 9a52a89c39..53219d776c 100644 --- a/gfx/gfx_widgets.c +++ b/gfx/gfx_widgets.c @@ -47,20 +47,9 @@ #include "../cheevos-new/badges.h" #endif -static bool widgets_inited = false; -static bool widgets_active = false; - -bool gfx_widgets_active(void) -{ - return widgets_active; -} - -static bool widgets_persisting = false; - -void gfx_widgets_set_persistence(bool persist) -{ - widgets_persisting = persist; -} +static bool widgets_inited = false; +static bool widgets_active = false; +static bool widgets_persisting = false; static float msg_queue_background[16] = COLOR_HEX_TO_FLOAT(0x3A3A3A, 1.0f); static float msg_queue_info[16] = COLOR_HEX_TO_FLOAT(0x12ACF8, 1.0f); @@ -74,6 +63,14 @@ static float color_task_progress_bar[16] = COLOR_HEX_TO_FLOAT(0x22B14C, 1.0f); static uint64_t gfx_widgets_frame_count = 0; +static float gfx_widgets_pure_white[16] = { + 1.00, 1.00, 1.00, 1.00, + 1.00, 1.00, 1.00, 1.00, + 1.00, 1.00, 1.00, 1.00, + 1.00, 1.00, 1.00, 1.00, +}; + + /* Font data */ typedef struct { @@ -84,33 +81,6 @@ typedef struct static gfx_widget_fonts_t gfx_widget_fonts; -gfx_widget_font_data_t* gfx_widgets_get_font_regular(void) -{ - return &gfx_widget_fonts.regular; -} - -gfx_widget_font_data_t* gfx_widgets_get_font_bold(void) -{ - return &gfx_widget_fonts.bold; -} - -gfx_widget_font_data_t* gfx_widgets_get_font_msg_queue(void) -{ - return &gfx_widget_fonts.msg_queue; -} - -static float gfx_widgets_pure_white[16] = { - 1.00, 1.00, 1.00, 1.00, - 1.00, 1.00, 1.00, 1.00, - 1.00, 1.00, 1.00, 1.00, - 1.00, 1.00, 1.00, 1.00, -}; - -float* gfx_widgets_get_pure_white(void) -{ - return gfx_widgets_pure_white; -} - /* FPS */ static char gfx_widgets_fps_text[255] = {0}; @@ -172,11 +142,6 @@ static float gfx_widgets_backdrop_orig[16] = { 0.00, 0.00, 0.00, 0.75, }; -float* gfx_widgets_get_backdrop_orig(void) -{ - return gfx_widgets_backdrop_orig; -} - static float gfx_widgets_backdrop[16] = { 0.00, 0.00, 0.00, 0.75, 0.00, 0.00, 0.00, 0.75, @@ -184,8 +149,6 @@ static float gfx_widgets_backdrop[16] = { 0.00, 0.00, 0.00, 0.75, }; -/* Messages queue */ - typedef struct menu_widget_msg { char *msg; @@ -243,11 +206,6 @@ static bool msg_queue_has_icons = false; static gfx_animation_ctx_tag gfx_widgets_generic_tag = (uintptr_t)&widgets_active; -gfx_animation_ctx_tag gfx_widgets_get_generic_tag(void) -{ - return gfx_widgets_generic_tag; -} - /* There can only be one message animation at a time to * avoid confusing users */ static bool widgets_moving = false; @@ -304,16 +262,6 @@ static float last_scale_factor = 0.0f; static unsigned simple_widget_padding = 0; static unsigned simple_widget_height = 0; -unsigned gfx_widgets_get_padding(void) -{ - return simple_widget_padding; -} - -unsigned gfx_widgets_get_height(void) -{ - return simple_widget_height; -} - static unsigned msg_queue_height; static unsigned msg_queue_icon_size_x; static unsigned msg_queue_icon_size_y; @@ -334,16 +282,69 @@ static unsigned msg_queue_task_hourglass_x; /* Used for both generic and libretro messages */ static unsigned generic_message_height; -unsigned gfx_widgets_get_generic_message_height(void) -{ - return generic_message_height; -} - static unsigned divider_width_1px = 1; static unsigned last_video_width = 0; static unsigned last_video_height = 0; +bool gfx_widgets_active(void) +{ + return widgets_active; +} + +void gfx_widgets_set_persistence(bool persist) +{ + widgets_persisting = persist; +} + +gfx_widget_font_data_t* gfx_widgets_get_font_regular(void) +{ + return &gfx_widget_fonts.regular; +} + +gfx_widget_font_data_t* gfx_widgets_get_font_bold(void) +{ + return &gfx_widget_fonts.bold; +} + +gfx_widget_font_data_t* gfx_widgets_get_font_msg_queue(void) +{ + return &gfx_widget_fonts.msg_queue; +} + +float* gfx_widgets_get_pure_white(void) +{ + return gfx_widgets_pure_white; +} + +float* gfx_widgets_get_backdrop_orig(void) +{ + return gfx_widgets_backdrop_orig; +} + +/* Messages queue */ + +gfx_animation_ctx_tag gfx_widgets_get_generic_tag(void) +{ + return gfx_widgets_generic_tag; +} + +unsigned gfx_widgets_get_padding(void) +{ + return simple_widget_padding; +} + +unsigned gfx_widgets_get_height(void) +{ + return simple_widget_height; +} + + +unsigned gfx_widgets_get_generic_message_height(void) +{ + return generic_message_height; +} + unsigned gfx_widgets_get_last_video_width(void) { return last_video_width; From 86b78e2fea0e0a199ed4557a059681266bb1a993 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 12 May 2020 09:11:18 +0200 Subject: [PATCH 063/192] Cleanups --- verbosity.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/verbosity.c b/verbosity.c index cb71e414e4..4df51b2037 100644 --- a/verbosity.c +++ b/verbosity.c @@ -88,7 +88,7 @@ static bool log_file_override_active = false; static char log_file_override_path[PATH_MAX_LENGTH] = {0}; #ifdef HAVE_LIBNX -static Mutex logging_mtx; +static Mutex log_mutex; #ifdef NXLINK /* TODO/FIXME - global referenced in platform_switch.c - not @@ -142,7 +142,7 @@ void retro_main_log_file_init(const char *path, bool append) return; #ifdef HAVE_LIBNX - mutexInit(&logging_mtx); + mutexInit(&log_mutex); #endif log_file_fp = stderr; @@ -275,7 +275,7 @@ void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap) #endif #else #if defined(HAVE_LIBNX) - mutexLock(&logging_mtx); + mutexLock(&log_mutex); #endif if (fp) { @@ -284,7 +284,7 @@ void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap) fflush(fp); } #if defined(HAVE_LIBNX) - mutexUnlock(&logging_mtx); + mutexUnlock(&log_mutex); #endif #endif From cc50eaa88f807bdd9988e100b413e73ff68717a4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 12 May 2020 14:02:10 +0200 Subject: [PATCH 064/192] Cleanup --- menu/widgets/menu_input_bind_dialog.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/menu/widgets/menu_input_bind_dialog.c b/menu/widgets/menu_input_bind_dialog.c index 39619d2ffe..110ca1cb93 100644 --- a/menu/widgets/menu_input_bind_dialog.c +++ b/menu/widgets/menu_input_bind_dialog.c @@ -21,9 +21,6 @@ #include "menu_input_bind_dialog.h" #include "../menu_driver.h" -#include "../menu_input.h" - -#include "../../input/input_driver.h" #include "../../configuration.h" #include "../../performance_counters.h" From 9088137051478559579f38d5ceed550655eac077 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 12 May 2020 14:20:12 +0200 Subject: [PATCH 065/192] Remove unused function --- file_path_special.c | 50 --------------------------------------------- file_path_special.h | 18 ---------------- 2 files changed, 68 deletions(-) diff --git a/file_path_special.c b/file_path_special.c index 9841dd7743..29d811ff24 100644 --- a/file_path_special.c +++ b/file_path_special.c @@ -414,53 +414,3 @@ void fill_pathname_application_special(char *s, break; } } - -/** - * fill_short_pathname_representation: - * @out_rep : output representation - * @in_path : input path - * @size : size of output representation - * - * Generates a short representation of path. It should only - * be used for displaying the result; the output representation is not - * binding in any meaningful way (for a normal path, this is the same as basename) - * In case of more complex URLs, this should cut everything except for - * the main image file. - * - * E.g.: "/path/to/game.img" -> game.img - * "/path/to/myarchive.7z#folder/to/game.img" -> game.img - */ -void fill_short_pathname_representation_wrapper(char* out_rep, - const char *in_path, size_t size) -{ -#ifdef HAVE_COMPRESSION - char *path_short = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - char *last_slash = NULL; - - path_short[0] = '\0'; - - fill_pathname(path_short, path_basename(in_path), "", - PATH_MAX_LENGTH * sizeof(char) - ); - - last_slash = find_last_slash(path_short); - - if (last_slash != NULL) - { - /* We handle paths like: - * /path/to/file.7z#mygame.img - * short_name: mygame.img: - * - * We check whether something is actually - * after the hash to avoid going over the buffer. - */ - strlcpy(out_rep, last_slash + 1, size); - free(path_short); - return; - } - - free(path_short); -#endif - - fill_short_pathname_representation(out_rep, in_path, size); -} diff --git a/file_path_special.h b/file_path_special.h index 12e85bb806..9eb7f39d4b 100644 --- a/file_path_special.h +++ b/file_path_special.h @@ -117,24 +117,6 @@ enum application_special_type APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_DISCORD_AVATARS }; -/** - * fill_short_pathname_representation: - * @out_rep : output representation - * @in_path : input path - * @size : size of output representation - * - * Generates a short representation of path. It should only - * be used for displaying the result; the output representation is not - * binding in any meaningful way (for a normal path, this is the same as basename) - * In case of more complex URLs, this should cut everything except for - * the main image file. - * - * E.g.: "/path/to/game.img" -> game.img - * "/path/to/myarchive.7z#folder/to/game.img" -> game.img - */ -void fill_short_pathname_representation_wrapper(char* out_rep, - const char *in_path, size_t size); - const char *file_path_str(enum file_path_enum enum_idx); bool fill_pathname_application_data(char *s, size_t len); From bde18ba86a8e4d2ebfa3aca75c8d493afa637d13 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 12 May 2020 14:36:27 +0200 Subject: [PATCH 066/192] Style nits --- gfx/common/vulkan_common.c | 11 ++- gfx/common/win32_common.c | 183 ++++++++++++++++++++----------------- 2 files changed, 107 insertions(+), 87 deletions(-) diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index 169ef25bd1..d87dde5293 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -52,10 +52,13 @@ static VkDevice cached_device_vk; static retro_vulkan_destroy_device_t cached_destroy_device_vk; static struct string_list *vulkan_gpu_list = NULL; -//#define WSI_HARDENING_TEST +#if 0 +#define WSI_HARDENING_TEST +#endif + #ifdef WSI_HARDENING_TEST -static unsigned wsi_harden_counter = 0; -static unsigned wsi_harden_counter2 = 0; +static unsigned wsi_harden_counter = 0; +static unsigned wsi_harden_counter2 = 0; static void trigger_spurious_error_vkresult(VkResult *res) { @@ -1978,9 +1981,7 @@ bool vulkan_context_init(gfx_ctx_vulkan_data_t *vk, #else vulkan_library = dylib_load("libvulkan.so"); if (!vulkan_library) - { vulkan_library = dylib_load("libvulkan.so.1"); - } #endif } diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 83bf4e71cf..27af86d674 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -117,97 +117,114 @@ extern bool dinput_handle_message(void *dinput, UINT message, WPARAM wParam, LPARAM lParam); #endif -typedef struct DISPLAYCONFIG_RATIONAL_CUSTOM { - UINT32 Numerator; - UINT32 Denominator; +typedef struct DISPLAYCONFIG_RATIONAL_CUSTOM +{ + UINT32 Numerator; + UINT32 Denominator; } DISPLAYCONFIG_RATIONAL_CUSTOM; -typedef struct DISPLAYCONFIG_2DREGION_CUSTOM { - UINT32 cx; - UINT32 cy; +typedef struct DISPLAYCONFIG_2DREGION_CUSTOM +{ + UINT32 cx; + UINT32 cy; } DISPLAYCONFIG_2DREGION_CUSTOM; -typedef struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM { - UINT64 pixelRate; - DISPLAYCONFIG_RATIONAL_CUSTOM hSyncFreq; - DISPLAYCONFIG_RATIONAL_CUSTOM vSyncFreq; - DISPLAYCONFIG_2DREGION_CUSTOM activeSize; - DISPLAYCONFIG_2DREGION_CUSTOM totalSize; - union { - struct { - UINT32 videoStandard :16; - UINT32 vSyncFreqDivider :6; - UINT32 reserved :10; - } AdditionalSignalInfo; - UINT32 videoStandard; - } dummyunionname; - UINT32 scanLineOrdering; +typedef struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM +{ + UINT64 pixelRate; + DISPLAYCONFIG_RATIONAL_CUSTOM hSyncFreq; + DISPLAYCONFIG_RATIONAL_CUSTOM vSyncFreq; + DISPLAYCONFIG_2DREGION_CUSTOM activeSize; + DISPLAYCONFIG_2DREGION_CUSTOM totalSize; + union + { + struct + { + UINT32 videoStandard :16; + UINT32 vSyncFreqDivider :6; + UINT32 reserved :10; + } AdditionalSignalInfo; + UINT32 videoStandard; + } dummyunionname; + UINT32 scanLineOrdering; } DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM; -typedef struct DISPLAYCONFIG_TARGET_MODE_CUSTOM { - DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM targetVideoSignalInfo; +typedef struct DISPLAYCONFIG_TARGET_MODE_CUSTOM +{ + DISPLAYCONFIG_VIDEO_SIGNAL_INFO_CUSTOM targetVideoSignalInfo; } DISPLAYCONFIG_TARGET_MODE_CUSTOM; -typedef struct DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM { - LUID adapterId; - UINT32 id; - union { - UINT32 modeInfoIdx; - struct { - UINT32 cloneGroupId :16; - UINT32 sourceModeInfoIdx :16; - } dummystructname; - } dummyunionname; - UINT32 statusFlags; +typedef struct DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM +{ + LUID adapterId; + UINT32 id; + union + { + UINT32 modeInfoIdx; + struct + { + UINT32 cloneGroupId :16; + UINT32 sourceModeInfoIdx :16; + } dummystructname; + } dummyunionname; + UINT32 statusFlags; } DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM; -typedef struct DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM { - POINTL PathSourceSize; - RECTL DesktopImageRegion; - RECTL DesktopImageClip; +typedef struct DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM +{ + POINTL PathSourceSize; + RECTL DesktopImageRegion; + RECTL DesktopImageClip; } DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM; -typedef struct DISPLAYCONFIG_SOURCE_MODE_CUSTOM { - UINT32 width; - UINT32 height; - UINT32 pixelFormat; - POINTL position; +typedef struct DISPLAYCONFIG_SOURCE_MODE_CUSTOM +{ + UINT32 width; + UINT32 height; + UINT32 pixelFormat; + POINTL position; } DISPLAYCONFIG_SOURCE_MODE_CUSTOM; -typedef struct DISPLAYCONFIG_MODE_INFO_CUSTOM { - UINT32 infoType; - UINT32 id; - LUID adapterId; - union { - DISPLAYCONFIG_TARGET_MODE_CUSTOM targetMode; - DISPLAYCONFIG_SOURCE_MODE_CUSTOM sourceMode; - DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM desktopImageInfo; - } dummyunionname; +typedef struct DISPLAYCONFIG_MODE_INFO_CUSTOM +{ + UINT32 infoType; + UINT32 id; + LUID adapterId; + union + { + DISPLAYCONFIG_TARGET_MODE_CUSTOM targetMode; + DISPLAYCONFIG_SOURCE_MODE_CUSTOM sourceMode; + DISPLAYCONFIG_DESKTOP_IMAGE_INFO_CUSTOM desktopImageInfo; + } dummyunionname; } DISPLAYCONFIG_MODE_INFO_CUSTOM; -typedef struct DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM { - LUID adapterId; - UINT32 id; - union { - UINT32 modeInfoIdx; - struct { - UINT32 desktopModeInfoIdx :16; - UINT32 targetModeInfoIdx :16; - } dummystructname; - } dummyunionname; - UINT32 outputTechnology; - UINT32 rotation; - UINT32 scaling; - DISPLAYCONFIG_RATIONAL_CUSTOM refreshRate; - UINT32 scanLineOrdering; - BOOL targetAvailable; - UINT32 statusFlags; +typedef struct DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM +{ + LUID adapterId; + UINT32 id; + union + { + UINT32 modeInfoIdx; + struct + { + UINT32 desktopModeInfoIdx :16; + UINT32 targetModeInfoIdx :16; + } dummystructname; + } dummyunionname; + UINT32 outputTechnology; + UINT32 rotation; + UINT32 scaling; + DISPLAYCONFIG_RATIONAL_CUSTOM refreshRate; + UINT32 scanLineOrdering; + BOOL targetAvailable; + UINT32 statusFlags; } DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM; -typedef struct DISPLAYCONFIG_PATH_INFO_CUSTOM { - DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM sourceInfo; - DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM targetInfo; - UINT32 flags; +typedef struct DISPLAYCONFIG_PATH_INFO_CUSTOM +{ + DISPLAYCONFIG_PATH_SOURCE_INFO_CUSTOM sourceInfo; + DISPLAYCONFIG_PATH_TARGET_INFO_CUSTOM targetInfo; + UINT32 flags; } DISPLAYCONFIG_PATH_INFO_CUSTOM; typedef LONG (WINAPI *QUERYDISPLAYCONFIG)(UINT32, UINT32*, DISPLAYCONFIG_PATH_INFO_CUSTOM*, UINT32*, DISPLAYCONFIG_MODE_INFO_CUSTOM*, UINT32*); @@ -301,9 +318,9 @@ bool win32_taskbar_is_created(void) return taskbar_is_created; } -static INT_PTR_COMPAT CALLBACK PickCoreProc( +static INT_PTR_COMPAT CALLBACK pick_core_proc( HWND hDlg, UINT message, - WPARAM wParam, LPARAM lParam) + WPARAM wParam, LPARAM lParam) { size_t list_size; core_info_list_t *core_info_list = NULL; @@ -528,7 +545,7 @@ bool win32_load_content_from_gui(const char *szFilename) /* Pick one core that could be compatible, ew */ if (DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_PICKCORE), - main_window.hwnd, PickCoreProc, (LPARAM)NULL) == IDOK) + main_window.hwnd, pick_core_proc, (LPARAM)NULL) == IDOK) { task_push_load_content_with_current_core_from_companion_ui( NULL, &content_info, CORE_TYPE_PLAIN, NULL, NULL); @@ -822,7 +839,8 @@ static LRESULT win32_menu_loop(HWND owner, WPARAM wparam) return 0L; } -static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message, +static LRESULT CALLBACK wnd_proc_common( + bool *quit, HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { bool keydown = true; @@ -1028,7 +1046,7 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message, case WM_MOVE: case WM_SIZE: case WM_COMMAND: - ret = WndProcCommon(&quit, hwnd, message, wparam, lparam); + ret = wnd_proc_common(&quit, hwnd, message, wparam, lparam); if (quit) return ret; #if _WIN32_WINNT >= 0x0500 /* 2K */ @@ -1092,8 +1110,7 @@ LRESULT CALLBACK WndProcWGL(HWND hwnd, UINT message, case WM_MOVE: case WM_SIZE: case WM_COMMAND: - ret = WndProcCommon(&quit, - hwnd, message, wparam, lparam); + ret = wnd_proc_common(&quit, hwnd, message, wparam, lparam); if (quit) return ret; #if _WIN32_WINNT >= 0x0500 /* 2K */ @@ -1195,7 +1212,7 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message, case WM_MOVE: case WM_SIZE: case WM_COMMAND: - ret = WndProcCommon(&quit, hwnd, message, wparam, lparam); + ret = wnd_proc_common(&quit, hwnd, message, wparam, lparam); if (quit) return ret; #if _WIN32_WINNT >= 0x0500 /* 2K */ @@ -1856,7 +1873,9 @@ bool win32_get_video_output(DEVMODE *dm, int mode, size_t len) memset(dm, 0, len); dm->dmSize = len; - if (win32_internal_get_video_output((mode == -1) ? ENUM_CURRENT_SETTINGS : mode, + if (win32_internal_get_video_output((mode == -1) + ? ENUM_CURRENT_SETTINGS + : mode, dm) == 0) return false; return true; From 1d1c7e5a0d7a8025971795a168d5b14dbbf7bac3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 12 May 2020 15:10:15 +0200 Subject: [PATCH 067/192] (PSL1GHT/GCM) Style nits --- gfx/drivers/gcm_gfx.c | 457 ++++++++++++++++++++++-------------------- 1 file changed, 235 insertions(+), 222 deletions(-) diff --git a/gfx/drivers/gcm_gfx.c b/gfx/drivers/gcm_gfx.c index ba16247c79..6b58243dc9 100644 --- a/gfx/drivers/gcm_gfx.c +++ b/gfx/drivers/gcm_gfx.c @@ -66,13 +66,12 @@ typedef struct { - - int height; - int width; - int id; - uint32_t *ptr; - // Internal stuff - uint32_t offset; + int height; + int width; + int id; + uint32_t *ptr; + /* Internal stuff */ + uint32_t offset; } rsxBuffer; typedef struct @@ -91,26 +90,25 @@ typedef struct typedef struct gcm_video { - video_viewport_t vp; - rsxBuffer buffers[MAX_BUFFERS]; - rsxBuffer menuBuffers[MAX_BUFFERS]; - int currentBuffer, menuBuffer; - gcmContextData *context; - u16 width; - u16 height; - bool menu_frame_enable; - bool rgb32; - bool vsync; - u32 depth_pitch; - u32 depth_offset; - u32 *depth_buffer; + video_viewport_t vp; + rsxBuffer buffers[MAX_BUFFERS]; + rsxBuffer menuBuffers[MAX_BUFFERS]; + int currentBuffer, menuBuffer; + gcmContextData *context; + u16 width; + u16 height; + bool menu_frame_enable; + bool rgb32; + bool vsync; + u32 depth_pitch; + u32 depth_offset; + u32 *depth_buffer; bool smooth; unsigned rotation; bool keep_aspect; bool should_resize; bool msg_rendering_enabled; - } gcm_video_t; #ifndef HAVE_THREADS @@ -121,136 +119,138 @@ static bool gcm_tasks_finder(retro_task_t *task,void *userdata) task_finder_data_t gcm_tasks_finder_data = {gcm_tasks_finder, NULL}; #endif -static int -makeBuffer (rsxBuffer * buffer, u16 width, u16 height, int id) +static int gcm_make_buffer(rsxBuffer * buffer, u16 width, u16 height, int id) { - int depth = sizeof(u32); - int pitch = depth * width; - int size = depth * width * height; + int depth = sizeof(u32); + int pitch = depth * width; + int size = depth * width * height; - buffer->ptr = (uint32_t*) rsxMemalign (64, size); - if (buffer->ptr == NULL) - goto error; + buffer->ptr = (uint32_t*)rsxMemalign (64, size); + if (!buffer->ptr) + goto error; - if (rsxAddressToOffset (buffer->ptr, &buffer->offset) != 0) - goto error; + if (rsxAddressToOffset (buffer->ptr, &buffer->offset) != 0) + goto error; - /* Register the display buffer with the RSX */ - if (gcmSetDisplayBuffer (id, buffer->offset, pitch, width, height) != 0) - goto error; + /* Register the display buffer with the RSX */ + if (gcmSetDisplayBuffer (id, buffer->offset, pitch, width, height) != 0) + goto error; - buffer->width = width; - buffer->height = height; - buffer->id = id; + buffer->width = width; + buffer->height = height; + buffer->id = id; - return TRUE; + return TRUE; - error: - if (buffer->ptr != NULL) - rsxFree (buffer->ptr); +error: + if (buffer->ptr) + rsxFree (buffer->ptr); - return FALSE; + return FALSE; } -static int -flip (gcmContextData *context, s32 buffer) +static int gcm_flip(gcmContextData *context, s32 buffer) { - if (gcmSetFlip (context, buffer) == 0) { - rsxFlushBuffer (context); - // Prevent the RSX from continuing until the flip has finished. - gcmSetWaitFlip (context); + if (gcmSetFlip(context, buffer) == 0) + { + rsxFlushBuffer (context); + /* Prevent the RSX from continuing until the flip has finished. */ + gcmSetWaitFlip (context); - return TRUE; - } - return FALSE; + return TRUE; + } + return FALSE; } #define GCM_LABEL_INDEX 255 -static void waitRSXIdle(gcmContextData *context); +static void gcm_wait_rsx_idle(gcmContextData *context); -static void -waitFlip () +static void gcm_wait_flip(void) { - while (gcmGetFlipStatus () != 0) + while (gcmGetFlipStatus() != 0) usleep (200); /* Sleep, to not stress the cpu. */ - gcmResetFlipStatus (); + gcmResetFlipStatus(); } -static gcmContextData * -initScreen (gcm_video_t* gcm) +static gcmContextData *gcm_init_screen(gcm_video_t* gcm) { - gcmContextData *context = NULL; /* Context to keep track of the RSX buffer. */ - static gcmContextData *saved_context = NULL; - videoState state; - videoConfiguration vconfig; - videoResolution res; /* Screen Resolution */ + /* Context to keep track of the RSX buffer. */ + gcmContextData *context = NULL; + static gcmContextData *saved_context = NULL; + videoState state; + videoConfiguration vconfig; + videoResolution res; /* Screen Resolution */ - if (!saved_context) { - /* Allocate a 1Mb buffer, alligned to a 1Mb boundary - * to be our shared IO memory with the RSX. */ - void *host_addr = memalign (1024*1024, HOST_SIZE); + if (!saved_context) + { + /* Allocate a 1Mb buffer, alligned to a 1Mb boundary + * to be our shared IO memory with the RSX. */ + void *host_addr = memalign (1024*1024, HOST_SIZE); - if (host_addr == NULL) + if (!host_addr) + goto error; + + /* Initialise Reality, which sets up the + * command buffer and shared I/O memory */ + context = rsxInit (CB_SIZE, HOST_SIZE, host_addr); + if (!context) + goto error; + saved_context = context; + } + else + context = saved_context; + + /* Get the state of the display */ + if (videoGetState (0, 0, &state) != 0) goto error; - /* Initilise Reality, which sets up the command buffer and shared IO memory */ - context = rsxInit (CB_SIZE, HOST_SIZE, host_addr); - if (context == NULL) + /* Make sure display is enabled */ + if (state.state != 0) goto error; - saved_context = context; - } else { - context = saved_context; - } - /* Get the state of the display */ - if (videoGetState (0, 0, &state) != 0) - goto error; + /* Get the current resolution */ + if (videoGetResolution (state.displayMode.resolution, &res) != 0) + goto error; - /* Make sure display is enabled */ - if (state.state != 0) - goto error; + /* Configure the buffer format to xRGB */ + memset (&vconfig, 0, sizeof(videoConfiguration)); + vconfig.resolution = state.displayMode.resolution; + vconfig.format = VIDEO_BUFFER_FORMAT_XRGB; + vconfig.pitch = res.width * sizeof(u32); + vconfig.aspect = state.displayMode.aspect; - /* Get the current resolution */ - if (videoGetResolution (state.displayMode.resolution, &res) != 0) - goto error; + gcm->width = res.width; + gcm->height = res.height; - /* Configure the buffer format to xRGB */ - memset (&vconfig, 0, sizeof(videoConfiguration)); - vconfig.resolution = state.displayMode.resolution; - vconfig.format = VIDEO_BUFFER_FORMAT_XRGB; - vconfig.pitch = res.width * sizeof(u32); - vconfig.aspect = state.displayMode.aspect; + gcm_wait_rsx_idle(context); - gcm->width = res.width; - gcm->height = res.height; + if (videoConfigure (0, &vconfig, NULL, 0) != 0) + goto error; - waitRSXIdle(context); + if (videoGetState (0, 0, &state) != 0) + goto error; - if (videoConfigure (0, &vconfig, NULL, 0) != 0) - goto error; + gcmSetFlipMode (GCM_FLIP_VSYNC); /* Wait for VSYNC to flip */ - if (videoGetState (0, 0, &state) != 0) - goto error; + gcm->depth_pitch = res.width * sizeof(u32); + gcm->depth_buffer = (u32 *) rsxMemalign (64, (res.height * gcm->depth_pitch)* 2); + rsxAddressToOffset (gcm->depth_buffer, &gcm->depth_offset); - gcmSetFlipMode (GCM_FLIP_VSYNC); // Wait for VSYNC to flip + gcmResetFlipStatus(); - gcm->depth_pitch = res.width * sizeof(u32); - gcm->depth_buffer = (u32 *) rsxMemalign (64, (res.height * gcm->depth_pitch)* 2); - rsxAddressToOffset (gcm->depth_buffer, &gcm->depth_offset); + return context; - gcmResetFlipStatus(); +error: +#if 0 + if (context) + rsxFinish (context, 0); - return context; + if (gcm->host_addr) + free (gcm->host_addr); +#endif - error: - // if (context) - // rsxFinish (context, 0); - - // if (gcm->host_addr) - // free (gcm->host_addr); - - return NULL; + return NULL; } @@ -267,8 +267,7 @@ waitFinish(gcmContextData *context, u32 sLabelVal) sLabelVal++; } -static void -waitRSXIdle(gcmContextData *context) +static void gcm_wait_rsx_idle(gcmContextData *context) { u32 sLabelVal = 1; @@ -283,7 +282,7 @@ waitRSXIdle(gcmContextData *context) static void* gcm_init(const video_info_t* video, input_driver_t** input, void** input_data) { - RARCH_LOG("Reached gcm_init\n"); + int i; gcm_video_t* gcm = malloc(sizeof(gcm_video_t)); if (!gcm) @@ -291,17 +290,15 @@ static void* gcm_init(const video_info_t* video, memset(gcm, 0, sizeof(gcm_video_t)); - int i; - - gcm->context = initScreen (gcm); + gcm->context = gcm_init_screen(gcm); for (i = 0; i < MAX_BUFFERS; i++) - makeBuffer( &gcm->buffers[i], gcm->width, gcm->height, i); + gcm_make_buffer(&gcm->buffers[i], gcm->width, gcm->height, i); for (i = 0; i < MAX_BUFFERS; i++) - makeBuffer( &gcm->menuBuffers[i], gcm->width, gcm->height, i + MAX_BUFFERS); + gcm_make_buffer(&gcm->menuBuffers[i], gcm->width, gcm->height, i + MAX_BUFFERS); - flip(gcm->context, MAX_BUFFERS - 1); + gcm_flip(gcm->context, MAX_BUFFERS - 1); gcm->vp.x = 0; gcm->vp.y = 0; @@ -318,41 +315,44 @@ static void* gcm_init(const video_info_t* video, *input = ps3input ? &input_ps3 : NULL; *input_data = ps3input; } - RARCH_LOG("gcm_init done\n"); return gcm; } -static void black (uint32_t *dst, uint32_t *dst_end, size_t sz) +static void gcm_fill_black(uint32_t *dst, uint32_t *dst_end, size_t sz) { if (sz > dst_end - dst) sz = dst_end - dst; memset (dst, 0, sz * 4); } -static void blitBuffer(rsxBuffer *buffer, const void *frame, unsigned width, - unsigned height, unsigned pitch, int rgb32, bool do_scaling) +static void gcm_blit_buffer( + rsxBuffer *buffer, const void *frame, unsigned width, + unsigned height, unsigned pitch, int rgb32, bool do_scaling) { - if (width > buffer->width) + int scale = 1, xofs = 0, yofs = 0; + if (width > buffer->width) width = buffer->width; if (height > buffer->height) height = buffer->height; - int scale = 1, xofs = 0, yofs = 0; - if (do_scaling) { - scale = buffer->width / width; - if (scale > buffer->height / height) - scale = buffer->height / height; - if (scale >= 10) - scale = 10; - if (scale >= 1) { - xofs = (buffer->width - width * scale) / 2; - yofs = (buffer->height - height * scale) / 2; - } else - scale = 1; + if (do_scaling) + { + scale = buffer->width / width; + if (scale > buffer->height / height) + scale = buffer->height / height; + if (scale >= 10) + scale = 10; + if (scale >= 1) + { + xofs = (buffer->width - width * scale) / 2; + yofs = (buffer->height - height * scale) / 2; + } + else + scale = 1; } - // TODO: let rsx do the copy + /* TODO: let rsx do the copy */ int i; int pre_clean = xofs + buffer->width * yofs; uint32_t *dst = buffer->ptr; @@ -361,83 +361,94 @@ static void blitBuffer(rsxBuffer *buffer, const void *frame, unsigned width, memset (dst, 0, pre_clean * 4); dst += pre_clean; - if (scale == 1) { - if (rgb32) { - const uint8_t *src = frame; - for (i = 0; i < height; i++) - { - memcpy(dst, src, width * 4); - black(dst + width, dst_end, buffer->width - width); - dst += buffer->width; - src += pitch; - } - } else { - const uint16_t *src = frame; - for (i = 0; i < height; i++) - { - for (int j = 0; j < width; j++, src++, dst++) { - u16 rgb565 = *src; - u8 r = ((rgb565 >> 8) & 0xf8); - u8 g = ((rgb565 >> 3) & 0xfc); - u8 b = ((rgb565 << 3) & 0xfc); - *dst = (r<<16) | (g<<8) | b; - } - black(dst, dst_end, buffer->width - width); + if (scale == 1) + { + if (rgb32) + { + const uint8_t *src = frame; + for (i = 0; i < height; i++) + { + memcpy(dst, src, width * 4); + gcm_fill_black(dst + width, dst_end, buffer->width - width); + dst += buffer->width; + src += pitch; + } + } + else + { + const uint16_t *src = frame; + for (i = 0; i < height; i++) + { + for (int j = 0; j < width; j++, src++, dst++) + { + u16 rgb565 = *src; + u8 r = ((rgb565 >> 8) & 0xf8); + u8 g = ((rgb565 >> 3) & 0xfc); + u8 b = ((rgb565 << 3) & 0xfc); + *dst = (r<<16) | (g<<8) | b; + } + gcm_fill_black(dst, dst_end, buffer->width - width); - dst += buffer->width - width; - src += pitch / 2 - width; - } - } - } else { - if (rgb32) { - const uint32_t *src = frame; - for (i = 0; i < height; i++) - { - for (int j = 0; j < width; j++, src++) { - u32 c = *src; - for (int k = 0; k < scale; k++, dst++) - for (int l = 0; l < scale; l++) - dst[l * buffer->width] = c; - } - for (int l = 0; l < scale; l++) - black(dst + l * buffer->width, dst_end, buffer->width - width * scale); + dst += buffer->width - width; + src += pitch / 2 - width; + } + } + } + else + { + if (rgb32) + { + const uint32_t *src = frame; + for (i = 0; i < height; i++) + { + for (int j = 0; j < width; j++, src++) + { + u32 c = *src; + for (int k = 0; k < scale; k++, dst++) + for (int l = 0; l < scale; l++) + dst[l * buffer->width] = c; + } + for (int l = 0; l < scale; l++) + gcm_fill_black(dst + l * buffer->width, dst_end, buffer->width - width * scale); - dst += buffer->width * scale - width * scale; - src += pitch / 4 - width; - } - } else { - const uint16_t *src = frame; - for (i = 0; i < height; i++) - { - for (int j = 0; j < width; j++, src++) { - u16 rgb565 = *src; - u8 r = ((rgb565 >> 8) & 0xf8); - u8 g = ((rgb565 >> 3) & 0xfc); - u8 b = ((rgb565 << 3) & 0xfc); - u32 c = (r<<16) | (g<<8) | b; - for (int k = 0; k < scale; k++, dst++) - for (int l = 0; l < scale; l++) - dst[l * buffer->width] = c; - } - for (int l = 0; l < scale; l++) - black(dst + l * buffer->width, dst_end, buffer->width - width * scale); + dst += buffer->width * scale - width * scale; + src += pitch / 4 - width; + } + } else { + const uint16_t *src = frame; + for (i = 0; i < height; i++) + { + for (int j = 0; j < width; j++, src++) + { + u16 rgb565 = *src; + u8 r = ((rgb565 >> 8) & 0xf8); + u8 g = ((rgb565 >> 3) & 0xfc); + u8 b = ((rgb565 << 3) & 0xfc); + u32 c = (r<<16) | (g<<8) | b; + for (int k = 0; k < scale; k++, dst++) + for (int l = 0; l < scale; l++) + dst[l * buffer->width] = c; + } + for (int l = 0; l < scale; l++) + gcm_fill_black(dst + l * buffer->width, dst_end, buffer->width - width * scale); - dst += buffer->width * scale - width * scale; - src += pitch / 2 - width; - } - } + dst += buffer->width * scale - width * scale; + src += pitch / 2 - width; + } + } } if (dst < dst_end) - memset(dst, 0, 4 * (dst_end - dst)); + memset(dst, 0, 4 * (dst_end - dst)); } -static void gcm_update_screen(gcm_video_t *gcm) { - rsxBuffer *buffer = gcm->menu_frame_enable - ? &gcm->menuBuffers[gcm->menuBuffer] - : &gcm->buffers[gcm->currentBuffer]; - flip(gcm->context, buffer->id); - if (gcm->vsync) - waitFlip(); +static void gcm_update_screen(gcm_video_t *gcm) +{ + rsxBuffer *buffer = gcm->menu_frame_enable + ? &gcm->menuBuffers[gcm->menuBuffer] + : &gcm->buffers[gcm->currentBuffer]; + gcm_flip(gcm->context, buffer->id); + if (gcm->vsync) + gcm_wait_flip(); #ifdef HAVE_SYSUTILS cellSysutilCheckCallback(); #endif @@ -452,14 +463,15 @@ static bool gcm_frame(void* data, const void* frame, if(frame && width && height) { - gcm->currentBuffer++; - if (gcm->currentBuffer >= MAX_BUFFERS) - gcm->currentBuffer = 0; - blitBuffer(&gcm->buffers[gcm->currentBuffer], frame, width, height, pitch, - gcm->rgb32, true); + gcm->currentBuffer++; + if (gcm->currentBuffer >= MAX_BUFFERS) + gcm->currentBuffer = 0; + gcm_blit_buffer( + &gcm->buffers[gcm->currentBuffer], frame, width, height, pitch, + gcm->rgb32, true); } - // TODO: translucid menu + /* TODO: translucid menu */ gcm_update_screen(gcm); return true; @@ -524,21 +536,23 @@ static void gcm_free(void* data) for (int i = 0; i < MAX_BUFFERS; i++) rsxFree(gcm->menuBuffers[i].ptr); - //rsxFinish(gcm->context, 1); - // free(gcm->host_addr); +#if 0 + rsxFinish(gcm->context, 1); + free(gcm->host_addr); +#endif free (gcm); } static void gcm_set_texture_frame(void* data, const void* frame, bool rgb32, - unsigned width, unsigned height, float alpha) + unsigned width, unsigned height, float alpha) { gcm_video_t* gcm = (gcm_video_t*)data; int newBuffer = gcm->menuBuffer + 1; if (newBuffer >= MAX_BUFFERS) newBuffer = 0; - // TODO: respect alpha - blitBuffer(&gcm->menuBuffers[newBuffer], frame, width, height, + /* TODO: respect alpha */ + gcm_blit_buffer(&gcm->menuBuffers[newBuffer], frame, width, height, width * (rgb32 ? 4 : 2), rgb32, true); gcm->menuBuffer = newBuffer; @@ -605,7 +619,6 @@ static void gcm_viewport_info(void* data, struct video_viewport* vp) *vp = gcm->vp; } - static void gcm_set_osd_msg(void *data, video_frame_info_t *video_info, const char *msg, @@ -649,14 +662,14 @@ static const video_poke_interface_t gcm_poke_interface = { }; static void gcm_get_poke_interface(void* data, - const video_poke_interface_t** iface) + const video_poke_interface_t** iface) { (void)data; *iface = &gcm_poke_interface; } static bool gcm_set_shader(void* data, - enum rarch_shader_type type, const char* path) + enum rarch_shader_type type, const char* path) { (void)data; (void)type; From 494c0f8fe485fe2bd6bdde53c2652bb3ff9c2907 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 12 May 2020 17:06:58 +0200 Subject: [PATCH 068/192] (PSL1GHT) Cleanups --- input/drivers/psl1ght_input.c | 305 ++++++++++++++++++---------------- 1 file changed, 166 insertions(+), 139 deletions(-) diff --git a/input/drivers/psl1ght_input.c b/input/drivers/psl1ght_input.c index 9e0f84585c..f4c532fb9a 100644 --- a/input/drivers/psl1ght_input.c +++ b/input/drivers/psl1ght_input.c @@ -60,20 +60,32 @@ typedef struct ps3_input int connected[MAX_KB_PORT_NUM]; } ps3_input_t; -static void connect_keyboard(ps3_input_t *ps3, int port) +static int mod_table[] = { + RETROK_RSUPER, + RETROK_RALT, + RETROK_RSHIFT, + RETROK_RCTRL, + RETROK_LSUPER, + RETROK_LALT, + RETROK_LSHIFT, + RETROK_LCTRL +}; + +static void ps3_connect_keyboard(ps3_input_t *ps3, int port) { - ioKbSetCodeType(port, KB_CODETYPE_RAW); - ioKbSetReadMode(port, KB_RMODE_INPUTCHAR); - ps3->connected[port] = 1; + ioKbSetCodeType(port, KB_CODETYPE_RAW); + ioKbSetReadMode(port, KB_RMODE_INPUTCHAR); + ps3->connected[port] = 1; } -static void disconnect_keyboard(ps3_input_t *ps3, int port) +static void ps3_disconnect_keyboard(ps3_input_t *ps3, int port) { - ps3->connected[port] = 0; + ps3->connected[port] = 0; } static void ps3_input_poll(void *data) { + unsigned i, j; ps3_input_t *ps3 = (ps3_input_t*)data; KbData last_kbdata[MAX_KB_PORT_NUM]; @@ -81,58 +93,70 @@ static void ps3_input_poll(void *data) ps3->joypad->poll(); ioKbGetInfo(&ps3->kbinfo); - for (int i = 0; i < MAX_KB_PORT_NUM; i++) { - if(ps3->kbinfo.status[i] && !ps3->connected[i]) - connect_keyboard(ps3, i); -// if(!ps3->kbinfo.status[i] && ps3->connected[i]) -// disconnect_keyboard(ps3, i); + for (i = 0; i < MAX_KB_PORT_NUM; i++) + { + if (ps3->kbinfo.status[i] && !ps3->connected[i]) + ps3_connect_keyboard(ps3, i); +#if 0 + if (!ps3->kbinfo.status[i] && ps3->connected[i]) + ps3_disconnect_keyboard(ps3, i); +#endif } memcpy(last_kbdata, ps3->kbdata, sizeof(last_kbdata)); - for (int i = 0; i < MAX_KB_PORT_NUM; i++) { - if(ps3->kbinfo.status[i]) - ioKbRead(i, &ps3->kbdata[i]); + for (i = 0; i < MAX_KB_PORT_NUM; i++) + { + if (ps3->kbinfo.status[i]) + ioKbRead(i, &ps3->kbdata[i]); } - for (int i = 0; i < MAX_KB_PORT_NUM; i++) { - /* Set keyboard modifier based on shift,ctrl and alt state */ - uint16_t mod = 0; + for (i = 0; i < MAX_KB_PORT_NUM; i++) + { + /* Set keyboard modifier based on shift,ctrl and alt state */ + uint16_t mod = 0; - if (ps3->kbdata[i].mkey._KbMkeyU._KbMkeyS.l_alt || ps3->kbdata[i].mkey._KbMkeyU._KbMkeyS.r_alt) - mod |= RETROKMOD_ALT; - if (ps3->kbdata[i].mkey._KbMkeyU._KbMkeyS.l_ctrl || ps3->kbdata[i].mkey._KbMkeyU._KbMkeyS.r_ctrl) - mod |= RETROKMOD_CTRL; - if (ps3->kbdata[i].mkey._KbMkeyU._KbMkeyS.l_shift || ps3->kbdata[i].mkey._KbMkeyU._KbMkeyS.r_shift) - mod |= RETROKMOD_SHIFT; - /* TODO: windows keys. */ + if (ps3->kbdata[i].mkey._KbMkeyU._KbMkeyS.l_alt || ps3->kbdata[i].mkey._KbMkeyU._KbMkeyS.r_alt) + mod |= RETROKMOD_ALT; + if (ps3->kbdata[i].mkey._KbMkeyU._KbMkeyS.l_ctrl || ps3->kbdata[i].mkey._KbMkeyU._KbMkeyS.r_ctrl) + mod |= RETROKMOD_CTRL; + if (ps3->kbdata[i].mkey._KbMkeyU._KbMkeyS.l_shift || ps3->kbdata[i].mkey._KbMkeyU._KbMkeyS.r_shift) + mod |= RETROKMOD_SHIFT; + /* TODO: windows keys. */ - for (int j = 0; j < last_kbdata[i].nb_keycode; j++) { - int code = last_kbdata[i].keycode[j]; - int newly_depressed = 1; - for (int k = 0; k < MAX_KB_PORT_NUM; i++) - if (ps3->kbdata[i].keycode[k] == code) { - newly_depressed = 0; - break; - } - if (newly_depressed) { - unsigned keyboardcode = input_keymaps_translate_keysym_to_rk(code); - input_keyboard_event(false, keyboardcode, keyboardcode, mod, RETRO_DEVICE_KEYBOARD); - } - } + for (j = 0; j < last_kbdata[i].nb_keycode; j++) + { + int code = last_kbdata[i].keycode[j]; + int newly_depressed = 1; + for (int k = 0; k < MAX_KB_PORT_NUM; i++) + if (ps3->kbdata[i].keycode[k] == code) + { + newly_depressed = 0; + break; + } - for (int j = 0; j < ps3->kbdata[i].nb_keycode; j++) { - int code = ps3->kbdata[i].keycode[j]; - int newly_pressed = 1; - for (int k = 0; k < MAX_KB_PORT_NUM; i++) - if (last_kbdata[i].keycode[k] == code) { - newly_pressed = 0; - break; - } - if (newly_pressed) { - unsigned keyboardcode = input_keymaps_translate_keysym_to_rk(code); - input_keyboard_event(true, keyboardcode, keyboardcode, mod, RETRO_DEVICE_KEYBOARD); - } - } + if (newly_depressed) + { + unsigned keyboardcode = input_keymaps_translate_keysym_to_rk(code); + input_keyboard_event(false, keyboardcode, keyboardcode, mod, RETRO_DEVICE_KEYBOARD); + } + } + + for (j = 0; j < ps3->kbdata[i].nb_keycode; j++) + { + int code = ps3->kbdata[i].keycode[j]; + int newly_pressed = 1; + for (int k = 0; k < MAX_KB_PORT_NUM; i++) + if (last_kbdata[i].keycode[k] == code) + { + newly_pressed = 0; + break; + } + if (newly_pressed) + { + unsigned keyboardcode = input_keymaps_translate_keysym_to_rk(code); + input_keyboard_event(true, keyboardcode, keyboardcode, mod, RETRO_DEVICE_KEYBOARD); + } + } } } @@ -145,44 +169,42 @@ static int16_t ps3_mouse_device_state(ps3_input_t *ps3, #endif -static int mod_table[] = { - RETROK_RSUPER, - RETROK_RALT, - RETROK_RSHIFT, - RETROK_RCTRL, - RETROK_LSUPER, - RETROK_LALT, - RETROK_LSHIFT, - RETROK_LCTRL -}; - -static bool -psl1ght_keyboard_port_input_pressed(ps3_input_t *ps3, unsigned id) +static bool psl1ght_keyboard_port_input_pressed(ps3_input_t *ps3, unsigned id) { - if (id >= RETROK_LAST || id == 0) - return false; - for (int i = 0; i < 8; i++) { - if (id == mod_table[i]) { - for (int j = 0; j < MAX_KB_PORT_NUM; j++) { - if(ps3->kbinfo.status[j] && (ps3->kbdata[j].mkey._KbMkeyU.mkeys & - (1 << i))) - return true; - } - return false; - } - } + int code; + unsigned i, j; - int code = rarch_keysym_lut[id]; - if (code == 0) - return false; - for (int i = 0; i < MAX_KB_PORT_NUM; i++) { - if(ps3->kbinfo.status[i]) - for (int j = 0; j < ps3->kbdata[i].nb_keycode; j++) { - if (ps3->kbdata[i].keycode[j] == code) - return true; + if (id >= RETROK_LAST || id == 0) + return false; + + for (i = 0; i < 8; i++) + { + if (id == mod_table[i]) + { + for (j = 0; j < MAX_KB_PORT_NUM; j++) + { + if (ps3->kbinfo.status[j] && (ps3->kbdata[j].mkey._KbMkeyU.mkeys & + (1 << i))) + return true; + } + return false; } - } - return false; + } + + code = rarch_keysym_lut[id]; + if (code == 0) + return false; + for (i = 0; i < MAX_KB_PORT_NUM; i++) + { + if (ps3->kbinfo.status[i]) + for (j = 0; j < ps3->kbdata[i].nb_keycode; j++) + { + if (ps3->kbdata[i].keycode[j] == code) + return true; + } + } + + return false; } static int16_t ps3_input_state(void *data, @@ -191,7 +213,7 @@ static int16_t ps3_input_state(void *data, unsigned port, unsigned device, unsigned idx, unsigned id) { - ps3_input_t *ps3 = (ps3_input_t*)data; + ps3_input_t *ps3 = (ps3_input_t*)data; if (!ps3) return 0; @@ -223,7 +245,7 @@ static int16_t ps3_input_state(void *data, ret |= (1 << i); continue; } - else if (psl1ght_keyboard_port_input_pressed(ps3, binds[port][i].key)) + else if (psl1ght_keyboard_port_input_pressed(ps3, binds[port][i].key)) ret |= (1 << i); } @@ -243,16 +265,16 @@ static int16_t ps3_input_state(void *data, return true; if (((float)abs(ps3->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold) return true; - if (psl1ght_keyboard_port_input_pressed(ps3, binds[port][id].key)) + if (psl1ght_keyboard_port_input_pressed(ps3, binds[port][id].key)) return true; } break; case RETRO_DEVICE_ANALOG: - if (binds[port]) - return input_joypad_analog(ps3->joypad, joypad_info, port, idx, id, binds[port]); + if (binds[port]) + return input_joypad_analog(ps3->joypad, joypad_info, port, idx, id, binds[port]); break; case RETRO_DEVICE_KEYBOARD: - return (psl1ght_keyboard_port_input_pressed(ps3, id)); + return (psl1ght_keyboard_port_input_pressed(ps3, id)); } return 0; @@ -266,6 +288,8 @@ static void ps3_input_free_input(void *data) static void* ps3_input_init(const char *joypad_driver) { + int status; + unsigned i; ps3_input_t *ps3 = (ps3_input_t*)calloc(1, sizeof(*ps3)); if (!ps3) return NULL; @@ -279,20 +303,18 @@ static void* ps3_input_init(const char *joypad_driver) input_keymaps_init_keyboard_lut(rarch_key_map_psl1ght); - int status; - status = ioKbInit(MAX_KB_PORT_NUM); RARCH_LOG("Calling ioKbInit(%d) returned %d\r\n", MAX_KB_PORT_NUM, status); status = ioKbGetInfo(&ps3->kbinfo); RARCH_LOG("Calling ioKbGetInfo() returned %d\r\n", status); - + RARCH_LOG("KbInfo:\r\nMax Kbs: %u\r\nConnected Kbs: %u\r\nInfo Field: %08x\r\n", ps3->kbinfo.max, ps3->kbinfo.connected, ps3->kbinfo.info); - for (int i = 0; i < MAX_KB_PORT_NUM; i++) { - if(ps3->kbinfo.status[i]) { - connect_keyboard(ps3, i); - } + for (i = 0; i < MAX_KB_PORT_NUM; i++) + { + if (ps3->kbinfo.status[i]) + ps3_connect_keyboard(ps3, i); } return ps3; @@ -313,14 +335,14 @@ static uint64_t ps3_input_get_capabilities(void *data) static bool ps3_input_set_sensor_state(void *data, unsigned port, enum retro_sensor_action action, unsigned event_rate) { - RARCH_LOG("alive " __FILE__ ":%d\n", __LINE__); + RARCH_LOG("alive " __FILE__ ":%d\n", __LINE__); return false; } static bool ps3_input_set_rumble(void *data, unsigned port, enum retro_rumble_effect effect, uint16_t strength) { - RARCH_LOG("alive " __FILE__ ":%d\n", __LINE__); + RARCH_LOG("alive " __FILE__ ":%d\n", __LINE__); return false; } @@ -409,25 +431,26 @@ static bool ps3_joypad_init(void *data) return true; } -static u16 transform_buttons(const padData *data) { - return ( - (data->BTN_CROSS << RETRO_DEVICE_ID_JOYPAD_B) - | (data->BTN_SQUARE << RETRO_DEVICE_ID_JOYPAD_Y) - | (data->BTN_SELECT << RETRO_DEVICE_ID_JOYPAD_SELECT) - | (data->BTN_START << RETRO_DEVICE_ID_JOYPAD_START) - | (data->BTN_UP << RETRO_DEVICE_ID_JOYPAD_UP) - | (data->BTN_DOWN << RETRO_DEVICE_ID_JOYPAD_DOWN) - | (data->BTN_LEFT << RETRO_DEVICE_ID_JOYPAD_LEFT) - | (data->BTN_RIGHT << RETRO_DEVICE_ID_JOYPAD_RIGHT) - | (data->BTN_CIRCLE << RETRO_DEVICE_ID_JOYPAD_A) - | (data->BTN_TRIANGLE << RETRO_DEVICE_ID_JOYPAD_X) - | (data->BTN_L1 << RETRO_DEVICE_ID_JOYPAD_L) - | (data->BTN_R1 << RETRO_DEVICE_ID_JOYPAD_R) - | (data->BTN_L2 << RETRO_DEVICE_ID_JOYPAD_L2) - | (data->BTN_R2 << RETRO_DEVICE_ID_JOYPAD_R2) - | (data->BTN_L3 << RETRO_DEVICE_ID_JOYPAD_L3) - | (data->BTN_R3 << RETRO_DEVICE_ID_JOYPAD_R3) - ); +static u16 transform_buttons(const padData *data) +{ + return ( + (data->BTN_CROSS << RETRO_DEVICE_ID_JOYPAD_B) + | (data->BTN_SQUARE << RETRO_DEVICE_ID_JOYPAD_Y) + | (data->BTN_SELECT << RETRO_DEVICE_ID_JOYPAD_SELECT) + | (data->BTN_START << RETRO_DEVICE_ID_JOYPAD_START) + | (data->BTN_UP << RETRO_DEVICE_ID_JOYPAD_UP) + | (data->BTN_DOWN << RETRO_DEVICE_ID_JOYPAD_DOWN) + | (data->BTN_LEFT << RETRO_DEVICE_ID_JOYPAD_LEFT) + | (data->BTN_RIGHT << RETRO_DEVICE_ID_JOYPAD_RIGHT) + | (data->BTN_CIRCLE << RETRO_DEVICE_ID_JOYPAD_A) + | (data->BTN_TRIANGLE << RETRO_DEVICE_ID_JOYPAD_X) + | (data->BTN_L1 << RETRO_DEVICE_ID_JOYPAD_L) + | (data->BTN_R1 << RETRO_DEVICE_ID_JOYPAD_R) + | (data->BTN_L2 << RETRO_DEVICE_ID_JOYPAD_L2) + | (data->BTN_R2 << RETRO_DEVICE_ID_JOYPAD_R2) + | (data->BTN_L3 << RETRO_DEVICE_ID_JOYPAD_L3) + | (data->BTN_R3 << RETRO_DEVICE_ID_JOYPAD_R3) + ); } static bool ps3_joypad_button(unsigned port_num, uint16_t joykey) @@ -440,13 +463,13 @@ static bool ps3_joypad_button(unsigned port_num, uint16_t joykey) static void ps3_joypad_get_buttons(unsigned port_num, input_bits_t *state) { - if (port_num < MAX_PADS) + if (port_num < MAX_PADS) { - u16 v = transform_buttons(&pad_state[port_num]); - BITS_COPY16_PTR( state, v); - } + u16 v = transform_buttons(&pad_state[port_num]); + BITS_COPY16_PTR( state, v); + } else - BIT256_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static int16_t ps3_joypad_axis(unsigned port_num, uint32_t joyaxis) @@ -497,23 +520,29 @@ static int16_t ps3_joypad_axis(unsigned port_num, uint32_t joyaxis) static void ps3_joypad_poll(void) { - padInfo padinfo; - ioPadGetInfo(&padinfo); - for(int port=0; port Date: Tue, 12 May 2020 17:11:51 +0200 Subject: [PATCH 069/192] (PS3) Style nit cleanups --- frontend/drivers/platform_ps3.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/frontend/drivers/platform_ps3.c b/frontend/drivers/platform_ps3.c index 23f04bbddf..c1c1ade022 100644 --- a/frontend/drivers/platform_ps3.c +++ b/frontend/drivers/platform_ps3.c @@ -83,7 +83,6 @@ static void frontend_ps3_shutdown(bool unused) static void callback_sysutil_exit(uint64_t status, uint64_t param, void *userdata) { - (void)param; (void)userdata; (void)status; @@ -107,7 +106,7 @@ static void callback_sysutil_exit(uint64_t status, } #endif -static void fill_derived_paths() +static void fill_derived_paths(void) { strlcpy(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY], g_defaults.dirs[DEFAULT_DIR_PORT], @@ -276,7 +275,8 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[], memset(&size, 0x00, sizeof(CellGameContentSize)); ret = cellGameBootCheck(&get_type, &get_attributes, &size, dirName); - if(ret < 0) + + if (ret < 0) { RARCH_ERR("cellGameBootCheck() Error: 0x%x.\n", ret); } @@ -299,7 +299,7 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[], break; } - if((get_attributes & CELL_GAME_ATTRIBUTE_APP_HOME) + if ((get_attributes & CELL_GAME_ATTRIBUTE_APP_HOME) == CELL_GAME_ATTRIBUTE_APP_HOME) RARCH_LOG("RetroArch was launched from host machine (APP_HOME).\n"); @@ -307,12 +307,10 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[], #ifdef HAVE_MULTIMAN if (multiman_detected) - { - use_app_path(content_info_path); - } + use_app_path(content_info_path); #endif - if(ret < 0) + if (ret < 0) RARCH_ERR("cellGameContentPermit() Error: 0x%x\n", ret); else { @@ -468,7 +466,7 @@ static int frontend_ps3_exec_exitspawn(const char *path, ret = -1; #endif - if(ret < 0) + if (ret < 0) { RARCH_WARN("SELF file is not of NPDRM type, trying another approach to boot it...\n"); sys_game_process_exitspawn(path, (const char** const)argv, From 2ab7da36f2f2a5a96b8ac9460e9fc654ecd7f3b9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 12 May 2020 17:16:36 +0200 Subject: [PATCH 070/192] (Win32) Style nits --- frontend/drivers/platform_win32.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 611cb6d29a..ebb7a6ed28 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -616,15 +616,17 @@ static void frontend_win32_attach_console(void) bool need_stderr = (GetFileType(GetStdHandle(STD_ERROR_HANDLE)) == FILE_TYPE_UNKNOWN); - if(need_stdout || need_stderr) + if (need_stdout || need_stderr) { - if(!AttachConsole( ATTACH_PARENT_PROCESS)) + if (!AttachConsole( ATTACH_PARENT_PROCESS)) AllocConsole(); SetConsoleTitle("Log Console"); - if(need_stdout) freopen( "CONOUT$", "w", stdout ); - if(need_stderr) freopen( "CONOUT$", "w", stderr ); + if (need_stdout) + freopen( "CONOUT$", "w", stdout ); + if (need_stderr) + freopen( "CONOUT$", "w", stderr ); console_needs_free = true; } @@ -637,7 +639,7 @@ static void frontend_win32_detach_console(void) { #if defined(_WIN32) && !defined(_XBOX) #ifdef _WIN32_WINNT_WINXP - if(console_needs_free) + if (console_needs_free) { /* we don't reconnect stdout/stderr to anything here, * because by definition, they weren't connected to @@ -693,7 +695,7 @@ static void frontend_win32_respawn(char *s, size_t len, char *args) si.cb = sizeof(si); memset(&pi, 0, sizeof(pi)); - if(!CreateProcess( executable_path, args, + if (!CreateProcess( executable_path, args, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { RARCH_LOG("Failed to restart RetroArch\n"); From edb308ceb2e72131560a81c0edc8077e7c3d2ac6 Mon Sep 17 00:00:00 2001 From: dankcushions Date: Tue, 12 May 2020 16:27:16 +0100 Subject: [PATCH 071/192] Adjusted menu defaults --- config.def.h | 4 ++-- configuration.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config.def.h b/config.def.h index fe7fbe1ae4..ce38c83a6f 100644 --- a/config.def.h +++ b/config.def.h @@ -517,8 +517,8 @@ static const bool menu_show_sublabels = true; static const bool menu_scroll_fast = false; -#define DEFAULT_MENU_TICKER_TYPE (TICKER_TYPE_BOUNCE) -static const float menu_ticker_speed = 1.0f; +#define DEFAULT_MENU_TICKER_TYPE (TICKER_TYPE_LOOP) +static const float menu_ticker_speed = 2.0f; #define DEFAULT_MENU_TICKER_SMOOTH true diff --git a/configuration.c b/configuration.c index 7ddc5c13af..34dac4fd8c 100644 --- a/configuration.c +++ b/configuration.c @@ -1454,7 +1454,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, #ifdef HAVE_MENU SETTING_BOOL("menu_unified_controls", &settings->bools.menu_unified_controls, true, false, false); SETTING_BOOL("menu_throttle_framerate", &settings->bools.menu_throttle_framerate, true, true, false); - SETTING_BOOL("menu_linear_filter", &settings->bools.menu_linear_filter, true, true, false); + SETTING_BOOL("menu_linear_filter", &settings->bools.menu_linear_filter, true, DEFAULT_VIDEO_SMOOTH, false); SETTING_BOOL("menu_horizontal_animation", &settings->bools.menu_horizontal_animation, true, DEFAULT_MENU_HORIZONTAL_ANIMATION, false); SETTING_BOOL("menu_pause_libretro", &settings->bools.menu_pause_libretro, true, true, false); SETTING_BOOL("menu_savestate_resume", &settings->bools.menu_savestate_resume, true, menu_savestate_resume, false); From 70c57beea9e49478b4e01909d7b179c981442966 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 12 May 2020 17:39:04 +0200 Subject: [PATCH 072/192] Support for dos salamander --- dist-scripts/dist-cores.sh | 9 +++- frontend/drivers/platform_dos.c | 88 +++++++++++++++++++++++++++++++-- frontend/frontend_driver.c | 6 +++ 3 files changed, 96 insertions(+), 7 deletions(-) diff --git a/dist-scripts/dist-cores.sh b/dist-scripts/dist-cores.sh index cc7ad5107a..974df83229 100755 --- a/dist-scripts/dist-cores.sh +++ b/dist-scripts/dist-cores.sh @@ -129,6 +129,7 @@ elif [ $PLATFORM = "dos" ]; then platform=dos MAKEFILE_GRIFFIN=yes EXT=a + SALAMANDER=yes fi # Cleanup Salamander core if it exists @@ -153,6 +154,10 @@ if [ $SALAMANDER = "yes" ]; then if [ $PLATFORM = "psp1" ] ; then mv -f ../EBOOT.PBP ../pkg/${platform}/EBOOT.PBP fi + if [ $platform = "dos" ] ; then + mkdir -p ../pkg/${platform} + mv -f ../retrodos_salamander.exe ../pkg/${platform}/RETRODOS.EXE + fi if [ $PLATFORM = "vita" ] ; then mkdir -p ../pkg/${platform}/retroarch.vpk/vpk/sce_sys/livearea/contents vita-make-fself -c -s ../retroarchvita_salamander.velf ../pkg/${platform}/retroarch.vpk/vpk/eboot.bin @@ -307,8 +312,8 @@ for f in `ls -v *_${platform}.${EXT}`; do elif [ $PLATFORM = "wii" ] ; then mv -f ../retroarch_${platform}.dol ../pkg/${platform}/${name}_libretro_${platform}.dol elif [ $PLATFORM = "dos" ] ; then - mkdir -p ../pkg/${platform} - mv -f ../retrodos.exe ../pkg/${platform}/${name}_libretro_${platform}.exe + mkdir -p ../pkg/${platform}/cores + mv -f ../retrodos.exe ../pkg/${platform}/cores/${name}.exe elif [ $PLATFORM = "emscripten" ] ; then mkdir -p ../pkg/emscripten/ mv -f ../${name}_libretro.js ../pkg/emscripten/${name}_libretro.js diff --git a/frontend/drivers/platform_dos.c b/frontend/drivers/platform_dos.c index af8a312a97..7f3c81a0be 100644 --- a/frontend/drivers/platform_dos.c +++ b/frontend/drivers/platform_dos.c @@ -16,8 +16,14 @@ #include #include +#include +#include +#include #include "../frontend_driver.h" +#include "../../defaults.h" + +static enum frontend_fork dos_fork_mode = FRONTEND_FORK_NONE; static void frontend_dos_init(void *data) { @@ -47,12 +53,18 @@ static void frontend_dos_get_env_settings(int *argc, char *argv[], retro_main_log_file_init("retrodos.txt", false); - strlcpy(base_path, "retrodos", sizeof(base_path)); + strlcpy(base_path, argv[0], sizeof(base_path)); + char *slash = strrchr(base_path, '/'); + if (slash) + *slash = '\0'; + slash = strrchr(base_path, '/'); + if (slash && strcasecmp(slash, "/cores")) + *slash = '\0'; fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], base_path, "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], base_path, - "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + "coreinfo", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], base_path, "autoconf", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); @@ -101,14 +113,80 @@ static void frontend_dos_get_env_settings(int *argc, char *argv[], } } +static void frontend_dos_exec(const char *path, bool should_load_game) +{ + printf("Loading %s, %d\n", path, should_load_game); + + char *newargv[] = { NULL, NULL }; + size_t len = strlen(path); + + newargv[0] = (char*)malloc(len); + + strlcpy(newargv[0], path, len); + + execv(path, newargv); +} + +static void frontend_dos_exitspawn(char *s, size_t len, char *args) +{ + bool should_load_content = false; + + if (dos_fork_mode == FRONTEND_FORK_NONE) + return; + + switch (dos_fork_mode) + { + case FRONTEND_FORK_CORE_WITH_ARGS: + should_load_content = true; + break; + case FRONTEND_FORK_NONE: + default: + break; + } + + frontend_dos_exec(s, should_load_content); +} + +static bool frontend_unix_set_fork(enum frontend_fork fork_mode) +{ + switch (fork_mode) + { + case FRONTEND_FORK_CORE: + RARCH_LOG("FRONTEND_FORK_CORE\n"); + unix_fork_mode = fork_mode; + break; + case FRONTEND_FORK_CORE_WITH_ARGS: + RARCH_LOG("FRONTEND_FORK_CORE_WITH_ARGS\n"); + unix_fork_mode = fork_mode; + break; + case FRONTEND_FORK_RESTART: + RARCH_LOG("FRONTEND_FORK_RESTART\n"); + unix_fork_mode = FRONTEND_FORK_CORE; + + { + char executable_path[PATH_MAX_LENGTH] = {0}; + fill_pathname_application_path(executable_path, + sizeof(executable_path)); + path_set(RARCH_PATH_CORE, executable_path); + } + command_event(CMD_EVENT_QUIT, NULL); + break; + case FRONTEND_FORK_NONE: + default: + return false; + } + + return true; +} + frontend_ctx_driver_t frontend_ctx_dos = { frontend_dos_get_env_settings,/* environment_get */ frontend_dos_init, /* init */ NULL, /* deinit */ - NULL, /* exitspawn */ + frontend_dos_exitspawn, /* exitspawn */ NULL, /* process_args */ - NULL, /* exec */ - NULL, /* set_fork */ + frontend_dos_exec, /* exec */ + frontend_dos_set_fork, /* set_fork */ frontend_dos_shutdown, /* shutdown */ NULL, /* get_name */ NULL, /* get_os */ diff --git a/frontend/frontend_driver.c b/frontend/frontend_driver.c index cd11e6a0b8..b5dcb992f7 100644 --- a/frontend/frontend_driver.c +++ b/frontend/frontend_driver.c @@ -218,6 +218,9 @@ bool frontend_driver_get_core_extension(char *s, size_t len) #elif defined(HAVE_LIBNX) strlcpy(s, "nro", len); return true; +#elif defined(DJGPP) + strlcpy(s, "exe", len); + return true; #elif defined(_3DS) if (envIsHomebrew()) strlcpy(s, "3dsx", len); @@ -264,6 +267,9 @@ bool frontend_driver_get_salamander_basename(char *s, size_t len) #elif defined(_3DS) strlcpy(s, "retroarch.core", len); return true; +#elif defined(DJGPP) + strlcpy(s, "retrodos.exe", len); + return true; #elif defined(SWITCH) strlcpy(s, "retroarch_switch.nro", len); return true; From 6c4c93e17ba6e54fa2e13fbecf53681317ba66e5 Mon Sep 17 00:00:00 2001 From: Autechre Date: Tue, 12 May 2020 18:09:38 +0200 Subject: [PATCH 073/192] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index a7b94f8233..74ef86167b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,7 @@ - MAC/COCOA: Fix mouse cursor tracking - MENU/MATERIALUI: Add desktop-style playlist view mode - MENU/MATERIALUI/DESKTOPVIEW: When scrolling playlists, show last selected thumbnails while waiting for next entry to load +- MENU/RGUI: Adjusted menu defaults, adjusted default scrolling speed - NETPLAY: Fix regressions introduced in 1.8.5 - RGUI: Add option to always stretch menu to fill the screen - WIIU: Enable graphics widgets From 31d9fedf4741def3ecde721a0cf0de02988f0b05 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 12 May 2020 22:55:15 +0200 Subject: [PATCH 074/192] cpu_features_get_time_usec: Use monotonic_clock on djgpp --- libretro-common/features/features_cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index 98fc1de570..dec4df2e78 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -240,14 +240,14 @@ retro_time_t cpu_features_get_time_usec(void) return ticks_to_us(OSGetSystemTime()); #elif defined(SWITCH) || defined(HAVE_LIBNX) return (svcGetSystemTick() * 10) / 192; -#elif defined(_POSIX_MONOTONIC_CLOCK) || defined(__QNX__) || defined(ANDROID) || defined(__MACH__) +#elif defined(_POSIX_MONOTONIC_CLOCK) || defined(__QNX__) || defined(ANDROID) || defined(__MACH__) || defined(DJGPP) struct timespec tv = {0}; if (ra_clock_gettime(CLOCK_MONOTONIC, &tv) < 0) return 0; return tv.tv_sec * INT64_C(1000000) + (tv.tv_nsec + 500) / 1000; #elif defined(EMSCRIPTEN) return emscripten_get_now() * 1000; -#elif defined(PS2) || defined(DJGPP) +#elif defined(PS2) return clock()*(1000000LL/CLOCKS_PER_SEC); #elif defined(__mips__) struct timeval tv; From cab004f08a485598782b17624d1dcf1f8de5a9eb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 12 May 2020 22:54:16 +0200 Subject: [PATCH 075/192] cpu_features_get_time_usec: Use sceKernelGetSystemTimeWide on PSP and Vita --- libretro-common/features/features_cpu.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index dec4df2e78..7d1d98cfdc 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -249,14 +249,10 @@ retro_time_t cpu_features_get_time_usec(void) return emscripten_get_now() * 1000; #elif defined(PS2) return clock()*(1000000LL/CLOCKS_PER_SEC); -#elif defined(__mips__) - struct timeval tv; - gettimeofday(&tv,NULL); - return (1000000 * tv.tv_sec + tv.tv_usec); #elif defined(_3DS) return osGetTime() * 1000; -#elif defined(VITA) - return sceKernelGetProcessTimeWide(); +#elif defined(VITA) || defined(PSP) + return sceKernelGetSystemTimeWide(); #else #error "Your platform does not have a timer function implemented in cpu_features_get_time_usec(). Cannot continue." #endif From f1f248dd119c27e5406501c2d127ffae4caf263e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Coll=20Cerd=C3=A1n?= Date: Tue, 12 May 2020 20:08:37 +0200 Subject: [PATCH 076/192] Add fallback directories to shader presets. Improves the management of shader presets by using the Menu Config directory and the directory of the configuration file as alternate fallback directories whenever the Video Shader directory is not writable. --- menu/menu_shader.c | 153 +++++++++++++++++++++++++++++++-------------- retroarch.c | 122 ++++++++++++++++++++++++------------ 2 files changed, 187 insertions(+), 88 deletions(-) diff --git a/menu/menu_shader.c b/menu/menu_shader.c index 5cf8cf70c2..b02839d8e0 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -278,8 +278,9 @@ static bool menu_shader_manager_save_preset_internal( } else { - const char *dirs[3] = {0}; + const char *dirs[3] = {0}; char config_directory[PATH_MAX_LENGTH]; + char basedir[PATH_MAX_LENGTH]; config_directory[0] = '\0'; @@ -301,6 +302,19 @@ static bool menu_shader_manager_save_preset_internal( fill_pathname_join(buffer, dirs[i], fullname, sizeof(buffer)); + strlcpy(basedir, buffer, sizeof(basedir)); + path_basedir(basedir); + + if (!path_is_directory(basedir)) { + ret = path_mkdir(basedir); + + if (!ret) + { + RARCH_WARN("Failed to create preset directory %s.\n", basedir); + continue; + } + } + preset_path = buffer; ret = video_shader_write_preset(preset_path, @@ -337,43 +351,25 @@ static bool menu_shader_manager_operate_auto_preset( char tmp[PATH_MAX_LENGTH]; char directory[PATH_MAX_LENGTH]; char file[PATH_MAX_LENGTH]; - bool success = false; struct retro_system_info *system = runloop_get_libretro_system_info(); const char *core_name = system ? system->library_name : NULL; tmp[0] = directory[0] = file[0] = '\0'; - if (type == SHADER_PRESET_GLOBAL) - fill_pathname_join( - directory, - dir_video_shader, - "presets", - sizeof(directory)); - else if (string_is_empty(core_name)) + if (type != SHADER_PRESET_GLOBAL && string_is_empty(core_name)) return false; - else - { - fill_pathname_join( - tmp, - dir_video_shader, - "presets", - sizeof(tmp)); - fill_pathname_join( - directory, - tmp, - core_name, - sizeof(directory)); - } switch (type) { case SHADER_PRESET_GLOBAL: - fill_pathname_join(file, directory, "global", sizeof(file)); + fill_pathname_join(file, "presets", "global", sizeof(file)); break; case SHADER_PRESET_CORE: + fill_pathname_join(directory, "presets", core_name, sizeof(directory)); fill_pathname_join(file, directory, core_name, sizeof(file)); break; case SHADER_PRESET_PARENT: + fill_pathname_join(directory, "presets", core_name, sizeof(directory)); fill_pathname_parent_dir_name(tmp, path_get(RARCH_PATH_BASENAME), sizeof(tmp)); fill_pathname_join(file, directory, tmp, sizeof(file)); @@ -384,6 +380,7 @@ static bool menu_shader_manager_operate_auto_preset( path_basename(path_get(RARCH_PATH_BASENAME)); if (string_is_empty(game_name)) return false; + fill_pathname_join(directory, "presets", core_name, sizeof(directory)); fill_pathname_join(file, directory, game_name, sizeof(file)); break; } @@ -394,9 +391,6 @@ static bool menu_shader_manager_operate_auto_preset( switch (op) { case AUTO_SHADER_OP_SAVE: - if (!path_is_directory(directory)) - path_mkdir(directory); - return menu_shader_manager_save_preset_internal( shader, file, dir_video_shader, @@ -405,41 +399,106 @@ static bool menu_shader_manager_operate_auto_preset( case AUTO_SHADER_OP_REMOVE: { /* remove all supported auto-shaders of given type */ - char *end = file + strlen(file); - size_t i; - for (i = 0; i < ARRAY_SIZE(shader_types); i++) - { - const char *preset_ext; + char *end; + size_t i, j; + size_t n, m; - if (!video_shader_is_supported(shader_types[i])) + n = m = 0; + + const char *dirs[3] = {0}; + char config_directory[PATH_MAX_LENGTH]; + char preset_path[PATH_MAX_LENGTH]; + + config_directory[0] = '\0'; + + if (!path_is_empty(RARCH_PATH_CONFIG)) + fill_pathname_basedir( + config_directory, + path_get(RARCH_PATH_CONFIG), + sizeof(config_directory)); + + dirs[0] = dir_video_shader; + dirs[1] = dir_menu_config; + dirs[2] = config_directory; + + for (i = 0; i < ARRAY_SIZE(dirs); i++) + { + if (string_is_empty(dirs[i])) continue; - preset_ext = video_shader_get_preset_extension(shader_types[i]); - strlcpy(end, preset_ext, sizeof(file) - (end-file)); + fill_pathname_join(preset_path, dirs[i], file, sizeof(preset_path)); + end = preset_path + strlen(preset_path); - if (!filestream_delete(file)) - success = true; + for (j = 0; j < ARRAY_SIZE(shader_types); j++) + { + const char *preset_ext; + + if (!video_shader_is_supported(shader_types[j])) + continue; + + preset_ext = video_shader_get_preset_extension(shader_types[j]); + strlcpy(end, preset_ext, sizeof(preset_path) - (end - preset_path)); + + if (path_is_valid(preset_path)) + { + n++; + + if (!filestream_delete(preset_path)) + { + m++; + RARCH_LOG("Deleted shader preset from %s.\n", preset_path); + } + else + RARCH_WARN("Failed to remove shader preset at %s.\n", preset_path); + } + } } + + return n == m; } - return success; case AUTO_SHADER_OP_EXISTS: { /* test if any supported auto-shaders of given type exists */ - char *end = file + strlen(file); - size_t i; + char *end; + size_t i, j; - for (i = 0; i < ARRAY_SIZE(shader_types); i++) + const char *dirs[3] = {0}; + char config_directory[PATH_MAX_LENGTH]; + char preset_path[PATH_MAX_LENGTH]; + + config_directory[0] = '\0'; + + if (!path_is_empty(RARCH_PATH_CONFIG)) + fill_pathname_basedir( + config_directory, + path_get(RARCH_PATH_CONFIG), + sizeof(config_directory)); + + dirs[0] = dir_video_shader; + dirs[1] = dir_menu_config; + dirs[2] = config_directory; + + for (i = 0; i < ARRAY_SIZE(dirs); i++) { - const char *preset_ext; - - if (!video_shader_is_supported(shader_types[i])) + if (string_is_empty(dirs[i])) continue; - preset_ext = video_shader_get_preset_extension(shader_types[i]); - strlcpy(end, preset_ext, sizeof(file) - (end-file)); + fill_pathname_join(preset_path, dirs[i], file, sizeof(preset_path)); + end = preset_path + strlen(preset_path); - if (path_is_valid(file)) - return true; + for (j = 0; j < ARRAY_SIZE(shader_types); j++) + { + const char *preset_ext; + + if (!video_shader_is_supported(shader_types[j])) + continue; + + preset_ext = video_shader_get_preset_extension(shader_types[j]); + strlcpy(end, preset_ext, sizeof(preset_path) - (end - preset_path)); + + if (path_is_valid(preset_path)) + return true; + } } } break; diff --git a/retroarch.c b/retroarch.c index 2a54db3519..51e3b6c3b7 100644 --- a/retroarch.c +++ b/retroarch.c @@ -27318,6 +27318,13 @@ static bool retroarch_load_shader_preset_internal( * folder-specific: $SHADER_DIR/presets/$CORE_NAME/$FOLDER_NAME.$PRESET_EXT * game-specific: $SHADER_DIR/presets/$CORE_NAME/$GAME_NAME.$PRESET_EXT * + * $SHADER_DIR is composed by three different locations which will be searched + * in the following order (search will stop on first match): + * + * 1. The Video Shader directory + * 2. The Menu Config directory + * 3. The directory where the configuration file is stored + * * Note: Uses video_shader_is_supported() which only works after * context driver initialization. * @@ -27327,71 +27334,104 @@ static bool retroarch_load_shader_preset(void) { settings_t *settings = configuration_settings; const char *video_shader_directory = settings->paths.directory_video_shader; + const char *menu_config_directory = settings->paths.directory_menu_config; const char *core_name = runloop_system.info.library_name; const char *rarch_path_basename = path_get(RARCH_PATH_BASENAME); const char *game_name = path_basename(rarch_path_basename); + char *content_dir_name = NULL; + char *config_file_directory = NULL; char *shader_directory = NULL; bool auto_shaders_enable = settings->bools.auto_shaders_enable; + const char *dirs[3] = {0}; + size_t i = 0; + + bool ret = false; + if (!auto_shaders_enable) return false; - if (string_is_empty(video_shader_directory)) - return false; + + content_dir_name = (char*)malloc(PATH_MAX_LENGTH); + if (!content_dir_name) + goto end; + + config_file_directory = (char*)malloc(PATH_MAX_LENGTH); + if (!config_file_directory) + goto end; shader_directory = (char*)malloc(PATH_MAX_LENGTH); - if (!shader_directory) - return false; + goto end; - fill_pathname_join(shader_directory, - video_shader_directory, - "presets", PATH_MAX_LENGTH); + content_dir_name[0] = '\0'; - RARCH_LOG("[Shaders]: preset directory: %s\n", shader_directory); + if (!string_is_empty(rarch_path_basename)) + fill_pathname_parent_dir_name(content_dir_name, + rarch_path_basename, PATH_MAX_LENGTH); - if (retroarch_load_shader_preset_internal(shader_directory, core_name, - game_name)) + config_file_directory[0] = '\0'; + + if (!path_is_empty(RARCH_PATH_CONFIG)) + fill_pathname_basedir(config_file_directory, + path_get(RARCH_PATH_CONFIG), PATH_MAX_LENGTH); + + dirs[0] = video_shader_directory; + dirs[1] = menu_config_directory; + dirs[2] = config_file_directory; + + for (i = 0; i < ARRAY_SIZE(dirs); i++) { - RARCH_LOG("[Shaders]: game-specific shader preset found.\n"); - goto success; - } + if (string_is_empty(dirs[i])) + continue; - { - char content_dir_name[PATH_MAX_LENGTH]; - content_dir_name[0] = '\0'; - if (!string_is_empty(rarch_path_basename)) - fill_pathname_parent_dir_name(content_dir_name, - rarch_path_basename, sizeof(content_dir_name)); + fill_pathname_join(shader_directory, + dirs[i], "presets", PATH_MAX_LENGTH); - if (retroarch_load_shader_preset_internal(shader_directory, core_name, - content_dir_name)) + RARCH_LOG("[Shaders]: preset directory: %s\n", shader_directory); + + ret = retroarch_load_shader_preset_internal(shader_directory, core_name, + game_name); + + if (ret) + { + RARCH_LOG("[Shaders]: game-specific shader preset found.\n"); + break; + } + + ret = retroarch_load_shader_preset_internal(shader_directory, core_name, + content_dir_name); + + if (ret) { RARCH_LOG("[Shaders]: folder-specific shader preset found.\n"); - goto success; + break; + } + + ret = retroarch_load_shader_preset_internal(shader_directory, core_name, + core_name); + + if (ret) + { + RARCH_LOG("[Shaders]: core-specific shader preset found.\n"); + break; + } + + ret = retroarch_load_shader_preset_internal(shader_directory, NULL, + "global"); + + if (ret) + { + RARCH_LOG("[Shaders]: global shader preset found.\n"); + break; } } - if (retroarch_load_shader_preset_internal(shader_directory, core_name, - core_name)) - { - RARCH_LOG("[Shaders]: core-specific shader preset found.\n"); - goto success; - } - - if (retroarch_load_shader_preset_internal(shader_directory, NULL, - "global")) - { - RARCH_LOG("[Shaders]: global shader preset found.\n"); - goto success; - } - +end: + free(content_dir_name); + free(config_file_directory); free(shader_directory); - return false; - -success: - free(shader_directory); - return true; + return ret; } #endif From fe42f6bb73c8e1108903073079166d25ca97e576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Coll=20Cerd=C3=A1n?= Date: Wed, 13 May 2020 19:44:23 +0200 Subject: [PATCH 077/192] Changed the order of shader preset directories. The Menu Config directory now takes precedence over the Video Shader directory for the storage of shader preset overrides. With this, all user overrides are grouped by default under the same path. --- menu/menu_shader.c | 12 ++++++------ retroarch.c | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/menu/menu_shader.c b/menu/menu_shader.c index b02839d8e0..640b288ce3 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -290,8 +290,8 @@ static bool menu_shader_manager_save_preset_internal( path_get(RARCH_PATH_CONFIG), sizeof(config_directory)); - dirs[0] = dir_video_shader; - dirs[1] = dir_menu_config; + dirs[0] = dir_menu_config; + dirs[1] = dir_video_shader; dirs[2] = config_directory; for (i = 0; i < ARRAY_SIZE(dirs); i++) @@ -417,8 +417,8 @@ static bool menu_shader_manager_operate_auto_preset( path_get(RARCH_PATH_CONFIG), sizeof(config_directory)); - dirs[0] = dir_video_shader; - dirs[1] = dir_menu_config; + dirs[0] = dir_menu_config; + dirs[1] = dir_video_shader; dirs[2] = config_directory; for (i = 0; i < ARRAY_SIZE(dirs); i++) @@ -474,8 +474,8 @@ static bool menu_shader_manager_operate_auto_preset( path_get(RARCH_PATH_CONFIG), sizeof(config_directory)); - dirs[0] = dir_video_shader; - dirs[1] = dir_menu_config; + dirs[0] = dir_menu_config; + dirs[1] = dir_video_shader; dirs[2] = config_directory; for (i = 0; i < ARRAY_SIZE(dirs); i++) diff --git a/retroarch.c b/retroarch.c index 51e3b6c3b7..5543bd9ca5 100644 --- a/retroarch.c +++ b/retroarch.c @@ -27321,8 +27321,8 @@ static bool retroarch_load_shader_preset_internal( * $SHADER_DIR is composed by three different locations which will be searched * in the following order (search will stop on first match): * - * 1. The Video Shader directory - * 2. The Menu Config directory + * 1. The Menu Config directory + * 2. The Video Shader directory * 3. The directory where the configuration file is stored * * Note: Uses video_shader_is_supported() which only works after @@ -27376,8 +27376,8 @@ static bool retroarch_load_shader_preset(void) fill_pathname_basedir(config_file_directory, path_get(RARCH_PATH_CONFIG), PATH_MAX_LENGTH); - dirs[0] = video_shader_directory; - dirs[1] = menu_config_directory; + dirs[0] = menu_config_directory; + dirs[1] = video_shader_directory; dirs[2] = config_file_directory; for (i = 0; i < ARRAY_SIZE(dirs); i++) From 718e9eaf37da9b1a0c35dcad5994bb0b46620e8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Coll=20Cerd=C3=A1n?= <721143+johanbcn@users.noreply.github.com> Date: Thu, 14 May 2020 00:32:52 +0200 Subject: [PATCH 078/192] Comply with the C89 standard --- menu/menu_shader.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/menu/menu_shader.c b/menu/menu_shader.c index 640b288ce3..45eb76cfcd 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -400,15 +400,14 @@ static bool menu_shader_manager_operate_auto_preset( { /* remove all supported auto-shaders of given type */ char *end; - size_t i, j; - size_t n, m; - - n = m = 0; + size_t i, j, n, m; const char *dirs[3] = {0}; char config_directory[PATH_MAX_LENGTH]; char preset_path[PATH_MAX_LENGTH]; + n = m = 0; + config_directory[0] = '\0'; if (!path_is_empty(RARCH_PATH_CONFIG)) From 89c7d1a8357019058c67faef24e6d839a5a530a4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 14 May 2020 09:27:58 +0200 Subject: [PATCH 079/192] Update libretro-common --- libretro-common/features/features_cpu.c | 18 +++++------ libretro-common/libco/armeabi.c | 5 +++- libretro-common/libco/psp1.c | 40 +++++++++++-------------- libretro-common/streams/file_stream.c | 10 +++++-- 4 files changed, 37 insertions(+), 36 deletions(-) diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index 7d1d98cfdc..63d01427a4 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -189,22 +189,18 @@ retro_perf_tick_t cpu_features_get_perf_counter(void) time_ticks = __mftb(); #elif defined(GEKKO) time_ticks = gettime(); -#elif defined(PSP) - sceRtcGetCurrentTick((uint64_t*)&time_ticks); -#elif defined(VITA) - sceRtcGetCurrentTick((SceRtcTick*)&time_ticks); +#elif defined(PSP) || defined(VITA) + time_ticks = sceKernelGetSystemTimeWide(); #elif defined(PS2) time_ticks = clock()*294912; // 294,912MHZ / 1000 msecs #elif defined(_3DS) time_ticks = svcGetSystemTick(); #elif defined(WIIU) time_ticks = OSGetSystemTime(); -#elif defined(__mips__) - struct timeval tv; - gettimeofday(&tv,NULL); - time_ticks = (1000000 * tv.tv_sec + tv.tv_usec); #elif defined(HAVE_LIBNX) time_ticks = armGetSystemTick(); +#elif defined(EMSCRIPTEN) + time_ticks = emscripten_get_now() * 1000; #endif return time_ticks; @@ -248,11 +244,11 @@ retro_time_t cpu_features_get_time_usec(void) #elif defined(EMSCRIPTEN) return emscripten_get_now() * 1000; #elif defined(PS2) - return clock()*(1000000LL/CLOCKS_PER_SEC); -#elif defined(_3DS) - return osGetTime() * 1000; + return clock()*1000; #elif defined(VITA) || defined(PSP) return sceKernelGetSystemTimeWide(); +#elif defined(_3DS) + return osGetTime() * 1000; #else #error "Your platform does not have a timer function implemented in cpu_features_get_time_usec(). Cannot continue." #endif diff --git a/libretro-common/libco/armeabi.c b/libretro-common/libco/armeabi.c index f03a356794..3f0ea1a30c 100644 --- a/libretro-common/libco/armeabi.c +++ b/libretro-common/libco/armeabi.c @@ -24,10 +24,13 @@ static thread_local cothread_t co_active_handle; __asm__ ( #if defined(__thumb2__) - ".thumb\n" ".align 2\n" ".globl co_switch_arm\n" ".globl _co_switch_arm\n" + ".thumb\n" + ".thumb_func\n" + ".type co_switch_arm, %function\n" + ".type _co_switch_arm, %function\n" "co_switch_arm:\n" "_co_switch_arm:\n" " mov r3, sp\n" diff --git a/libretro-common/libco/psp1.c b/libretro-common/libco/psp1.c index 45850a4d83..75a71c22e7 100644 --- a/libretro-common/libco/psp1.c +++ b/libretro-common/libco/psp1.c @@ -4,42 +4,38 @@ #include #include -/* Since cothread_t is a void pointer it must contain an address. We can't return a reference to a local variable - * because it would go out of scope, so we create a static variable instead so we can return a reference to it. - */ -static SceUID active_thread_id = 0; +typedef void (*entrypoint_t)(void); cothread_t co_active() { - active_thread_id = sceKernelGetThreadId(); - return &active_thread_id; + return (void *) sceKernelGetThreadId(); +} + +static int thread_wrap(unsigned int argc, void *argp) +{ + entrypoint_t entrypoint = *(entrypoint_t *) argp; + sceKernelSleepThread(); + entrypoint(); + return 0; } cothread_t co_create(unsigned int size, void (*entrypoint)(void)) { - /* Similar scenario as with active_thread_id except there will only be one active_thread_id while there could be many - * new threads each with their own handle, so we create them on the heap instead and delete them manually when they're - * no longer needed in co_delete(). - */ - cothread_t handle = malloc(sizeof(cothread_t)); - - /* SceKernelThreadEntry has a different signature than entrypoint, but in practice this seems to work */ - SceUID new_thread_id = sceKernelCreateThread("cothread", (SceKernelThreadEntry)entrypoint, 0x12, size, 0, NULL); - sceKernelStartThread(new_thread_id, 0, NULL); - - *(SceUID *)handle = new_thread_id; - return handle; + SceUID new_thread_id = sceKernelCreateThread("cothread", thread_wrap, 0x12, size, 0, NULL); + sceKernelStartThread(new_thread_id, sizeof (entrypoint), &entrypoint); + return (void *) new_thread_id; } void co_delete(cothread_t handle) { - sceKernelTerminateDeleteThread(*(SceUID *)handle); - free(handle); + SceUID id = (SceUID) handle; + sceKernelTerminateDeleteThread(id); } void co_switch(cothread_t handle) { - sceKernelWakeupThread(*(SceUID *)handle); + SceUID id = (SceUID) handle; + sceKernelWakeupThread(id); /* Sleep the currently active thread so the new thread can start */ sceKernelSleepThread(); -} \ No newline at end of file +} diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index bacd810943..b8d4c49ece 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -275,11 +275,17 @@ int filestream_scanf(RFILE *stream, const char* format, ...) if (sizeof(void*) != sizeof(long*)) abort(); /* all pointers must have the same size */ if (asterisk) { - if (sscanf(bufiter, subfmt, &sublen) != 0) break; + int v = sscanf(bufiter, subfmt, &sublen); + if (v == EOF) + return EOF; + if (v != 0) break; } else { - if (sscanf(bufiter, subfmt, va_arg(args, void*), &sublen) != 1) break; + int v = sscanf(bufiter, subfmt, va_arg(args, void*), &sublen); + if (v == EOF) + return EOF; + if (v != 1) break; } ret++; From eff8c31ffdf5cd1daf4a1b025b1955a0e36130f1 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Thu, 14 May 2020 11:23:41 +0100 Subject: [PATCH 080/192] (XMB/GLUI) Limit tab switch rate when input repeat is active --- menu/cbs/menu_cbs_left.c | 68 ++++++++++++------------------ menu/cbs/menu_cbs_right.c | 7 ++- menu/drivers/materialui.c | 45 ++++++++++++++++++++ menu/drivers/ozone/ozone_display.c | 7 ++- menu/drivers/rgui.c | 5 +-- menu/drivers/xmb.c | 51 ++++++++++++++++++++++ menu/menu_driver.c | 4 ++ menu/menu_driver.h | 2 + 8 files changed, 138 insertions(+), 51 deletions(-) diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index db20c52547..812490bd8e 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -220,12 +220,32 @@ static int action_left_scroll(unsigned type, const char *label, return 0; } +static int action_left_goto_tab(void) +{ + menu_ctx_list_t list_info; + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); + size_t selection = menu_navigation_get_selection(); + menu_file_list_cbs_t *cbs = selection_buf ? (menu_file_list_cbs_t*) + selection_buf->list[selection].actiondata : NULL; + + list_info.type = MENU_LIST_HORIZONTAL; + list_info.action = MENU_ACTION_LEFT; + + menu_driver_list_cache(&list_info); + + if (cbs && cbs->action_content_list_switch) + return cbs->action_content_list_switch(selection_buf, menu_stack, + "", "", 0); + + return 0; +} + static int action_left_mainmenu(unsigned type, const char *label, bool wraparound) { menu_ctx_list_t list_info; - unsigned push_list = 0; - settings_t *settings = config_get_ptr(); + settings_t *settings = config_get_ptr(); bool menu_nav_wraparound_enable = settings->bools.menu_navigation_wraparound_enable; const char *menu_ident = menu_driver_ident(); @@ -235,48 +255,16 @@ static int action_left_mainmenu(unsigned type, const char *label, menu_driver_list_get_size(&list_info); - /* List switching functionality does not - * apply to RGUI or MaterialUI */ + /* Tab switching functionality only applies + * to XMB */ if ((list_info.size == 1) && - !string_is_equal(menu_ident, "rgui") && - !string_is_equal(menu_ident, "glui")) + string_is_equal(menu_ident, "xmb")) { - if ((list_info.selection != 0) - || menu_nav_wraparound_enable) - push_list = 1; + if ((list_info.selection != 0) || menu_nav_wraparound_enable) + return action_left_goto_tab(); } else - push_list = 2; - - switch (push_list) - { - case 1: - { - menu_ctx_list_t list_info; - file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); - file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); - size_t selection = menu_navigation_get_selection(); - menu_file_list_cbs_t *cbs = selection_buf ? - (menu_file_list_cbs_t*) - selection_buf->list[selection].actiondata : NULL; - - list_info.type = MENU_LIST_HORIZONTAL; - list_info.action = MENU_ACTION_LEFT; - - menu_driver_list_cache(&list_info); - - if (cbs && cbs->action_content_list_switch) - return cbs->action_content_list_switch( - selection_buf, menu_stack, "", "", 0); - } - break; - case 2: - action_left_scroll(0, "", false); - break; - case 0: - default: - break; - } + action_left_scroll(0, "", false); return 0; } diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index b8b3cf3561..cd0b77585a 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -265,11 +265,10 @@ static int action_right_mainmenu(unsigned type, const char *label, menu_driver_list_get_size(&list_info); - /* Tab switching functionality does not - * apply to RGUI or MaterialUI */ + /* Tab switching functionality only applies + * to XMB */ if ((list_info.size == 1) && - !string_is_equal(menu_ident, "rgui") && - !string_is_equal(menu_ident, "glui")) + string_is_equal(menu_ident, "xmb")) { menu_ctx_list_t list_horiz_info; menu_ctx_list_t list_tabs_info; diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 7ba0c9a2a8..06d80434f2 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -1073,6 +1073,23 @@ typedef struct * Colour Themes END * ============================== */ +/* Specifies minimum period (in usec) between + * tab switch events when input repeat is + * active (i.e. when navigating between top level + * menu categories by *holding* left/right on + * RetroPad or keyboard) + * > Note: We want to set a value of 300 ms + * here, but doing so leads to bad pacing when + * running at 60 Hz (due to random frame time + * deviations - input repeat cycles always take + * slightly more or less than 300 ms, so tab + * switches occur every n or (n + 1) frames, + * which gives the appearance of stuttering). + * Reducing the delay by 1 ms accommodates + * any timing fluctuations, resulting in + * smooth motion */ +#define MUI_TAB_SWITCH_REPEAT_DELAY 299000 + /* Animation defines */ #define MUI_ANIM_DURATION_SCROLL 166.66667f #define MUI_ANIM_DURATION_SCROLL_RESET 83.333333f @@ -1412,6 +1429,10 @@ typedef struct materialui_handle bool last_auto_rotate_nav_bar; bool menu_stack_flushed; + /* Keeps track of the last time tabs were switched + * via a MENU_ACTION_LEFT/MENU_ACTION_RIGHT event */ + retro_time_t last_tab_switch_time; + enum materialui_landscape_layout_optimization_type last_landscape_layout_optimization; materialui_landscape_optimization_t @@ -7949,6 +7970,30 @@ static enum menu_action materialui_parse_menu_entry_action( if ((mui->nav_bar.location != MUI_NAV_BAR_LOCATION_HIDDEN) && (materialui_list_get_size(mui, MENU_LIST_PLAIN) == 1)) { + retro_time_t current_time = menu_driver_get_current_time(); + size_t scroll_accel = 0; + + /* Determine whether input repeat is + * currently active + * > This is always true when scroll + * acceleration is greater than zero */ + menu_driver_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, + &scroll_accel); + + if (scroll_accel > 0) + { + /* Ignore input action if tab switch period + * is less than defined limit */ + if ((current_time - mui->last_tab_switch_time) < + MUI_TAB_SWITCH_REPEAT_DELAY) + { + new_action = MENU_ACTION_NOOP; + break; + } + } + mui->last_tab_switch_time = current_time; + + /* Perform tab switch */ materialui_switch_tabs(mui, NULL, action); new_action = MENU_ACTION_ACCESSIBILITY_SPEAK_TITLE_LABEL; } diff --git a/menu/drivers/ozone/ozone_display.c b/menu/drivers/ozone/ozone_display.c index 14c77487f9..2ce3263d30 100644 --- a/menu/drivers/ozone/ozone_display.c +++ b/menu/drivers/ozone/ozone_display.c @@ -25,7 +25,6 @@ #include #include #include -#include #include "../../../gfx/gfx_animation.h" @@ -355,7 +354,7 @@ void ozone_draw_osk(ozone_handle_t *ozone, unsigned y_offset = 0; bool draw_placeholder = string_is_empty(str); - retro_time_t current_time = cpu_features_get_time_usec(); + retro_time_t current_time = menu_driver_get_current_time(); static retro_time_t last_time = 0; if (current_time - last_time >= INTERVAL_OSK_CURSOR) @@ -467,9 +466,9 @@ void ozone_draw_osk(ozone_handle_t *ozone, video_width, video_height, margin + padding*2 + cursor_x, - margin + padding + y_offset + ozone->dimensions.spacer_3px, + margin + padding + y_offset + ozone->fonts.entries_label.line_height - ozone->fonts.entries_label.line_ascender + ozone->dimensions.spacer_3px, ozone->dimensions.spacer_1px, - 25 * scale_factor, + ozone->fonts.entries_label.line_ascender, video_width, video_height, ozone_pure_white); diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 43f6134000..391685113d 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -34,7 +34,6 @@ #include #include -#include #ifdef HAVE_CONFIG_H #include "../../config.h" @@ -4768,7 +4767,7 @@ static void rgui_scan_selected_entry_thumbnail(rgui_t *rgui, bool force_load) { /* Schedule a delayed load */ rgui->thumbnail_load_pending = true; - rgui->thumbnail_load_trigger_time = cpu_features_get_time_usec(); + rgui->thumbnail_load_trigger_time = menu_driver_get_current_time(); } } } @@ -5291,7 +5290,7 @@ static void rgui_frame(void *data, video_frame_info_t *video_info) * Note: Delay is increased when viewing fullscreen thumbnails, * since the flicker when switching between playlist view and * fullscreen thumbnail view is incredibly jarring...) */ - if ((cpu_features_get_time_usec() - rgui->thumbnail_load_trigger_time) >= + if ((menu_driver_get_current_time() - rgui->thumbnail_load_trigger_time) >= (settings->uints.menu_rgui_thumbnail_delay * 1000 * (rgui->show_fs_thumbnail ? 1.5f : 1.0f))) rgui_load_current_thumbnails(rgui, settings->bools.network_on_demand_thumbnails); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 38f198701c..c2979b1e2a 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -67,6 +67,23 @@ #define XMB_DELAY 166.66667f #endif +/* Specifies minimum period (in usec) between + * tab switch events when input repeat is + * active (i.e. when navigating between top level + * menu categories by *holding* left/right on + * RetroPad or keyboard) + * > Note: We want to set a value of 100 ms + * here, but doing so leads to bad pacing when + * running at 60 Hz (due to random frame time + * deviations - input repeat cycles always take + * slightly more or less than 100 ms, so tab + * switches occur every n or (n + 1) frames, + * which gives the appearance of stuttering). + * Reducing the delay by 1 ms accommodates + * any timing fluctuations, resulting in + * smooth motion */ +#define XMB_TAB_SWITCH_REPEAT_DELAY 99000 + #if 0 #define XMB_DEBUG #endif @@ -346,6 +363,10 @@ typedef struct xmb_handle size_t fullscreen_thumbnail_selection; char fullscreen_thumbnail_label[255]; + /* Keeps track of the last time tabs were switched + * via a MENU_ACTION_LEFT/MENU_ACTION_RIGHT event */ + retro_time_t last_tab_switch_time; + } xmb_handle_t; float scale_mod[8] = { @@ -6832,6 +6853,36 @@ static enum menu_action xmb_parse_menu_entry_action( /* Scan user inputs */ switch (action) { + case MENU_ACTION_LEFT: + case MENU_ACTION_RIGHT: + /* Check whether left/right action will + * trigger a tab switch event */ + if (xmb->depth == 1) + { + retro_time_t current_time = menu_driver_get_current_time(); + size_t scroll_accel = 0; + + /* Determine whether input repeat is + * currently active + * > This is always true when scroll + * acceleration is greater than zero */ + menu_driver_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, + &scroll_accel); + + if (scroll_accel > 0) + { + /* Ignore input action if tab switch period + * is less than defined limit */ + if ((current_time - xmb->last_tab_switch_time) < + XMB_TAB_SWITCH_REPEAT_DELAY) + { + new_action = MENU_ACTION_NOOP; + break; + } + } + xmb->last_tab_switch_time = current_time; + } + break; case MENU_ACTION_START: /* If this is a menu with thumbnails, attempt * to show fullscreen thumbnail view */ diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 4240436654..f342977146 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -2662,6 +2662,10 @@ bool menu_driver_list_get_size(menu_ctx_list_t *list) return true; } +retro_time_t menu_driver_get_current_time(void) +{ + return menu_driver_current_time_us; +} bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) { diff --git a/menu/menu_driver.h b/menu/menu_driver.h index da4debff16..da972289de 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -463,6 +463,8 @@ bool menu_driver_list_get_entry(menu_ctx_list_t *list); bool menu_driver_list_get_size(menu_ctx_list_t *list); +retro_time_t menu_driver_get_current_time(void); + size_t menu_navigation_get_selection(void); void menu_navigation_set_selection(size_t val); From 9d5a54ced4ebcf2e86b7e1c49e569fc089a58762 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Thu, 14 May 2020 14:16:36 +0100 Subject: [PATCH 081/192] (RGUI) Enable custom wallpaper when menu size is reduced at low resolutions --- menu/drivers/rgui.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 391685113d..d72e83a1c6 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -1620,36 +1620,39 @@ static void rgui_render_particle_effect(rgui_t *rgui) static void process_wallpaper(rgui_t *rgui, struct texture_image *image) { unsigned x, y; - - /* Note: Ugly hacks required for the Wii, since GEKKO - * platforms only support a 16:9 framebuffer width of - * 424 instead of the usual 426... */ + unsigned x_crop_offset; + unsigned y_crop_offset; /* Sanity check */ if (!image->pixels || -#if defined(GEKKO) - (image->width != ((rgui_background_buf.width == 424) ? - (rgui_background_buf.width + 2) : rgui_background_buf.width)) || -#else - (image->width != rgui_background_buf.width) || -#endif - (image->height != rgui_background_buf.height) || + (image->width < rgui_background_buf.width) || + (image->height < rgui_background_buf.height) || !rgui_background_buf.data) return; + /* In most cases, image size will be identical + * to wallpaper buffer size - but wallpaper buffer + * will be smaller than expected if: + * - This is a GEKKO platform (these only support + * a 16:9 framebuffer width of 424 instead of + * the usual 426...) + * - The current display resolution is less than + * 240p - in which case, the framebuffer will + * scale down to a minimum of 192p + * If the wallpaper buffer is undersized, we have + * to crop the source image */ + x_crop_offset = (image->width - rgui_background_buf.width) >> 1; + y_crop_offset = (image->height - rgui_background_buf.height) >> 1; + /* Copy image to wallpaper buffer, performing pixel format conversion */ for (x = 0; x < rgui_background_buf.width; x++) { for (y = 0; y < rgui_background_buf.height; y++) { rgui_background_buf.data[x + (y * rgui_background_buf.width)] = -#if defined(GEKKO) - argb32_to_pixel_platform_format(image->pixels[ - x + ((rgui_background_buf.width == 424) ? 1 : 0) + - (y * image->width)]); -#else - argb32_to_pixel_platform_format(image->pixels[x + (y * rgui_background_buf.width)]); -#endif + argb32_to_pixel_platform_format(image->pixels[ + (x + x_crop_offset) + + ((y + y_crop_offset) * image->width)]); } } From d9673b8c8fd86d8e2fdcfac503e3da2cd53af6e3 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Thu, 14 May 2020 17:27:13 +0100 Subject: [PATCH 082/192] Disable 'Use Global Core Options File' by default --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index ce38c83a6f..0a4c88f426 100644 --- a/config.def.h +++ b/config.def.h @@ -614,7 +614,7 @@ static const bool rgui_extended_ascii = false; static const bool default_game_specific_options = true; static const bool default_auto_overrides_enable = true; static const bool default_auto_remaps_enable = true; -static const bool default_global_core_options = true; +static const bool default_global_core_options = false; static const bool default_auto_shaders_enable = true; static const bool default_sort_savefiles_enable = false; From 82666abbddb7023a25cb26cbb63ec756d51fcdec Mon Sep 17 00:00:00 2001 From: Autechre Date: Thu, 14 May 2020 19:42:38 +0200 Subject: [PATCH 083/192] Update CHANGES.md --- CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 74ef86167b..b4d8bf1dba 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,13 +2,17 @@ - 3DS: Add IDs for Frodo - 3DS: Enable basic networking / cheevos - CHEEVOS/BUGFIX: Opening achievements list would crash RetroArch with badges enabled (on new games) +- CORE OPTIONS: Disable 'Use Global Core Options File' by default - DOS/DJGPP: Add 32bit color support for cores - GLCORE: Switch to glcore video driver when requested by a core - LINUX/XDG: Use GenericName correctly in desktop entry - MAC/COCOA: Fix mouse cursor tracking - MENU/MATERIALUI: Add desktop-style playlist view mode - MENU/MATERIALUI/DESKTOPVIEW: When scrolling playlists, show last selected thumbnails while waiting for next entry to load +- MENU/MATERIALUI: Limit tab switch rate when input repeat is active - MENU/RGUI: Adjusted menu defaults, adjusted default scrolling speed +- MENU/RGUI: Enable custom wallpaper when menu size is reduced at low resolutions +- MENU/XMB: Limit tab switch rate when input repeat is active - NETPLAY: Fix regressions introduced in 1.8.5 - RGUI: Add option to always stretch menu to fill the screen - WIIU: Enable graphics widgets From 706875160e54d1b33abc685f7d885cc27807994d Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Fri, 15 May 2020 13:33:05 +0100 Subject: [PATCH 084/192] Don't perform unnecessary cheevos initialisation when cheevos are disabled --- cheevos-new/cheevos.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cheevos-new/cheevos.c b/cheevos-new/cheevos.c index 5ce829c547..b185579258 100644 --- a/cheevos-new/cheevos.c +++ b/cheevos-new/cheevos.c @@ -2921,11 +2921,13 @@ bool rcheevos_load(const void *data) retro_task_t *task = NULL; const struct retro_game_info *info = NULL; rcheevos_coro_t *coro = NULL; + settings_t *settings = config_get_ptr(); + bool cheevos_enable = settings && settings->bools.cheevos_enable; rcheevos_loaded = false; rcheevos_hardcore_paused = false; - if (!rcheevos_locals.core_supports || !data) + if (!cheevos_enable || !rcheevos_locals.core_supports || !data) { rcheevos_hardcore_paused = true; return false; From b53f635441b411fce7328cec61b0fe35ec3c7071 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Fri, 15 May 2020 17:26:36 +0100 Subject: [PATCH 085/192] (Ozone) Fix sidebar playlist sort order when 'Truncate Playlist Names' is enabled --- menu/drivers/ozone/ozone_sidebar.c | 128 ++++++++++++++++++----------- 1 file changed, 82 insertions(+), 46 deletions(-) diff --git a/menu/drivers/ozone/ozone_sidebar.c b/menu/drivers/ozone/ozone_sidebar.c index c30e5f2865..367643f8e2 100644 --- a/menu/drivers/ozone/ozone_sidebar.c +++ b/menu/drivers/ozone/ozone_sidebar.c @@ -716,9 +716,13 @@ void ozone_change_tab(ozone_handle_t *ozone, void ozone_init_horizontal_list(ozone_handle_t *ozone) { menu_displaylist_info_t info; - settings_t *settings = config_get_ptr(); - const char *dir_playlist = settings->paths.directory_playlist; - bool menu_content_show_playlists = settings->bools.menu_content_show_playlists; + size_t list_size; + size_t i; + settings_t *settings = config_get_ptr(); + const char *dir_playlist = settings->paths.directory_playlist; + bool menu_content_show_playlists = settings->bools.menu_content_show_playlists; + bool ozone_truncate_playlist_name = settings->bools.ozone_truncate_playlist_name; + menu_displaylist_info_init(&info); info.list = ozone->horizontal_list; @@ -736,6 +740,70 @@ void ozone_init_horizontal_list(ozone_handle_t *ozone) } menu_displaylist_info_free(&info); + + /* Loop through list and set console names */ + list_size = ozone_list_get_size(ozone, MENU_LIST_HORIZONTAL); + + for (i = 0; i < list_size; i++) + { + const char *playlist_file = NULL; + char *console_name = NULL; + char playlist_file_noext[255]; + + playlist_file_noext[0] = '\0'; + + /* Get playlist file name */ + file_list_get_at_offset(ozone->horizontal_list, i, + &playlist_file, NULL, NULL, NULL); + + if (!playlist_file) + { + file_list_set_alt_at_offset(ozone->horizontal_list, i, NULL); + continue; + } + + /* Remove extension */ + fill_pathname_base_noext(playlist_file_noext, + playlist_file, sizeof(playlist_file_noext)); + + console_name = playlist_file_noext; + + /* Truncate playlist names, if required + * > Format: "Vendor - Console" + Remove everything before the hyphen + and the subsequent space */ + if (ozone_truncate_playlist_name) + { + bool hyphen_found = false; + + for (;;) + { + /* Check for "- " */ + if (*console_name == '\0') + break; + else if (*console_name == '-' && *(console_name + 1) == ' ') + { + hyphen_found = true; + break; + } + + console_name++; + } + + if (hyphen_found) + console_name += 2; + else + console_name = playlist_file_noext; + } + + /* Assign console name to list */ + file_list_set_alt_at_offset(ozone->horizontal_list, i, console_name); + } + + /* If playlist names were truncated, re-sort list + * by console name */ + if (ozone_truncate_playlist_name && (list_size > 0)) + file_list_sort_on_alt(ozone->horizontal_list); } void ozone_refresh_horizontal_list(ozone_handle_t *ozone) @@ -762,17 +830,13 @@ void ozone_refresh_horizontal_list(ozone_handle_t *ozone) void ozone_context_reset_horizontal_list(ozone_handle_t *ozone) { unsigned i; - const char *title; - char title_noext[255]; - char *console_name = NULL; - settings_t *settings = config_get_ptr(); - bool ozone_truncate_playlist_name = settings->bools.ozone_truncate_playlist_name; - size_t list_size = ozone_list_get_size(ozone, MENU_LIST_HORIZONTAL); + size_t list_size = ozone_list_get_size(ozone, MENU_LIST_HORIZONTAL); for (i = 0; i < list_size; i++) { - const char *path = NULL; - ozone_node_t *node = (ozone_node_t*)file_list_get_userdata_at_offset(ozone->horizontal_list, i); + const char *path = NULL; + const char *console_name = NULL; + ozone_node_t *node = (ozone_node_t*)file_list_get_userdata_at_offset(ozone->horizontal_list, i); if (!node) { @@ -868,45 +932,17 @@ void ozone_context_reset_horizontal_list(ozone_handle_t *ozone) /* Console name */ menu_entries_get_at_offset( - ozone->horizontal_list, - i, - &title, NULL, NULL, NULL, NULL); - - fill_pathname_base_noext(title_noext, title, sizeof(title_noext)); - - console_name = title_noext; - - /* Format : "Vendor - Console" - Remove everything before the hyphen - and the subsequent space */ - if (ozone_truncate_playlist_name) - { - bool hyphen_found = false; - - for (;;) - { - /* Check for "- " */ - if (*console_name == '-' && *(console_name + 1) == ' ') - { - hyphen_found = true; - break; - } - else if (*console_name == '\0') - break; - - console_name++; - } - - if (hyphen_found) - console_name += 2; - else - console_name = title_noext; - } + ozone->horizontal_list, i, + NULL, NULL, NULL, NULL, &console_name); if (node->console_name) free(node->console_name); - node->console_name = strdup(console_name); + /* Note: console_name will *always* be valid here, + * but provide a fallback to prevent NULL pointer + * dereferencing in case of unknown errors... */ + node->console_name = strdup( + console_name ? console_name : path); free(sysname); free(texturepath); From 69949187f67f7b60a82cf133b1feb97224858340 Mon Sep 17 00:00:00 2001 From: meleu Date: Fri, 15 May 2020 11:00:48 -0300 Subject: [PATCH 086/192] add cheevos_start_active option --- cheevos-new/cheevos.c | 35 ++++++++++++++++++++------ configuration.c | 7 +++--- configuration.h | 1 + intl/msg_hash_lbl.h | 4 +++ intl/msg_hash_us.h | 8 ++++++ menu/cbs/menu_cbs_sublabel.c | 10 +++++--- menu/menu_displaylist.c | 49 ++++++++++++++++++------------------ menu/menu_setting.c | 20 +++++++++++++-- msg_hash.h | 1 + retroarch.cfg | 10 +++++--- 10 files changed, 102 insertions(+), 43 deletions(-) diff --git a/cheevos-new/cheevos.c b/cheevos-new/cheevos.c index b185579258..51c076a582 100644 --- a/cheevos-new/cheevos.c +++ b/cheevos-new/cheevos.c @@ -1552,7 +1552,7 @@ static int rcheevos_prepare_hash_psx(rcheevos_coro_t* coro) /* find the data track - it should be the first one */ coro->track = cdfs_open_data_track(coro->path); - + if (!coro->track) { CHEEVOS_LOG(RCHEEVOS_TAG "could not open CD\n"); @@ -1991,7 +1991,8 @@ found: * Inputs: CHEEVOS_VAR_GAMEID * Outputs: */ - CORO_GOSUB(RCHEEVOS_DEACTIVATE); + if (!coro->settings->bools.cheevos_start_active) + CORO_GOSUB(RCHEEVOS_DEACTIVATE); /* * Inputs: CHEEVOS_VAR_GAMEID @@ -2021,15 +2022,33 @@ found: if (!number_of_unsupported) { - snprintf(msg, sizeof(msg), - "You have %d of %d achievements unlocked.", - number_of_unlocked, rcheevos_locals.patchdata.core_count); + if (coro->settings->bools.cheevos_start_active) { + snprintf(msg, sizeof(msg), + "All %d achievements activated for this session.", + rcheevos_locals.patchdata.core_count); + } + else + { + snprintf(msg, sizeof(msg), + "You have %d of %d achievements unlocked.", + number_of_unlocked, rcheevos_locals.patchdata.core_count); + } } else { - snprintf(msg, sizeof(msg), - "You have %d of %d achievements unlocked (%d unsupported).", - number_of_unlocked - number_of_unsupported, rcheevos_locals.patchdata.core_count, number_of_unsupported); + if (coro->settings->bools.cheevos_start_active) { + snprintf(msg, sizeof(msg), + "All %d achievements activated for this session (%d unsupported).", + rcheevos_locals.patchdata.core_count, + number_of_unsupported); + } + else{ + snprintf(msg, sizeof(msg), + "You have %d of %d achievements unlocked (%d unsupported).", + number_of_unlocked - number_of_unsupported, + rcheevos_locals.patchdata.core_count, + number_of_unsupported); + } } msg[sizeof(msg) - 1] = 0; diff --git a/configuration.c b/configuration.c index 34dac4fd8c..7299146e05 100644 --- a/configuration.c +++ b/configuration.c @@ -332,7 +332,7 @@ static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_XENON360; #elif defined(HAVE_D3D11) static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_D3D11; #elif defined(HAVE_D3D12) -/* FIXME/WARNING: DX12 performance on Xbox is horrible for +/* FIXME/WARNING: DX12 performance on Xbox is horrible for * some reason. For now, we will default to D3D11 when possible. */ static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_D3D12; #elif defined(HAVE_D3D10) @@ -1588,6 +1588,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, SETTING_BOOL("cheevos_verbose_enable", &settings->bools.cheevos_verbose_enable, true, false, false); SETTING_BOOL("cheevos_auto_screenshot", &settings->bools.cheevos_auto_screenshot, true, false, false); SETTING_BOOL("cheevos_badges_enable", &settings->bools.cheevos_badges_enable, true, false, false); + SETTING_BOOL("cheevos_start_active", &settings->bools.cheevos_start_active, true, false, false); #endif #ifdef HAVE_OVERLAY SETTING_BOOL("input_overlay_enable", &settings->bools.input_overlay_enable, true, config_overlay_enable_default(), false); @@ -2674,7 +2675,7 @@ static config_file_t *open_default_config_file(void) skeleton_conf[0] = '\0'; - /* Build a retroarch.cfg path from the + /* Build a retroarch.cfg path from the * global config directory (/etc). */ fill_pathname_join(skeleton_conf, GLOBAL_CONFIG_DIR, file_path_str(FILE_PATH_MAIN_CONFIG), path_size); @@ -2689,7 +2690,7 @@ static config_file_t *open_default_config_file(void) if (conf) { - /* Since this is a clean config file, we can + /* 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, true); diff --git a/configuration.h b/configuration.h index 0363cb7121..fb24ef8c40 100644 --- a/configuration.h +++ b/configuration.h @@ -304,6 +304,7 @@ typedef struct settings bool cheevos_badges_enable; bool cheevos_verbose_enable; bool cheevos_auto_screenshot; + bool cheevos_start_active; /* Camera */ bool camera_allow; diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index b14c5e66f3..ce3db58484 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -368,6 +368,10 @@ MSG_HASH( MENU_ENUM_LABEL_CHEEVOS_AUTO_SCREENSHOT, "cheevos_auto_screenshot" ) +MSG_HASH( + MENU_ENUM_LABEL_CHEEVOS_START_ACTIVE, + "cheevos_start_active" + ) MSG_HASH( MENU_ENUM_LABEL_CLOSE_CONTENT, "unload_core" diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 0af56c7a4d..422999fc8d 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -4155,6 +4155,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_CHEEVOS_AUTO_SCREENSHOT, "Automatically take a screenshot when an achievement is triggered." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEEVOS_START_ACTIVE, + "Start Active" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_CHEEVOS_START_ACTIVE, + "Start the session with all achievements active (even the ones you previously unlocked)." + ) /* Settings > Network */ diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 6aff97f596..6c8e8ab826 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -169,6 +169,7 @@ default_sublabel_macro(action_bind_sublabel_cheevos_richpresence_enable, MENU_ default_sublabel_macro(action_bind_sublabel_cheevos_badges_enable, MENU_ENUM_SUBLABEL_CHEEVOS_BADGES_ENABLE) default_sublabel_macro(action_bind_sublabel_cheevos_verbose_enable, MENU_ENUM_SUBLABEL_CHEEVOS_VERBOSE_ENABLE) default_sublabel_macro(action_bind_sublabel_cheevos_auto_screenshot, MENU_ENUM_SUBLABEL_CHEEVOS_AUTO_SCREENSHOT) +default_sublabel_macro(action_bind_sublabel_cheevos_start_active, MENU_ENUM_SUBLABEL_CHEEVOS_START_ACTIVE) default_sublabel_macro(action_bind_sublabel_menu_views_settings_list, MENU_ENUM_SUBLABEL_MENU_VIEWS_SETTINGS) default_sublabel_macro(action_bind_sublabel_quick_menu_views_settings_list, MENU_ENUM_SUBLABEL_QUICK_MENU_VIEWS_SETTINGS) default_sublabel_macro(action_bind_sublabel_settings_views_settings_list, MENU_ENUM_SUBLABEL_SETTINGS_VIEWS_SETTINGS) @@ -1111,14 +1112,14 @@ static int action_bind_sublabel_playlist_entry( /* Only add sublabel if a core is currently assigned * > Both core name and core path must be valid */ - if ( string_is_empty(entry->core_name) || + if ( string_is_empty(entry->core_name) || string_is_equal(entry->core_name, "DETECT") || string_is_empty(entry->core_path) || string_is_equal(entry->core_path, "DETECT")) return 0; /* Add core name */ - strlcpy(s, + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_CORE), len); strlcat(s, " ", len); strlcat(s, entry->core_name, len); @@ -1224,7 +1225,7 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, info_range_list_t info_list[] = { { MENU_SETTINGS_INPUT_DESC_KBD_BEGIN, - MENU_SETTINGS_INPUT_DESC_KBD_END, + MENU_SETTINGS_INPUT_DESC_KBD_END, action_bind_sublabel_remap_kbd_sublabel }, #ifdef HAVE_AUDIOMIXER @@ -2746,6 +2747,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_CHEEVOS_AUTO_SCREENSHOT: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_cheevos_auto_screenshot); break; + case MENU_ENUM_LABEL_CHEEVOS_START_ACTIVE: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_cheevos_start_active); + break; case MENU_ENUM_LABEL_SETTINGS: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_settings); break; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 3c9e5815f0..6fcd6cc379 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -101,7 +101,7 @@ #include "../runtime_file.h" #include "../manual_content_scan.h" -/* TODO/FIXME - globals - need to find a way to +/* TODO/FIXME - globals - need to find a way to * get rid of these */ static char new_path_entry[4096] = {0}; static char new_lbl_entry[4096] = {0}; @@ -2259,7 +2259,7 @@ static int menu_displaylist_parse_horizontal_content_actions( MENU_ENUM_LABEL_ADD_TO_FAVORITES_PLAYLIST, FILE_TYPE_PLAYLIST_ENTRY, 0, 0); } - if ( settings->bools.quick_menu_show_set_core_association && + if ( settings->bools.quick_menu_show_set_core_association && !settings->bools.kiosk_mode_enable) { menu_entries_append_enum(info->list, @@ -2269,7 +2269,7 @@ static int menu_displaylist_parse_horizontal_content_actions( } if ( - settings->bools.quick_menu_show_reset_core_association && + settings->bools.quick_menu_show_reset_core_association && !settings->bools.kiosk_mode_enable) { menu_entries_append_enum(info->list, @@ -2289,7 +2289,7 @@ static int menu_displaylist_parse_horizontal_content_actions( #ifdef HAVE_NETWORKING if ( - settings->bools.quick_menu_show_download_thumbnails && + settings->bools.quick_menu_show_download_thumbnails && !settings->bools.kiosk_mode_enable) { bool download_enabled = true; @@ -2321,7 +2321,7 @@ static int menu_displaylist_parse_horizontal_content_actions( !string_is_equal(system, "music_history") && !string_is_equal(system, "video_history"); } - + if (settings->bools.network_on_demand_thumbnails) download_enabled = false; @@ -4068,13 +4068,13 @@ static unsigned menu_displaylist_populate_subsystem( unsigned i = 0; int n = 0; bool is_rgui = string_is_equal(menu_driver, "rgui"); - + /* Select appropriate 'star' marker for subsystem menu entries * (i.e. RGUI does not support unicode, so use a 'standard' * character fallback) */ snprintf(star_char, sizeof(star_char), "%s", is_rgui ? "*" : utf8_star_char); - + if (menu_displaylist_has_subsystems()) { for (i = 0; i < subsystem_current_count; i++, subsystem++) @@ -4088,13 +4088,13 @@ static unsigned menu_displaylist_populate_subsystem( "Load %s %s", subsystem->desc, star_char); - + /* If using RGUI with sublabels disabled, add the * appropriate text to the menu entry itself... */ if (is_rgui && !menu_show_sublabels) { char tmp[PATH_MAX_LENGTH]; - + n = snprintf(tmp, sizeof(tmp), "%s [%s %s]", s, "Current Content:", subsystem->roms[content_get_subsystem_rom_id()].desc); @@ -4121,7 +4121,7 @@ static unsigned menu_displaylist_populate_subsystem( strlcpy(s, tmp, sizeof(s)); } - + if (menu_entries_append_enum(list, s, msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_ADD), @@ -4135,7 +4135,7 @@ static unsigned menu_displaylist_populate_subsystem( "Start %s %s", subsystem->desc, star_char); - + /* If using RGUI with sublabels disabled, add the * appropriate text to the menu entry itself... */ if (is_rgui && !menu_show_sublabels) @@ -4156,7 +4156,7 @@ static unsigned menu_displaylist_populate_subsystem( if (!string_is_empty(rom_buff)) { n = snprintf(tmp, sizeof(tmp), "%s [%s]", s, rom_buff); - + /* More snprintf() gcc warning suppression... */ if ((n < 0) || (n >= PATH_MAX_LENGTH)) { @@ -4165,11 +4165,11 @@ static unsigned menu_displaylist_populate_subsystem( RARCH_WARN("Menu subsystem entry: Description label truncated.\n"); } } - + strlcpy(s, tmp, sizeof(s)); } } - + if (menu_entries_append_enum(list, s, msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_LOAD), @@ -4183,7 +4183,7 @@ static unsigned menu_displaylist_populate_subsystem( snprintf(s, sizeof(s), "Load %s", subsystem->desc); - + /* If using RGUI with sublabels disabled, add the * appropriate text to the menu entry itself... */ if (is_rgui && !menu_show_sublabels) @@ -4194,11 +4194,11 @@ static unsigned menu_displaylist_populate_subsystem( if (subsystem->num_roms > 0) { char tmp[PATH_MAX_LENGTH]; - + n = snprintf(tmp, sizeof(tmp), "%s [%s %s]", s, "Current Content:", subsystem->roms[0].desc); - + /* More snprintf() gcc warning suppression... */ if ((n < 0) || (n >= PATH_MAX_LENGTH)) { @@ -4211,7 +4211,7 @@ static unsigned menu_displaylist_populate_subsystem( strlcpy(s, tmp, sizeof(s)); } } - + if (menu_entries_append_enum(list, s, msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_ADD), @@ -4238,7 +4238,7 @@ unsigned menu_displaylist_build_list( case DISPLAYLIST_SUBSYSTEM_SETTINGS_LIST: { const struct retro_subsystem_info* subsystem = subsystem_data; - rarch_system_info_t *sys_info = + rarch_system_info_t *sys_info = runloop_get_system_info(); /* Core not loaded completely, use the data we * peeked on load core */ @@ -5490,12 +5490,12 @@ unsigned menu_displaylist_build_list( bool show_hidden_files = settings->bools.show_hidden_files; #ifdef HAVE_LIBRETRODB const char *path_content_database = settings->paths.path_content_database; - struct string_list *system_name_list = + struct string_list *system_name_list = manual_content_scan_get_menu_system_name_list( path_content_database, show_hidden_files); #else - struct string_list *system_name_list = + struct string_list *system_name_list = manual_content_scan_get_menu_system_name_list(NULL, show_hidden_files); #endif @@ -5540,7 +5540,7 @@ unsigned menu_displaylist_build_list( case DISPLAYLIST_DROPDOWN_LIST_MANUAL_CONTENT_SCAN_CORE_NAME: { /* Get core name list */ - struct string_list *core_name_list = + struct string_list *core_name_list = manual_content_scan_get_menu_core_name_list(); if (core_name_list) @@ -6075,6 +6075,7 @@ unsigned menu_displaylist_build_list( {MENU_ENUM_LABEL_CHEEVOS_TEST_UNOFFICIAL, PARSE_ONLY_BOOL, false }, {MENU_ENUM_LABEL_CHEEVOS_VERBOSE_ENABLE, PARSE_ONLY_BOOL, false }, {MENU_ENUM_LABEL_CHEEVOS_AUTO_SCREENSHOT, PARSE_ONLY_BOOL, false }, + {MENU_ENUM_LABEL_CHEEVOS_START_ACTIVE, PARSE_ONLY_BOOL, false }, }; for (i = 0; i < ARRAY_SIZE(build_list); i++) @@ -6677,7 +6678,7 @@ unsigned menu_displaylist_build_list( count++; } } - + { settings_t *settings = config_get_ptr(); bool runahead_enabled = settings->bools.run_ahead_enabled; @@ -7738,7 +7739,7 @@ unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list) bool menu_displaylist_has_subsystems(void) { const struct retro_subsystem_info* subsystem = subsystem_data; - rarch_system_info_t *sys_info = + rarch_system_info_t *sys_info = runloop_get_system_info(); /* Core not loaded completely, use the data we * peeked on load core */ diff --git a/menu/menu_setting.c b/menu/menu_setting.c index d0cd342925..6f92962843 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -2581,7 +2581,7 @@ static int setting_action_ok_bind_all_save_autoconfig(rarch_setting_t *setting, index_offset = setting->index_offset; name = input_config_get_device_name(index_offset); - if (!string_is_empty(name) && + if (!string_is_empty(name) && config_save_autoconf_profile(name, index_offset)) runloop_msg_queue_push( msg_hash_to_str(MSG_AUTOCONFIG_FILE_SAVED_SUCCESSFULLY), 1, 100, true, @@ -7135,7 +7135,7 @@ static void change_handler_video_layout_enable(rarch_setting_t *setting) static void change_handler_video_layout_path(rarch_setting_t *setting) { settings_t *settings = config_get_ptr(); - configuration_set_uint(settings, + configuration_set_uint(settings, settings->uints.video_layout_selected_view, 0); video_layout_load(setting->value.target.string); @@ -15936,6 +15936,22 @@ static bool setting_append_list( SD_FLAG_NONE ); + CONFIG_BOOL( + list, list_info, + &settings->bools.cheevos_start_active, + MENU_ENUM_LABEL_CHEEVOS_START_ACTIVE, + MENU_ENUM_LABEL_VALUE_CHEEVOS_START_ACTIVE, + false, + MENU_ENUM_LABEL_VALUE_OFF, + MENU_ENUM_LABEL_VALUE_ON, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler, + SD_FLAG_NONE + ); + CONFIG_BOOL( list, list_info, &settings->bools.cheevos_hardcore_mode_enable, diff --git a/msg_hash.h b/msg_hash.h index e489f3e457..8c0f065e02 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1238,6 +1238,7 @@ enum msg_hash_enums MENU_LABEL(CHEEVOS_TEST_UNOFFICIAL), MENU_LABEL(CHEEVOS_VERBOSE_ENABLE), MENU_LABEL(CHEEVOS_AUTO_SCREENSHOT), + MENU_LABEL(CHEEVOS_START_ACTIVE), MENU_LABEL(CHEEVOS_ENABLE), MENU_LABEL(CHEEVOS_DESCRIPTION), MENU_LABEL(ACCOUNTS_RETRO_ACHIEVEMENTS), diff --git a/retroarch.cfg b/retroarch.cfg index 2f20ebe700..07eccebafa 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -851,8 +851,8 @@ # cheevos_enable = false # RetroAchievements.org credentials. -# cheevos_username = -# cheevos_password = +# cheevos_username = +# cheevos_password = # The hardcore mode disables savestates and cheating features, but it # makes the achievements points double. @@ -875,7 +875,11 @@ # Send some messages to the RetroAchievements.org saying, for example, # where you are in the game, how many lives you have, your score, etc. -# cheevos_richpresence_enable = false +# cheevos_richpresence_enable = true + +# Even after unlocking achievements in previous sessions, you may still want +# to see them triggering in the current session. +# cheevos_start_active = false # Unnoficial achievements are used only for achievement creators and testers. # cheevos_test_unofficial = false From feb39a114da4c72d9b1f4492043343bb4306880c Mon Sep 17 00:00:00 2001 From: Autechre Date: Sat, 16 May 2020 15:18:51 +0200 Subject: [PATCH 087/192] Update CHANGES.md --- CHANGES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index b4d8bf1dba..6d8cdabd0c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,8 @@ - 3DS: Add IDs for Frodo - 3DS: Enable basic networking / cheevos - CHEEVOS/BUGFIX: Opening achievements list would crash RetroArch with badges enabled (on new games) +- CHEEVOS: Option to start a session with all achievements active +- CHEEVOS: Don't perform unnecessary cheevos initialisation when cheevos are disabled. Should reduce startup times when loading content. - CORE OPTIONS: Disable 'Use Global Core Options File' by default - DOS/DJGPP: Add 32bit color support for cores - GLCORE: Switch to glcore video driver when requested by a core @@ -10,6 +12,7 @@ - MENU/MATERIALUI: Add desktop-style playlist view mode - MENU/MATERIALUI/DESKTOPVIEW: When scrolling playlists, show last selected thumbnails while waiting for next entry to load - MENU/MATERIALUI: Limit tab switch rate when input repeat is active +- MENU/OZONE: Fix sidebar playlist sort order when 'Truncate Playlist Names' is enabled - MENU/RGUI: Adjusted menu defaults, adjusted default scrolling speed - MENU/RGUI: Enable custom wallpaper when menu size is reduced at low resolutions - MENU/XMB: Limit tab switch rate when input repeat is active From 8c2c09483041eab20a4087689944e21961483f23 Mon Sep 17 00:00:00 2001 From: Autechre Date: Sat, 16 May 2020 15:19:02 +0200 Subject: [PATCH 088/192] Update CHANGES.md --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 6d8cdabd0c..ecda19d4fa 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,6 @@ # Future + +# 1.8.7 - 3DS: Add IDs for Frodo - 3DS: Enable basic networking / cheevos - CHEEVOS/BUGFIX: Opening achievements list would crash RetroArch with badges enabled (on new games) From 435af0f982c39ae1cd0c72ab9d38b7dcb39e5be2 Mon Sep 17 00:00:00 2001 From: Autechre Date: Sat, 16 May 2020 15:19:31 +0200 Subject: [PATCH 089/192] Update version.all --- version.all | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.all b/version.all index 86160727e5..d3f969e78b 100644 --- a/version.all +++ b/version.all @@ -6,8 +6,8 @@ # /* - pkg/snap/snapcraft.yaml (including the github url) */ #if 0 -RARCH_VERSION="1.8.6" +RARCH_VERSION="1.8.7" #endif #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "1.8.6" +#define PACKAGE_VERSION "1.8.7" #endif From b0a549716f27f7cf8151448e77cd0f156db21910 Mon Sep 17 00:00:00 2001 From: Autechre Date: Sat, 16 May 2020 15:19:53 +0200 Subject: [PATCH 090/192] Update version.dtd --- version.dtd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.dtd b/version.dtd index 4f84e6f78e..cc41a6ccd1 100644 --- a/version.dtd +++ b/version.dtd @@ -1 +1 @@ - + From ef9a3c20070ebf41e4376e4bc0a2a401d4e3a8ee Mon Sep 17 00:00:00 2001 From: Autechre Date: Sat, 16 May 2020 15:20:15 +0200 Subject: [PATCH 091/192] Update AndroidManifest.xml --- pkg/android/phoenix/AndroidManifest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/android/phoenix/AndroidManifest.xml b/pkg/android/phoenix/AndroidManifest.xml index 9a89473b94..e4761b6249 100644 --- a/pkg/android/phoenix/AndroidManifest.xml +++ b/pkg/android/phoenix/AndroidManifest.xml @@ -2,8 +2,8 @@ From a8d8523747229646bf78f89a05a36416af6e3e0f Mon Sep 17 00:00:00 2001 From: Autechre Date: Sat, 16 May 2020 15:20:52 +0200 Subject: [PATCH 092/192] Update Info.plist --- pkg/apple/OSX/Info.plist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/apple/OSX/Info.plist b/pkg/apple/OSX/Info.plist index 847449029d..8528918a03 100644 --- a/pkg/apple/OSX/Info.plist +++ b/pkg/apple/OSX/Info.plist @@ -30,11 +30,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.8.6 + 1.8.7 CFBundleSignature ???? CFBundleVersion - 1.8.6 + 1.8.7 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHighResolutionCapable From fb073544d23efd5adfccfa4c6bef460828c90f3b Mon Sep 17 00:00:00 2001 From: Autechre Date: Sat, 16 May 2020 15:21:05 +0200 Subject: [PATCH 093/192] Update Info_Metal.plist --- pkg/apple/OSX/Info_Metal.plist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/apple/OSX/Info_Metal.plist b/pkg/apple/OSX/Info_Metal.plist index 0af2d04866..7afa805a9d 100644 --- a/pkg/apple/OSX/Info_Metal.plist +++ b/pkg/apple/OSX/Info_Metal.plist @@ -30,11 +30,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.8.6 + 1.8.7 CFBundleSignature ???? CFBundleVersion - 1.8.6 + 1.8.7 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHighResolutionCapable From f1158b988c7eb26e2da3be11dd7563ff29e3c07a Mon Sep 17 00:00:00 2001 From: Autechre Date: Sat, 16 May 2020 15:22:20 +0200 Subject: [PATCH 094/192] Update RetroArch_iOS9-Info.plist --- pkg/apple/RetroArch_iOS9-Info.plist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/apple/RetroArch_iOS9-Info.plist b/pkg/apple/RetroArch_iOS9-Info.plist index 2820d4e4f8..d89a467b5f 100644 --- a/pkg/apple/RetroArch_iOS9-Info.plist +++ b/pkg/apple/RetroArch_iOS9-Info.plist @@ -33,11 +33,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.8.6 + 1.8.7 CFBundleSignature ???? CFBundleVersion - 1.8.6 + 1.8.7 LSRequiresIPhoneOS UIApplicationExitsOnSuspend From 6946f878ef7d08f465ded5bd26c03e6444f5b70e Mon Sep 17 00:00:00 2001 From: Jamiras Date: Sat, 16 May 2020 08:01:24 -0600 Subject: [PATCH 095/192] disable hardcore when cheats are enabled --- cheevos-new/cheevos.c | 15 ++------------- cheevos-new/cheevos.h | 6 +----- intl/msg_hash_us.h | 6 +++++- managers/cheat_manager.c | 28 ++++++++++++++++++++++------ msg_hash.h | 1 + retroarch.c | 8 +------- tasks/task_content.c | 2 -- 7 files changed, 32 insertions(+), 34 deletions(-) diff --git a/cheevos-new/cheevos.c b/cheevos-new/cheevos.c index 51c076a582..0b5d7d836f 100644 --- a/cheevos-new/cheevos.c +++ b/cheevos-new/cheevos.c @@ -207,8 +207,6 @@ bool rcheevos_loaded = false; bool rcheevos_hardcore_active = false; bool rcheevos_hardcore_paused = false; bool rcheevos_state_loaded_flag = false; -int rcheevos_cheats_are_enabled = 0; -int rcheevos_cheats_were_enabled = 0; char rcheevos_user_agent_prefix[128] = ""; #ifdef HAVE_THREADS @@ -1269,12 +1267,9 @@ bool rcheevos_get_description(rcheevos_ctx_desc_t* desc) return true; } -bool rcheevos_apply_cheats(bool* data_bool) +void rcheevos_pause_hardcore() { - rcheevos_cheats_are_enabled = *data_bool; - rcheevos_cheats_were_enabled |= rcheevos_cheats_are_enabled; - - return true; + rcheevos_hardcore_paused = true; } bool rcheevos_unload(void) @@ -1398,12 +1393,6 @@ void rcheevos_test(void) } } -bool rcheevos_set_cheats(void) -{ - rcheevos_cheats_were_enabled = rcheevos_cheats_are_enabled; - return true; -} - void rcheevos_set_support_cheevos(bool state) { rcheevos_locals.core_supports = state; diff --git a/cheevos-new/cheevos.h b/cheevos-new/cheevos.h index 952a760436..b1096be9a5 100644 --- a/cheevos-new/cheevos.h +++ b/cheevos-new/cheevos.h @@ -49,7 +49,7 @@ void rcheevos_get_achievement_state(unsigned index, char* buffer, size_t buffer_ bool rcheevos_get_description(rcheevos_ctx_desc_t *desc); -bool rcheevos_apply_cheats(bool *data_bool); +void rcheevos_pause_hardcore(); bool rcheevos_unload(void); @@ -57,8 +57,6 @@ bool rcheevos_toggle_hardcore_mode(void); void rcheevos_test(void); -bool rcheevos_set_cheats(void); - void rcheevos_set_support_cheevos(bool state); bool rcheevos_get_support_cheevos(void); @@ -73,8 +71,6 @@ extern bool rcheevos_loaded; extern bool rcheevos_hardcore_active; extern bool rcheevos_hardcore_paused; extern bool rcheevos_state_loaded_flag; -extern int rcheevos_cheats_are_enabled; -extern int rcheevos_cheats_were_enabled; RETRO_END_DECLS diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 422999fc8d..201866f33d 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -10583,7 +10583,11 @@ MSG_HASH( ) MSG_HASH( MSG_CHEEVOS_HARDCORE_MODE_DISABLED, - "A save state was loaded, Achievements Hardcore Mode disabled for the current session. Restart to enable hardcore mode." + "A save state was loaded. Achievements Hardcore Mode disabled for the current session. Restart to enable hardcore mode." + ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT, + "A cheat was activated. Achievements Hardcore Mode disabled for the current session. Disable cheats and restart to enable hardcore mode." ) MSG_HASH( MSG_RESAMPLER_QUALITY_LOWEST, diff --git a/managers/cheat_manager.c b/managers/cheat_manager.c index a00649e306..b7209c818e 100644 --- a/managers/cheat_manager.c +++ b/managers/cheat_manager.c @@ -61,12 +61,21 @@ unsigned cheat_manager_get_size(void) return cheat_manager_state.size; } +#ifdef HAVE_CHEEVOS +static void cheat_manager_pause_cheevos() +{ + if (rcheevos_hardcore_active && rcheevos_loaded && !rcheevos_hardcore_paused) + { + rcheevos_pause_hardcore(); + + runloop_msg_queue_push(msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + RARCH_LOG("%s\n", msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT)); + } +} +#endif + void cheat_manager_apply_cheats(void) { -#ifdef HAVE_CHEEVOS - bool data_bool = false; - -#endif unsigned i, idx = 0; if (!cheat_manager_state.cheats) @@ -96,8 +105,8 @@ void cheat_manager_apply_cheats(void) } #ifdef HAVE_CHEEVOS - data_bool = idx != 0; - rcheevos_apply_cheats(&data_bool); + if (idx != 0) + cheat_manager_pause_cheevos(); #endif } @@ -1318,6 +1327,7 @@ void cheat_manager_apply_retro_cheats(void) unsigned int bits = 8; unsigned int curr_val = 0; bool run_cheat = true; + bool cheat_applied = false; if ((!cheat_manager_state.cheats)) return; @@ -1407,6 +1417,7 @@ void cheat_manager_apply_retro_cheats(void) if (set_value) { + cheat_applied = true; for (repeat_iter = 1; repeat_iter <= cheat_manager_state.cheats[i].repeat_count; repeat_iter++) { switch (bytes_per_item) @@ -1495,6 +1506,11 @@ void cheat_manager_apply_retro_cheats(void) } } } + +#ifdef HAVE_CHEEVOS + if (cheat_applied) + cheat_manager_pause_cheevos(); +#endif } void cheat_manager_match_action(enum cheat_match_action_type match_action, unsigned int target_match_idx, unsigned int *address, unsigned int *address_mask, diff --git a/msg_hash.h b/msg_hash.h index 8c0f065e02..2b1564de57 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -2661,6 +2661,7 @@ enum msg_hash_enums MSG_CHEAT_SEARCH_ADD_MATCH_FAIL, MSG_CHEAT_SEARCH_DELETE_MATCH_SUCCESS, MSG_CHEEVOS_HARDCORE_MODE_DISABLED, + MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT, MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS, MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM, MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD, diff --git a/retroarch.c b/retroarch.c index 5543bd9ca5..4f2ec6f36f 100644 --- a/retroarch.c +++ b/retroarch.c @@ -7116,9 +7116,6 @@ bool command_event(enum event_command cmd, void *data) RARCH_LOG("%s.\n", msg_hash_to_str(MSG_RESET)); runloop_msg_queue_push(msg_hash_to_str(MSG_RESET), 1, 120, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); -#ifdef HAVE_CHEEVOS - rcheevos_set_cheats(); -#endif core_reset(); #ifdef HAVE_CHEEVOS rcheevos_reset_game(); @@ -29001,10 +28998,7 @@ int runloop_iterate(void) libretro_core_runtime_usec += rarch_core_runtime_tick(current_time); #ifdef HAVE_CHEEVOS - if ( settings->bools.cheevos_enable && - rcheevos_loaded && - (!rcheevos_cheats_are_enabled && !rcheevos_cheats_were_enabled) - ) + if (settings->bools.cheevos_enable && rcheevos_loaded) rcheevos_test(); #endif cheat_manager_apply_retro_cheats(); diff --git a/tasks/task_content.c b/tasks/task_content.c index 6846d4a688..077de9aa74 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -1077,8 +1077,6 @@ static bool content_file_load( const char *content_path = content->elems[0].data; enum rarch_content_type type = path_is_media_type(content_path); - rcheevos_set_cheats(); - if (type == RARCH_CONTENT_NONE && !string_is_empty(content_path)) rcheevos_load(info); else From 9107e5767c2c8bb55de0d22520bb8c6ae6e2ff91 Mon Sep 17 00:00:00 2001 From: Jamiras Date: Sat, 16 May 2020 09:28:13 -0600 Subject: [PATCH 096/192] make message less verbose --- intl/msg_hash_us.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 201866f33d..39294e8038 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -10583,11 +10583,11 @@ MSG_HASH( ) MSG_HASH( MSG_CHEEVOS_HARDCORE_MODE_DISABLED, - "A save state was loaded. Achievements Hardcore Mode disabled for the current session. Restart to enable hardcore mode." + "A save state was loaded. Achievements Hardcore Mode disabled for the current session." ) MSG_HASH( MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT, - "A cheat was activated. Achievements Hardcore Mode disabled for the current session. Disable cheats and restart to enable hardcore mode." + "A cheat was activated. Achievements Hardcore Mode disabled for the current session." ) MSG_HASH( MSG_RESAMPLER_QUALITY_LOWEST, From f22af81e7dae3aa8f0ba2bcbc0ce0300e7c28e28 Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Sun, 17 May 2020 16:32:51 +1000 Subject: [PATCH 097/192] (WiiU/wpad) Allow hotplugging Gamepad, support >1 channel --- input/drivers_joypad/wiiu/wpad_driver.c | 150 +++++++++++++++++++----- input/include/wiiu/input.h | 2 +- wiiu/include/wiiu/vpad.h | 5 + 3 files changed, 125 insertions(+), 32 deletions(-) diff --git a/input/drivers_joypad/wiiu/wpad_driver.c b/input/drivers_joypad/wiiu/wpad_driver.c index 1a755d92d9..1a6fb83d80 100644 --- a/input/drivers_joypad/wiiu/wpad_driver.c +++ b/input/drivers_joypad/wiiu/wpad_driver.c @@ -25,16 +25,80 @@ #define PANIC_BUTTON_MASK (VPAD_BUTTON_R | VPAD_BUTTON_L | VPAD_BUTTON_STICK_R | VPAD_BUTTON_STICK_L) -static bool wpad_ready = false; -static uint64_t button_state = 0; -static int16_t analog_state[3][2]; +typedef struct _drc_state drc_state; +struct _drc_state +{ + uint64_t button_state; + int16_t analog_state[3][2]; +}; +static drc_state gamepads[WIIU_GAMEPAD_CHANNELS] = { 0 }; + +#define WPAD_INVALID_CHANNEL -1 +static int channel_slot_map[WIIU_GAMEPAD_CHANNELS] = { WPAD_INVALID_CHANNEL, WPAD_INVALID_CHANNEL }; + +static VPADChan to_gamepad_channel(unsigned pad) { + unsigned i; + + for (i = 0; i < WIIU_GAMEPAD_CHANNELS; i++) { + if (channel_slot_map[i] == pad) { + return i; + } + } + + return WPAD_INVALID_CHANNEL; +} + +static void wpad_deregister(unsigned channel) { + unsigned slot; + + if (channel >= WIIU_GAMEPAD_CHANNELS) + return; + + /* See if Gamepad is already disconnected */ + if (channel_slot_map[channel] == WPAD_INVALID_CHANNEL) + return; + + /* Sanity check, about to use as unsigned */ + if (channel_slot_map[channel] < 0) { + channel_slot_map[channel] = WPAD_INVALID_CHANNEL; + return; + } + + slot = (unsigned)channel_slot_map[channel]; + if (slot >= MAX_USERS) + return; + + input_autoconfigure_disconnect(slot, wpad_driver.ident); + hid_instance.pad_list[slot].connected = false; + channel_slot_map[channel] = WPAD_INVALID_CHANNEL; +} + +static void wpad_register(unsigned channel) { + int slot; + + if (channel >= WIIU_GAMEPAD_CHANNELS) + return; + + /* Check if gamepad is already handled + Other checks not needed here - about to overwrite channel_slot_map entry*/ + if (channel_slot_map[channel] != WPAD_INVALID_CHANNEL) + return; + + slot = pad_connection_find_vacant_pad(hid_instance.pad_list); + if(slot < 0) + return; + + hid_instance.pad_list[slot].connected = true; + input_pad_connect(slot, &wpad_driver); + channel_slot_map[channel] = slot; +} static void update_button_state(uint64_t *state, uint32_t held_buttons) { *state = held_buttons & VPAD_MASK_BUTTONS; } -static void update_analog_state(int16_t state[3][2], VPADStatus *vpad) +static void update_analog_state(int16_t state[3][2], VPADStatus *vpad) { state[RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_X] = WIIU_READ_STICK(vpad->leftStick.x); state[RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_Y] = WIIU_READ_STICK(vpad->leftStick.y); @@ -51,11 +115,12 @@ static int16_t scale_touchpad(int16_t from_min, int16_t from_max, return (((value - from_min) * to_range) / from_range) + to_min; } -static void get_calibrated_point(VPADTouchData *point, struct video_viewport *viewport, VPADStatus *vpad) +static void get_calibrated_point(VPADTouchData *point, + struct video_viewport *viewport, VPADStatus *vpad, unsigned channel) { VPADTouchData calibrated720p = {0}; - VPADGetTPCalibratedPoint(PAD_GAMEPAD, &calibrated720p, &(vpad->tpNormal)); + VPADGetTPCalibratedPoint(channel, &calibrated720p, &(vpad->tpNormal)); point->x = scale_touchpad(12, 1268, 0, viewport->full_width, calibrated720p.x); point->y = scale_touchpad(12, 708, 0, viewport->full_height, calibrated720p.y); } @@ -88,9 +153,9 @@ static void apply_clamping(VPADTouchData *point, struct video_viewport *viewport } static void get_touch_coordinates(VPADTouchData *point, VPADStatus *vpad, - struct video_viewport *viewport, bool *clamped) + VPADChan channel, struct video_viewport *viewport, bool *clamped) { - get_calibrated_point(point, viewport, vpad); + get_calibrated_point(point, viewport, vpad, channel); apply_clamping(point, viewport, clamped); } @@ -127,7 +192,7 @@ static void log_coords(int16_t x, int16_t y) } #endif -static void update_touch_state(int16_t state[3][2], uint64_t *buttons, VPADStatus *vpad) +static void update_touch_state(int16_t state[3][2], uint64_t *buttons, VPADStatus *vpad, VPADChan channel) { VPADTouchData point = {0}; struct video_viewport viewport = {0}; @@ -140,7 +205,7 @@ static void update_touch_state(int16_t state[3][2], uint64_t *buttons, VPADStatu } video_driver_get_viewport_info(&viewport); - get_touch_coordinates(&point, vpad, &viewport, &touch_clamped); + get_touch_coordinates(&point, vpad, channel, &viewport, &touch_clamped); state[WIIU_DEVICE_INDEX_TOUCHPAD][RETRO_DEVICE_ID_ANALOG_X] = scale_touchpad( viewport.x, viewport.x + viewport.width, -0x7fff, 0x7fff, point.x); @@ -168,67 +233,90 @@ static void wpad_poll(void) { VPADStatus vpad; VPADReadError error; + VPADChan channel; - VPADRead(PAD_GAMEPAD, &vpad, 1, &error); + for (channel = VPAD_CHAN_0; channel < WIIU_GAMEPAD_CHANNELS; channel++) { + VPADRead(channel, &vpad, 1, &error); - if (error) - return; + if (error == VPAD_READ_SUCCESS || error == VPAD_READ_NO_SAMPLES) { + /* Gamepad is connected! */ + wpad_register(channel); + } else if (error == VPAD_READ_INVALID_CONTROLLER) { + wpad_deregister(channel); + } - update_button_state(&button_state, vpad.hold); - update_analog_state(analog_state, &vpad); - update_touch_state(analog_state, &button_state, &vpad); - check_panic_button(vpad.hold); + if (error == VPAD_READ_SUCCESS) { + update_button_state(&gamepads[channel].button_state, vpad.hold); + update_analog_state(gamepads[channel].analog_state, &vpad); + update_touch_state(gamepads[channel].analog_state, &gamepads[channel].button_state, &vpad, channel); + check_panic_button(vpad.hold); + } + } } static bool wpad_init(void *data) { - int slot = pad_connection_find_vacant_pad(hid_instance.pad_list); - if(slot < 0) - return false; - - hid_instance.pad_list[slot].connected = true; - input_pad_connect(slot, &wpad_driver); wpad_poll(); - wpad_ready = true; return true; } static bool wpad_query_pad(unsigned pad) { - return wpad_ready && pad < MAX_USERS; + return pad < MAX_USERS && (to_gamepad_channel(pad) != WPAD_INVALID_CHANNEL); } static void wpad_destroy(void) { - wpad_ready = false; + } static bool wpad_button(unsigned pad, uint16_t button_bit) { + VPADChan channel; + if (!wpad_query_pad(pad)) return false; - return button_state & (UINT64_C(1) << button_bit); + channel = to_gamepad_channel(pad); + if (channel < 0) + return false; + + return gamepads[channel].button_state & (UINT64_C(1) << button_bit); } static void wpad_get_buttons(unsigned pad, input_bits_t *state) { - if (!wpad_query_pad(pad)) + VPADChan channel; + + if (!wpad_query_pad(pad)) { BIT256_CLEAR_ALL_PTR(state); - else - BITS_COPY32_PTR(state, button_state); + return; + } + + channel = to_gamepad_channel(pad); + if (channel < 0) { + BIT256_CLEAR_ALL_PTR(state); + return; + } + + BITS_COPY32_PTR(state, gamepads[channel].button_state); } static int16_t wpad_axis(unsigned pad, uint32_t axis) { axis_data data; + VPADChan channel; if (!wpad_query_pad(pad) || axis == AXIS_NONE) return 0; + channel = to_gamepad_channel(pad); + if (channel < 0) + return 0; + pad_functions.read_axis_data(axis, &data); - return pad_functions.get_axis_value(data.axis, analog_state, data.is_negative); + return pad_functions.get_axis_value(data.axis, gamepads[channel].analog_state, data.is_negative); } static const char *wpad_name(unsigned pad) diff --git a/input/include/wiiu/input.h b/input/include/wiiu/input.h index a2f450abd2..dbe2995e9f 100644 --- a/input/include/wiiu/input.h +++ b/input/include/wiiu/input.h @@ -51,7 +51,7 @@ #define WIIU_DEVICE_INDEX_TOUCHPAD 2 -#define PAD_GAMEPAD 0 +#define WIIU_GAMEPAD_CHANNELS 2 #define WIIU_WIIMOTE_CHANNELS 4 #define WIIU_ANALOG_FACTOR 0x7ff0 diff --git a/wiiu/include/wiiu/vpad.h b/wiiu/include/wiiu/vpad.h index 60d27deaa1..6c3da494cd 100644 --- a/wiiu/include/wiiu/vpad.h +++ b/wiiu/include/wiiu/vpad.h @@ -103,6 +103,11 @@ typedef enum VPADReadError VPAD_READ_INVALID_CONTROLLER = -2, } VPADReadError; +typedef enum VPADChan +{ + VPAD_CHAN_0 = 0, +} VPADChan; + typedef struct VPADVec2D { float x; From cdaf9074671d80b0d71472974d4bc539ab1d4db5 Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Sun, 17 May 2020 16:39:41 +1000 Subject: [PATCH 098/192] (WiiU/hid) hid.h only used in drivers_hid/wiiu, don't include everywhere --- input/include/wiiu/hid.h | 7 ------- input/include/wiiu/input.h | 8 +++++++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/input/include/wiiu/hid.h b/input/include/wiiu/hid.h index 66999d41be..38f6ff4d04 100644 --- a/input/include/wiiu/hid.h +++ b/input/include/wiiu/hid.h @@ -94,13 +94,6 @@ struct _wiiu_adapter_list { wiiu_adapter_t *list; }; -extern wiiu_pad_functions_t pad_functions; -extern input_device_driver_t wiiu_joypad; -extern input_device_driver_t wpad_driver; -extern input_device_driver_t kpad_driver; -extern input_device_driver_t hidpad_driver; -extern hid_driver_t wiiu_hid; - static void *alloc_zeroed(size_t alignment, size_t size); static OSThread *new_thread(void); static wiiu_hid_t *new_hid(void); diff --git a/input/include/wiiu/input.h b/input/include/wiiu/input.h index dbe2995e9f..401dbaa426 100644 --- a/input/include/wiiu/input.h +++ b/input/include/wiiu/input.h @@ -29,7 +29,6 @@ #include #include #include -#include "hid.h" #include "../../common/hid/hid_device_driver.h" #include "../../connect/joypad_connection.h" @@ -65,4 +64,11 @@ struct _wiiu_pad_functions { void (*connect)(unsigned pad, input_device_driver_t *driver); }; +extern wiiu_pad_functions_t pad_functions; +extern input_device_driver_t wiiu_joypad; +extern input_device_driver_t wpad_driver; +extern input_device_driver_t kpad_driver; +extern input_device_driver_t hidpad_driver; +extern hid_driver_t wiiu_hid; + #endif /* __WIIU_INPUT__H */ From 41541128c5205d0bda33372bf3830ec84647c015 Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Sun, 17 May 2020 16:42:31 +1000 Subject: [PATCH 099/192] (WiiU/hid) Warning fixes --- input/drivers_hid/wiiu_hid.c | 6 ++++-- input/drivers_joypad/wiiu/hidpad_driver.c | 3 +-- input/include/wiiu/hid.h | 2 -- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/input/drivers_hid/wiiu_hid.c b/input/drivers_hid/wiiu_hid.c index 6470a6369e..998bc1b479 100644 --- a/input/drivers_hid/wiiu_hid.c +++ b/input/drivers_hid/wiiu_hid.c @@ -244,7 +244,6 @@ static int32_t wiiu_hid_read(void *data, void *buffer, size_t size) static void start_polling_thread(wiiu_hid_t *hid) { OSThreadAttributes attributes = OS_THREAD_ATTRIB_AFFINITY_CPU2; - BOOL result = false; int32_t stack_size = 0x8000; int32_t priority = 10; OSThread *thread = new_thread(); @@ -557,10 +556,13 @@ static void report_hid_error(const char *msg, wiiu_adapter_t *adapter, int32_t e case -111: RARCH_ERR("[hid]: invalid device handle (%s)\n", device); break; -#if 0 default: +#if 0 RARCH_ERR("[hid]: Unknown error (%d:%d: %s)\n", error_category, hid_error_code, device); +#else + (void)error_category; + break; #endif } } diff --git a/input/drivers_joypad/wiiu/hidpad_driver.c b/input/drivers_joypad/wiiu/hidpad_driver.c index 5757714d62..2260e01e7e 100644 --- a/input/drivers_joypad/wiiu/hidpad_driver.c +++ b/input/drivers_joypad/wiiu/hidpad_driver.c @@ -34,8 +34,7 @@ static bool init_hid_driver(void) static bool hidpad_init(void *data) { - (void *)data; - int i; + (void)data; if(!init_hid_driver()) { diff --git a/input/include/wiiu/hid.h b/input/include/wiiu/hid.h index 38f6ff4d04..3d2a44301e 100644 --- a/input/include/wiiu/hid.h +++ b/input/include/wiiu/hid.h @@ -116,9 +116,7 @@ static void wiiu_hid_attach(wiiu_hid_t *hid, wiiu_attach_event *event); static void wiiu_hid_detach(wiiu_hid_t *hid, wiiu_attach_event *event); static void synchronized_process_adapters(wiiu_hid_t *hid); static void synchronized_add_to_adapters_list(wiiu_adapter_t *adapter); -static wiiu_adapter_t *synchronized_remove_from_adapters_list(uint32_t handle); static void synchronized_add_event(wiiu_attach_event *event); -static void wiiu_start_read_loop(wiiu_adapter_t *adapter); static void wiiu_hid_read_loop_callback(uint32_t handle, int32_t error, uint8_t *buffer, uint32_t buffer_size, void *userdata); static void wiiu_hid_polling_thread_cleanup(OSThread *thread, void *stack); From 70fba3e92ecba6e10d3fa2fa9c5df79460fa73cd Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Sun, 17 May 2020 16:43:38 +1000 Subject: [PATCH 100/192] (WiiU/kpad) Actually return true when kpad_init succeeds, warning fix --- input/drivers_joypad/wiiu/kpad_driver.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/input/drivers_joypad/wiiu/kpad_driver.c b/input/drivers_joypad/wiiu/kpad_driver.c index e22ef3843b..abc7e06d2d 100644 --- a/input/drivers_joypad/wiiu/kpad_driver.c +++ b/input/drivers_joypad/wiiu/kpad_driver.c @@ -81,10 +81,12 @@ static int get_slot_for_channel(unsigned channel) static bool kpad_init(void *data) { - (void *)data; + (void)data; kpad_poll(); kpad_ready = true; + + return true; } static bool kpad_query_pad(unsigned pad) From 0be52f8a49c871c4d41d03acf0af093db01d59a4 Mon Sep 17 00:00:00 2001 From: Autechre Date: Sun, 17 May 2020 22:22:00 +0200 Subject: [PATCH 101/192] Update CHANGES.md --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index ecda19d4fa..aa3fab20c0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,6 @@ # Future +- WIIU: Gamepad hotplugging support +- WIIU: Theoretical multi-gamepad support # 1.8.7 - 3DS: Add IDs for Frodo From 12af4ed7e3046d071fe949af0530ddba5f4b144c Mon Sep 17 00:00:00 2001 From: Autechre Date: Sun, 17 May 2020 22:23:22 +0200 Subject: [PATCH 102/192] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index aa3fab20c0..98188b5a20 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,5 @@ # Future +- CHEEVOS: Disable hardcore when cheats are enabled - WIIU: Gamepad hotplugging support - WIIU: Theoretical multi-gamepad support From 582f967fb03928da546ecfce0a1437aded19242c Mon Sep 17 00:00:00 2001 From: Autechre Date: Mon, 18 May 2020 02:15:03 +0200 Subject: [PATCH 103/192] Update AndroidManifest.xml --- pkg/android/phoenix/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/android/phoenix/AndroidManifest.xml b/pkg/android/phoenix/AndroidManifest.xml index e4761b6249..f27cfa5293 100644 --- a/pkg/android/phoenix/AndroidManifest.xml +++ b/pkg/android/phoenix/AndroidManifest.xml @@ -2,7 +2,7 @@ From c805fd3213b429b0e9bd182d7f08ef18e3d981a5 Mon Sep 17 00:00:00 2001 From: Jamiras Date: Mon, 18 May 2020 09:10:06 -0600 Subject: [PATCH 104/192] return false when special track cannot be found --- libretro-common/streams/chd_stream.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libretro-common/streams/chd_stream.c b/libretro-common/streams/chd_stream.c index 1ff3021bc0..e5198df625 100644 --- a/libretro-common/streams/chd_stream.c +++ b/libretro-common/streams/chd_stream.c @@ -167,6 +167,8 @@ chdstream_find_special_track(chd_file *fd, int32_t track, metadata_t *meta) } else if (track == CHDSTREAM_TRACK_PRIMARY && largest_track != 0) return chdstream_find_track_number(fd, largest_track, meta); + + return false; } switch (track) From 27a7ab20e242e0cc784a0479cdfd9e9f7a6e24b4 Mon Sep 17 00:00:00 2001 From: Autechre Date: Mon, 18 May 2020 20:58:06 +0200 Subject: [PATCH 105/192] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 98188b5a20..992dc9b50a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,6 @@ # Future - CHEEVOS: Disable hardcore when cheats are enabled +- CHD: Return false when special track cannot be found - WIIU: Gamepad hotplugging support - WIIU: Theoretical multi-gamepad support From 54fd445c75069553d39fe618772a2b1828370858 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 19 May 2020 02:12:31 +0200 Subject: [PATCH 106/192] (verbosity) move static global variables to struct --- verbosity.c | 146 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 89 insertions(+), 57 deletions(-) diff --git a/verbosity.c b/verbosity.c index 4df51b2037..6a7e091081 100644 --- a/verbosity.c +++ b/verbosity.c @@ -76,20 +76,28 @@ #define FILE_PATH_PROGRAM_NAME "RetroArch" #endif -/* If this is non-NULL. RARCH_LOG and friends - * will write to this file. */ -static FILE *log_file_fp = NULL; -static void* log_file_buf = NULL; +typedef struct verbosity_state +{ + bool verbosity; + + bool initialized; + bool override_active; + char override_path[PATH_MAX_LENGTH]; + /* If this is non-NULL. RARCH_LOG and friends + * will write to this file. */ + FILE *fp; + void *buf; +#ifdef HAVE_LIBNX + Mutex mtx; +#endif +} verbosity_state_t; + +static verbosity_state_t main_verbosity_st; + static unsigned verbosity_log_level = DEFAULT_FRONTEND_LOG_LEVEL; -static bool main_verbosity = false; -static bool log_file_initialized = false; -static bool log_file_override_active = false; -static char log_file_override_path[PATH_MAX_LENGTH] = {0}; #ifdef HAVE_LIBNX -static Mutex log_mutex; - #ifdef NXLINK /* TODO/FIXME - global referenced in platform_switch.c - not * thread-safe */ @@ -105,85 +113,96 @@ void verbosity_set_log_level(unsigned level) void verbosity_enable(void) { - main_verbosity = true; + verbosity_state_t *g_verbosity = &main_verbosity_st; + + g_verbosity->verbosity = true; #ifdef RARCH_INTERNAL - if (!log_file_initialized) + if (!g_verbosity->initialized) frontend_driver_attach_console(); #endif } void verbosity_disable(void) { - main_verbosity = false; + verbosity_state_t *g_verbosity = &main_verbosity_st; + + g_verbosity->verbosity = false; #ifdef RARCH_INTERNAL - if (!log_file_initialized) + if (!g_verbosity->initialized) frontend_driver_detach_console(); #endif } bool verbosity_is_enabled(void) { - return main_verbosity; + verbosity_state_t *g_verbosity = &main_verbosity_st; + return g_verbosity->verbosity; } bool is_logging_to_file(void) { - return log_file_initialized; + verbosity_state_t *g_verbosity = &main_verbosity_st; + return g_verbosity->initialized; } bool *verbosity_get_ptr(void) { - return &main_verbosity; + verbosity_state_t *g_verbosity = &main_verbosity_st; + return &g_verbosity->verbosity; } void retro_main_log_file_init(const char *path, bool append) { - if (log_file_initialized) + FILE *tmp = NULL; + verbosity_state_t *g_verbosity = &main_verbosity_st; + if (g_verbosity->initialized) return; #ifdef HAVE_LIBNX - mutexInit(&log_mutex); + mutexInit(&g_verbosity->mtx); #endif - log_file_fp = stderr; + g_verbosity->fp = stderr; if (!path) return; - log_file_fp = (FILE*)fopen_utf8(path, append ? "ab" : "wb"); + tmp = (FILE*)fopen_utf8(path, append ? "ab" : "wb"); - if (!log_file_fp) + if (!tmp) { - log_file_fp = stderr; RARCH_ERR("Failed to open system event log file: %s\n", path); return; } - log_file_initialized = true; + g_verbosity->fp = tmp; + g_verbosity->initialized = true; #if !defined(PS2) /* TODO: PS2 IMPROVEMENT */ /* TODO: this is only useful for a few platforms, find which and add ifdef */ - log_file_buf = calloc(1, 0x4000); - setvbuf(log_file_fp, (char*)log_file_buf, _IOFBF, 0x4000); + g_verbosity->buf = calloc(1, 0x4000); + setvbuf(g_verbosity->fp, (char*)g_verbosity->buf, _IOFBF, 0x4000); #endif } void retro_main_log_file_deinit(void) { - if (log_file_fp && log_file_initialized) - { - fclose(log_file_fp); - log_file_fp = NULL; - } - if (log_file_buf) - free(log_file_buf); - log_file_buf = NULL; + verbosity_state_t *g_verbosity = &main_verbosity_st; - log_file_initialized = false; + if (g_verbosity->fp && g_verbosity->initialized) + { + fclose(g_verbosity->fp); + g_verbosity->fp = NULL; + } + if (g_verbosity->buf) + free(g_verbosity->buf); + g_verbosity->buf = NULL; + g_verbosity->initialized = false; } #if !defined(HAVE_LOGGER) void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap) { + verbosity_state_t *g_verbosity = &main_verbosity_st; if (verbosity_log_level > 1) return; @@ -230,15 +249,15 @@ void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap) prio = ANDROID_LOG_ERROR; } - if (log_file_initialized) + if (g_verbosity->initialized) { - vfprintf(log_file_fp, fmt, ap); - fflush(log_file_fp); + vfprintf(g_verbosity->fp, fmt, ap); + fflush(g_verbosity->fp); } else __android_log_vprint(prio, FILE_PATH_PROGRAM_NAME, fmt, ap); #else - FILE *fp = (FILE*)log_file_fp; + FILE *fp = (FILE*)g_verbosity->fp; #if defined(HAVE_QT) || defined(__WINRT__) int ret; char buffer[256]; @@ -275,7 +294,7 @@ void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap) #endif #else #if defined(HAVE_LIBNX) - mutexLock(&log_mutex); + mutexLock(&g_verbosity->mtx); #endif if (fp) { @@ -284,7 +303,7 @@ void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap) fflush(fp); } #if defined(HAVE_LIBNX) - mutexUnlock(&log_mutex); + mutexUnlock(&g_verbosity->mtx); #endif #endif @@ -331,8 +350,9 @@ void RARCH_LOG_BUFFER(uint8_t *data, size_t size) void RARCH_LOG(const char *fmt, ...) { va_list ap; + verbosity_state_t *g_verbosity = &main_verbosity_st; - if (!main_verbosity) + if (!g_verbosity->verbosity) return; if (verbosity_log_level > 1) return; @@ -353,8 +373,9 @@ void RARCH_LOG_OUTPUT(const char *msg, ...) void RARCH_WARN(const char *fmt, ...) { va_list ap; + verbosity_state_t *g_verbosity = &main_verbosity_st; - if (!main_verbosity) + if (!g_verbosity->verbosity) return; if (verbosity_log_level > 2) return; @@ -367,8 +388,9 @@ void RARCH_WARN(const char *fmt, ...) void RARCH_ERR(const char *fmt, ...) { va_list ap; + verbosity_state_t *g_verbosity = &main_verbosity_st; - if (!main_verbosity) + if (!g_verbosity->verbosity) return; va_start(ap, fmt); @@ -379,8 +401,11 @@ void RARCH_ERR(const char *fmt, ...) void rarch_log_file_set_override(const char *path) { - log_file_override_active = true; - strlcpy(log_file_override_path, path, sizeof(log_file_override_path)); + verbosity_state_t *g_verbosity = &main_verbosity_st; + + g_verbosity->override_active = true; + strlcpy(g_verbosity->override_path, path, + sizeof(g_verbosity->override_path)); } void rarch_log_file_init( @@ -391,9 +416,10 @@ void rarch_log_file_init( { char log_directory[PATH_MAX_LENGTH]; char log_file_path[PATH_MAX_LENGTH]; + verbosity_state_t *g_verbosity = &main_verbosity_st; static bool log_file_created = false; static char timestamped_log_file_name[64] = {0}; - bool logging_to_file = log_file_initialized; + bool logging_to_file = g_verbosity->initialized; log_directory[0] = '\0'; log_file_path[0] = '\0'; @@ -434,28 +460,31 @@ void rarch_log_file_init( /* > Check whether we are already logging to console */ /* De-initialise existing logger */ - if (log_file_fp) + if (g_verbosity->fp) retro_main_log_file_deinit(); /* > Get directory/file paths */ - if (log_file_override_active) + if (g_verbosity->override_active) { /* Get log directory */ const char *last_slash = - find_last_slash(log_file_override_path); + find_last_slash(g_verbosity->override_path); if (last_slash) { char tmp_buf[PATH_MAX_LENGTH] = {0}; - size_t path_length = last_slash + 1 - log_file_override_path; + size_t path_length = last_slash + 1 - + g_verbosity->override_path; if ((path_length > 1) && (path_length < PATH_MAX_LENGTH)) - strlcpy(tmp_buf, log_file_override_path, path_length * sizeof(char)); + strlcpy(tmp_buf, g_verbosity->override_path, + path_length * sizeof(char)); strlcpy(log_directory, tmp_buf, sizeof(log_directory)); } /* Get log file path */ - strlcpy(log_file_path, log_file_override_path, sizeof(log_file_path)); + strlcpy(log_file_path, g_verbosity->override_path, + sizeof(log_file_path)); } else if (!string_is_empty(log_dir)) { @@ -463,7 +492,8 @@ void rarch_log_file_init( strlcpy(log_directory, log_dir, sizeof(log_directory)); /* Get log file path */ - fill_pathname_join(log_file_path, log_dir, + fill_pathname_join(log_file_path, + log_dir, log_to_file_timestamp ? timestamped_log_file_name : "retroarch.log", @@ -491,7 +521,7 @@ void rarch_log_file_init( /* When RetroArch is launched, log file is overwritten. * On subsequent calls within the same session, it is appended to. */ retro_main_log_file_init(log_file_path, log_file_created); - if (log_file_initialized) + if (g_verbosity->initialized) log_file_created = true; return; } @@ -504,11 +534,13 @@ void rarch_log_file_init( void rarch_log_file_deinit(void) { + verbosity_state_t *g_verbosity = &main_verbosity_st; + /* De-initialise existing logger, if currently logging to file */ - if (log_file_initialized) + if (g_verbosity->initialized) retro_main_log_file_deinit(); /* If logging is currently disabled... */ - if (!log_file_fp) /* ...initialise logging to console */ + if (!g_verbosity->fp) /* ...initialise logging to console */ retro_main_log_file_init(NULL, false); } From 5e904c4dc311c1971646f632fc515d756ea03a9d Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Tue, 19 May 2020 11:35:57 +0100 Subject: [PATCH 107/192] (Input Mapping/Remapping) Restore broken 'reset to default' functionality --- menu/cbs/menu_cbs_scan.c | 3 +-- menu/cbs/menu_cbs_start.c | 2 +- menu/drivers/materialui.c | 20 ++++++++++++++++---- menu/drivers/rgui.c | 11 +++++++---- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/menu/cbs/menu_cbs_scan.c b/menu/cbs/menu_cbs_scan.c index ae3c8d89b1..6c522dbe92 100644 --- a/menu/cbs/menu_cbs_scan.c +++ b/menu/cbs/menu_cbs_scan.c @@ -194,7 +194,6 @@ static int action_scan_input_desc(const char *path, static int menu_cbs_init_bind_scan_compare_type(menu_file_list_cbs_t *cbs, unsigned type) { - switch (type) { #ifdef HAVE_LIBRETRODB @@ -208,7 +207,7 @@ static int menu_cbs_init_bind_scan_compare_type(menu_file_list_cbs_t *cbs, #endif case FILE_TYPE_RPL_ENTRY: BIND_ACTION_SCAN(cbs, action_switch_thumbnail); - break; + return 0; case FILE_TYPE_NONE: default: diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index d53b139586..f7443bec87 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -549,7 +549,7 @@ static int menu_cbs_init_bind_start_compare_label(menu_file_list_cbs_t *cbs) } } - return 0; + return -1; } static int menu_cbs_init_bind_start_compare_type(menu_file_list_cbs_t *cbs, diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 06d80434f2..f8f3d8c192 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -8049,10 +8049,22 @@ static enum menu_action materialui_parse_menu_entry_action( materialui_auto_select_onscreen_entry(mui, MUI_ONSCREEN_ENTRY_FIRST); break; case MENU_ACTION_SCAN: - /* 'Scan' command is used to cycle current - * thumbnail view mode */ - materialui_switch_list_view(mui); - new_action = MENU_ACTION_NOOP; + /* - If this is a playlist, 'scan' command is used + * to cycle current thumbnail view + * - If this is not a playlist, perform default + * 'scan' action *if* current selection is + * on screen */ + { + size_t selection = menu_navigation_get_selection(); + + if (mui->is_playlist) + { + materialui_switch_list_view(mui); + new_action = MENU_ACTION_NOOP; + } + else if (!materialui_entry_onscreen(mui, selection)) + new_action = MENU_ACTION_NOOP; + } break; case MENU_ACTION_START: /* - If this is a playlist, attempt to show diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index d72e83a1c6..2eab093df9 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -5403,10 +5403,13 @@ static enum menu_action rgui_parse_menu_entry_action( switch (action) { case MENU_ACTION_SCAN: - /* 'Scan' command is used to toggle - * fullscreen thumbnail view */ - rgui_toggle_fs_thumbnail(rgui); - new_action = MENU_ACTION_NOOP; + /* If this is a playlist, 'scan' command is + * used to toggle fullscreen thumbnail view */ + if (rgui->is_playlist) + { + rgui_toggle_fs_thumbnail(rgui); + new_action = MENU_ACTION_NOOP; + } break; default: /* In all other cases, pass through input From 2b19a50775d077a238c551caedbd65f85215f250 Mon Sep 17 00:00:00 2001 From: Autechre Date: Tue, 19 May 2020 12:50:26 +0200 Subject: [PATCH 108/192] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 992dc9b50a..c14d7af0bf 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,7 @@ # Future - CHEEVOS: Disable hardcore when cheats are enabled - CHD: Return false when special track cannot be found +- INPUT MAPPING/REMAPPING: Restore broken 'reset to default' functionality with RetroPad 'start' button - WIIU: Gamepad hotplugging support - WIIU: Theoretical multi-gamepad support From 25888db0afa690abd59da5e811041216b361258c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 19 May 2020 13:38:39 +0200 Subject: [PATCH 109/192] (menu_driver.c) Move state into struct --- menu/menu_driver.c | 425 ++++++++++++++++++++++++++------------------- 1 file changed, 245 insertions(+), 180 deletions(-) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index f342977146..5b987dac55 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -83,42 +83,53 @@ struct menu_list file_list_t **selection_buf; }; -/* Storage container for current menu datetime - * representation string */ -static char menu_datetime_cache[255] = {0}; +struct menu_state +{ + /* when enabled, on next iteration the 'Quick Menu' list will + * be pushed onto the stack */ + bool pending_quick_menu; + bool prevent_populate; + /* The menu driver owns the userdata */ + bool data_own; -/* when enabled, on next iteration the 'Quick Menu' list will - * be pushed onto the stack */ -static bool menu_driver_pending_quick_menu = false; + struct + { + /* Flagged when menu entries need to be refreshed */ + bool need_refresh; + bool nonblocking_refresh; + size_t begin; + rarch_setting_t *list_settings; + menu_list_t *list; + } entries; -static bool menu_driver_prevent_populate = false; + /* Quick jumping indices with L/R. + * Rebuilt when parsing directory. */ + struct + { + size_t index_list[SCROLL_INDEX_SIZE]; + unsigned index_size; + unsigned acceleration; + } scroll; -/* The menu driver owns the userdata */ -static bool menu_driver_data_own = false; + size_t selection_ptr; + + /* Timers */ + retro_time_t current_time_us; + retro_time_t powerstate_last_time_us; + retro_time_t datetime_last_time_us; + + /* Storage container for current menu datetime + * representation string */ + char datetime_cache[255]; + +}; + +static struct menu_state menu_driver_state; static menu_handle_t *menu_driver_data = NULL; static const menu_ctx_driver_t *menu_driver_ctx = NULL; static void *menu_userdata = NULL; -/* Quick jumping indices with L/R. - * Rebuilt when parsing directory. */ -static size_t scroll_index_list[SCROLL_INDEX_SIZE]; -static unsigned scroll_index_size = 0; -static unsigned scroll_acceleration = 0; -static size_t menu_driver_selection_ptr = 0; - -/* Timers */ -static retro_time_t menu_driver_current_time_us = 0; -static retro_time_t menu_driver_powerstate_last_time_us = 0; -static retro_time_t menu_driver_datetime_last_time_us = 0; - -/* Flagged when menu entries need to be refreshed */ -static bool menu_entries_need_refresh = false; -static bool menu_entries_nonblocking_refresh = false; -static size_t menu_entries_begin = 0; -static rarch_setting_t *menu_entries_list_settings = NULL; -static menu_list_t *menu_entries_list = NULL; - static enum action_iterate_type action_iterate_type(const char *label) { if (string_is_equal(label, "info_screen")) @@ -148,10 +159,11 @@ static enum action_iterate_type action_iterate_type(const char *label) #ifdef HAVE_ACCESSIBILITY static void get_current_menu_value(char* retstr, size_t max) { - const char* entry_label; menu_entry_t entry; + const char* entry_label; + struct menu_state *menu_st = &menu_driver_state; - menu_driver_selection_ptr = menu_navigation_get_selection(); + menu_st->selection_ptr = menu_navigation_get_selection(); menu_entry_init(&entry); menu_entry_get(&entry, 0, menu_navigation_get_selection(), NULL, true); menu_entry_get_value(&entry, &entry_label); @@ -161,10 +173,11 @@ static void get_current_menu_value(char* retstr, size_t max) static void get_current_menu_label(char* retstr, size_t max) { - const char* entry_label; menu_entry_t entry; + const char* entry_label; + struct menu_state *menu_st = &menu_driver_state; - menu_driver_selection_ptr = menu_navigation_get_selection(); + menu_st->selection_ptr = menu_navigation_get_selection(); menu_entry_init(&entry); menu_entry_get(&entry, 0, menu_navigation_get_selection(), NULL, true); menu_entry_get_rich_label(&entry, &entry_label); @@ -174,10 +187,12 @@ static void get_current_menu_label(char* retstr, size_t max) static void get_current_menu_sublabel(char* retstr, size_t max) { - const char* entry_sublabel; menu_entry_t entry; + const char* entry_sublabel; + struct menu_state *menu_st = &menu_driver_state; + + menu_st->selection_ptr = menu_navigation_get_selection(); - menu_driver_selection_ptr = menu_navigation_get_selection(); menu_entry_init(&entry); menu_entry_get(&entry, 0, menu_navigation_get_selection(), NULL, true); @@ -693,12 +708,14 @@ menu_handle_t *menu_driver_get_ptr(void) size_t menu_navigation_get_selection(void) { - return menu_driver_selection_ptr; + struct menu_state *menu_st = &menu_driver_state; + return menu_st->selection_ptr; } void menu_navigation_set_selection(size_t val) { - menu_driver_selection_ptr = val; + struct menu_state *menu_st = &menu_driver_state; + menu_st->selection_ptr = val; } @@ -708,7 +725,7 @@ void menu_navigation_set_selection(size_t val) #define menu_list_get_stack_size(list, idx) ((list)->menu_stack[(idx)]->size) -#define menu_entries_get_selection_buf_ptr_internal(idx) ((menu_entries_list) ? menu_list_get_selection(menu_entries_list, (unsigned)idx) : NULL) +#define menu_entries_get_selection_buf_ptr_internal(idx) ((menu_st->entries.list) ? menu_list_get_selection(menu_st->entries.list, (unsigned)idx) : NULL) /* Menu entry interface - * @@ -726,6 +743,7 @@ void menu_navigation_set_selection(size_t val) enum menu_entry_type menu_entry_get_type(uint32_t i) { + struct menu_state *menu_st = &menu_driver_state; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr_internal(0); menu_file_list_cbs_t *cbs = NULL; rarch_setting_t *setting = NULL; @@ -845,6 +863,7 @@ unsigned menu_entry_get_type_new(menu_entry_t *entry) uint32_t menu_entry_get_bool_value(uint32_t i) { + struct menu_state *menu_st = &menu_driver_state; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr_internal(0); menu_file_list_cbs_t *cbs = selection_buf ? (menu_file_list_cbs_t*)selection_buf->list[i].actiondata : NULL; @@ -857,6 +876,7 @@ uint32_t menu_entry_get_bool_value(uint32_t i) struct string_list *menu_entry_enum_values(uint32_t i) { + struct menu_state *menu_st = &menu_driver_state; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr_internal(0); menu_file_list_cbs_t *cbs = selection_buf ? (menu_file_list_cbs_t*)selection_buf->list[i].actiondata : NULL; @@ -870,6 +890,7 @@ struct string_list *menu_entry_enum_values(uint32_t i) void menu_entry_enum_set_value_with_string(uint32_t i, const char *s) { + struct menu_state *menu_st = &menu_driver_state; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr_internal(0); menu_file_list_cbs_t *cbs = selection_buf ? (menu_file_list_cbs_t*)selection_buf->list[i].actiondata : NULL; @@ -879,6 +900,7 @@ void menu_entry_enum_set_value_with_string(uint32_t i, const char *s) int32_t menu_entry_bind_index(uint32_t i) { + struct menu_state *menu_st = &menu_driver_state; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr_internal(0); menu_file_list_cbs_t *cbs = selection_buf ? (menu_file_list_cbs_t*)selection_buf->list[i].actiondata : NULL; @@ -891,6 +913,7 @@ int32_t menu_entry_bind_index(uint32_t i) void menu_entry_bind_key_set(uint32_t i, int32_t value) { + struct menu_state *menu_st = &menu_driver_state; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr_internal(0); menu_file_list_cbs_t *cbs = selection_buf ? (menu_file_list_cbs_t*)selection_buf->list[i].actiondata : NULL; @@ -902,6 +925,7 @@ void menu_entry_bind_key_set(uint32_t i, int32_t value) void menu_entry_bind_joykey_set(uint32_t i, int32_t value) { + struct menu_state *menu_st = &menu_driver_state; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr_internal(0); menu_file_list_cbs_t *cbs = selection_buf ? (menu_file_list_cbs_t*)selection_buf->list[i].actiondata : NULL; @@ -913,6 +937,7 @@ void menu_entry_bind_joykey_set(uint32_t i, int32_t value) void menu_entry_bind_joyaxis_set(uint32_t i, int32_t value) { + struct menu_state *menu_st = &menu_driver_state; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr_internal(0); menu_file_list_cbs_t *cbs = selection_buf ? (menu_file_list_cbs_t*)selection_buf->list[i].actiondata : NULL; @@ -924,6 +949,7 @@ void menu_entry_bind_joyaxis_set(uint32_t i, int32_t value) void menu_entry_pathdir_selected(uint32_t i) { + struct menu_state *menu_st = &menu_driver_state; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr_internal(0); menu_file_list_cbs_t *cbs = selection_buf ? (menu_file_list_cbs_t*)selection_buf->list[i].actiondata : NULL; @@ -935,6 +961,7 @@ void menu_entry_pathdir_selected(uint32_t i) bool menu_entry_pathdir_allow_empty(uint32_t i) { + struct menu_state *menu_st = &menu_driver_state; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr_internal(0); menu_file_list_cbs_t *cbs = selection_buf ? (menu_file_list_cbs_t*)selection_buf->list[i].actiondata : NULL; @@ -946,6 +973,7 @@ bool menu_entry_pathdir_allow_empty(uint32_t i) uint32_t menu_entry_pathdir_for_directory(uint32_t i) { + struct menu_state *menu_st = &menu_driver_state; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr_internal(0); menu_file_list_cbs_t *cbs = selection_buf ? (menu_file_list_cbs_t*)selection_buf->list[i].actiondata : NULL; @@ -957,6 +985,7 @@ uint32_t menu_entry_pathdir_for_directory(uint32_t i) void menu_entry_pathdir_extensions(uint32_t i, char *s, size_t len) { + struct menu_state *menu_st = &menu_driver_state; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr_internal(0); menu_file_list_cbs_t *cbs = selection_buf ? (menu_file_list_cbs_t*)selection_buf->list[i].actiondata : NULL; @@ -992,6 +1021,7 @@ void menu_entry_get_value(menu_entry_t *entry, const char **value) void menu_entry_set_value(uint32_t i, const char *s) { + struct menu_state *menu_st = &menu_driver_state; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr_internal(0); menu_file_list_cbs_t *cbs = selection_buf ? (menu_file_list_cbs_t*)selection_buf->list[i].actiondata : NULL; @@ -1006,6 +1036,7 @@ bool menu_entry_is_password(menu_entry_t *entry) uint32_t menu_entry_num_has_range(uint32_t i) { + struct menu_state *menu_st = &menu_driver_state; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr_internal(0); menu_file_list_cbs_t *cbs = selection_buf ? (menu_file_list_cbs_t*)selection_buf->list[i].actiondata : NULL; @@ -1017,6 +1048,7 @@ uint32_t menu_entry_num_has_range(uint32_t i) float menu_entry_num_min(uint32_t i) { + struct menu_state *menu_st = &menu_driver_state; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr_internal(0); menu_file_list_cbs_t *cbs = selection_buf ? (menu_file_list_cbs_t*)selection_buf->list[i].actiondata : NULL; @@ -1027,6 +1059,7 @@ float menu_entry_num_min(uint32_t i) float menu_entry_num_max(uint32_t i) { + struct menu_state *menu_st = &menu_driver_state; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr_internal(0); menu_file_list_cbs_t *cbs = selection_buf ? (menu_file_list_cbs_t*)selection_buf->list[i].actiondata : NULL; @@ -1042,6 +1075,7 @@ void menu_entry_get(menu_entry_t *entry, size_t stack_idx, const char *path = NULL; const char *entry_label = NULL; menu_file_list_cbs_t *cbs = NULL; + struct menu_state *menu_st = &menu_driver_state; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr_internal(stack_idx); file_list_t *list = (userdata) ? (file_list_t*)userdata : selection_buf; bool path_enabled = entry->path_enabled; @@ -1154,7 +1188,8 @@ void menu_entry_get(menu_entry_t *entry, size_t stack_idx, bool menu_entry_is_currently_selected(unsigned id) { - return id == menu_driver_selection_ptr; + struct menu_state *menu_st = &menu_driver_state; + return id == menu_st->selection_ptr; } /* Performs whatever actions are associated with menu entry 'i'. @@ -1167,8 +1202,9 @@ bool menu_entry_is_currently_selected(unsigned id) int menu_entry_select(uint32_t i) { menu_entry_t entry; + struct menu_state *menu_st = &menu_driver_state; - menu_driver_selection_ptr = i; + menu_st->selection_ptr = i; menu_entry_init(&entry); menu_entry_get(&entry, 0, i, NULL, false); @@ -1325,12 +1361,13 @@ static bool menu_list_pop_stack(menu_list_t *list, static void menu_list_flush_stack(menu_list_t *list, size_t idx, const char *needle, unsigned final_type) { - bool refresh = false; - const char *path = NULL; - const char *label = NULL; - unsigned type = 0; - size_t entry_idx = 0; - file_list_t *menu_list = menu_list_get(list, (unsigned)idx); + bool refresh = false; + const char *path = NULL; + const char *label = NULL; + unsigned type = 0; + size_t entry_idx = 0; + struct menu_state *menu_st = &menu_driver_state; + file_list_t *menu_list = menu_list_get(list, (unsigned)idx); menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); file_list_get_last(menu_list, @@ -1339,12 +1376,12 @@ static void menu_list_flush_stack(menu_list_t *list, while (menu_list_flush_stack_type( needle, label, type, final_type) != 0) { - size_t new_selection_ptr = menu_driver_selection_ptr; + size_t new_selection_ptr = menu_st->selection_ptr; if (!menu_list_pop_stack(list, idx, &new_selection_ptr, 1)) break; - menu_driver_selection_ptr = new_selection_ptr; + menu_st->selection_ptr = new_selection_ptr; menu_list = menu_list_get(list, (unsigned)idx); @@ -1397,25 +1434,27 @@ static int menu_entries_elem_get_first_char( static void menu_navigation_add_scroll_index(size_t sel) { - scroll_index_list[scroll_index_size] = sel; + struct menu_state *menu_st = &menu_driver_state; + menu_st->scroll.index_list[menu_st->scroll.index_size] = sel; - if (!((scroll_index_size + 1) >= SCROLL_INDEX_SIZE)) - scroll_index_size++; + if (!((menu_st->scroll.index_size + 1) >= SCROLL_INDEX_SIZE)) + menu_st->scroll.index_size++; } static void menu_entries_build_scroll_indices(file_list_t *list) { int current; - bool current_is_dir = false; - unsigned type = 0; - size_t i = 0; + struct menu_state *menu_st = &menu_driver_state; + bool current_is_dir = false; + unsigned type = 0; + size_t i = 0; - scroll_index_size = 0; + menu_st->scroll.index_size = 0; menu_navigation_add_scroll_index(0); - current = menu_entries_elem_get_first_char(list, 0); - type = list->list[0].type; + current = menu_entries_elem_get_first_char(list, 0); + type = list->list[0].type; if (type == FILE_TYPE_DIRECTORY) current_is_dir = true; @@ -1451,7 +1490,8 @@ static void menu_entries_build_scroll_indices(file_list_t *list) static bool menu_entries_refresh(file_list_t *list) { size_t list_size; - size_t selection = menu_driver_selection_ptr; + struct menu_state *menu_st = &menu_driver_state; + size_t selection = menu_st->selection_ptr; if (list->size) menu_entries_build_scroll_indices(list); @@ -1461,7 +1501,8 @@ static bool menu_entries_refresh(file_list_t *list) if ((selection >= list_size) && list_size) { size_t idx = list_size - 1; - menu_driver_selection_ptr = idx; + menu_st->selection_ptr = idx; + menu_driver_navigation_set(true); } else if (!list_size) @@ -1475,9 +1516,10 @@ static bool menu_entries_refresh(file_list_t *list) menu_file_list_cbs_t *menu_entries_get_last_stack_actiondata(void) { - if (menu_entries_list) + struct menu_state *menu_st = &menu_driver_state; + if (menu_st->entries.list) { - const file_list_t *list = menu_list_get(menu_entries_list, 0); + const file_list_t *list = menu_list_get(menu_st->entries.list, 0); return (menu_file_list_cbs_t*)list->list[list->size - 1].actiondata; } return NULL; @@ -1489,8 +1531,9 @@ int menu_entries_get_title(char *s, size_t len) unsigned menu_type = 0; const char *path = NULL; const char *label = NULL; - const file_list_t *list = menu_entries_list ? - menu_list_get(menu_entries_list, 0) : NULL; + struct menu_state *menu_st = &menu_driver_state; + const file_list_t *list = menu_st->entries.list ? + menu_list_get(menu_st->entries.list, 0) : NULL; menu_file_list_cbs_t *cbs = list ? (menu_file_list_cbs_t*)list->list[list->size - 1].actiondata : NULL; @@ -1558,7 +1601,8 @@ int menu_entries_get_core_title(char *s, size_t len) file_list_t *menu_entries_get_menu_stack_ptr(size_t idx) { - menu_list_t *menu_list = menu_entries_list; + struct menu_state *menu_st = &menu_driver_state; + menu_list_t *menu_list = menu_st->entries.list; if (!menu_list) return NULL; return menu_list_get(menu_list, (unsigned)idx); @@ -1566,7 +1610,8 @@ file_list_t *menu_entries_get_menu_stack_ptr(size_t idx) file_list_t *menu_entries_get_selection_buf_ptr(size_t idx) { - menu_list_t *menu_list = menu_entries_list; + struct menu_state *menu_st = &menu_driver_state; + menu_list_t *menu_list = menu_st->entries.list; if (!menu_list) return NULL; return menu_list_get_selection(menu_list, (unsigned)idx); @@ -1574,28 +1619,31 @@ file_list_t *menu_entries_get_selection_buf_ptr(size_t idx) static void menu_entries_list_deinit(void) { - if (menu_entries_list) - menu_list_free(menu_entries_list); - menu_entries_list = NULL; + struct menu_state *menu_st = &menu_driver_state; + if (menu_st->entries.list) + menu_list_free(menu_st->entries.list); + menu_st->entries.list = NULL; } static void menu_entries_settings_deinit(void) { - menu_setting_free(menu_entries_list_settings); - if (menu_entries_list_settings) - free(menu_entries_list_settings); - menu_entries_list_settings = NULL; + struct menu_state *menu_st = &menu_driver_state; + menu_setting_free(menu_st->entries.list_settings); + if (menu_st->entries.list_settings) + free(menu_st->entries.list_settings); + menu_st->entries.list_settings = NULL; } static bool menu_entries_init(void) { - if (!(menu_entries_list = (menu_list_t*)menu_list_new())) + struct menu_state *menu_st = &menu_driver_state; + if (!(menu_st->entries.list = (menu_list_t*)menu_list_new())) goto error; - menu_setting_ctl(MENU_SETTING_CTL_NEW, &menu_entries_list_settings); + menu_setting_ctl(MENU_SETTING_CTL_NEW, &menu_st->entries.list_settings); - if (!menu_entries_list_settings) + if (!menu_st->entries.list_settings) goto error; return true; @@ -1769,10 +1817,11 @@ void menu_entries_get_last_stack(const char **path, const char **label, unsigned *file_type, enum msg_hash_enums *enum_idx, size_t *entry_idx) { file_list_t *list = NULL; - if (!menu_entries_list) + struct menu_state *menu_st = &menu_driver_state; + if (!menu_st->entries.list) return; - list = menu_list_get(menu_entries_list, 0); + list = menu_list_get(menu_st->entries.list, 0); file_list_get_last(list, path, label, file_type, entry_idx); @@ -1789,21 +1838,24 @@ void menu_entries_get_last_stack(const char **path, const char **label, void menu_entries_flush_stack(const char *needle, unsigned final_type) { - menu_list_t *menu_list = menu_entries_list; + struct menu_state *menu_st = &menu_driver_state; + menu_list_t *menu_list = menu_st->entries.list; if (menu_list) menu_list_flush_stack(menu_list, 0, needle, final_type); } void menu_entries_pop_stack(size_t *ptr, size_t idx, bool animate) { - menu_list_t *menu_list = menu_entries_list; + struct menu_state *menu_st = &menu_driver_state; + menu_list_t *menu_list = menu_st->entries.list; if (menu_list) menu_list_pop_stack(menu_list, idx, ptr, animate); } size_t menu_entries_get_stack_size(size_t idx) { - menu_list_t *menu_list = menu_entries_list; + struct menu_state *menu_st = &menu_driver_state; + menu_list_t *menu_list = menu_st->entries.list; if (!menu_list) return 0; return menu_list_get_stack_size(menu_list, idx); @@ -1812,7 +1864,8 @@ size_t menu_entries_get_stack_size(size_t idx) size_t menu_entries_get_size(void) { const file_list_t *list = NULL; - menu_list_t *menu_list = menu_entries_list; + struct menu_state *menu_st = &menu_driver_state; + menu_list_t *menu_list = menu_st->entries.list; if (!menu_list) return 0; list = menu_list_get_selection(menu_list, 0); @@ -1821,28 +1874,30 @@ size_t menu_entries_get_size(void) bool menu_entries_ctl(enum menu_entries_ctl_state state, void *data) { + struct menu_state *menu_st = &menu_driver_state; + switch (state) { case MENU_ENTRIES_CTL_NEEDS_REFRESH: - if (menu_entries_nonblocking_refresh) + if (menu_st->entries.nonblocking_refresh) return false; - if (!menu_entries_need_refresh) + if (!menu_st->entries.need_refresh) return false; break; case MENU_ENTRIES_CTL_LIST_GET: { - menu_list_t **list = (menu_list_t**)data; + menu_list_t **list = (menu_list_t**)data; if (!list) return false; - *list = menu_entries_list; + *list = menu_st->entries.list; } return true; case MENU_ENTRIES_CTL_SETTINGS_GET: { - rarch_setting_t **settings = (rarch_setting_t**)data; + rarch_setting_t **settings = (rarch_setting_t**)data; if (!settings) return false; - *settings = menu_entries_list_settings; + *settings = menu_st->entries.list_settings; } break; case MENU_ENTRIES_CTL_SET_REFRESH: @@ -1850,9 +1905,9 @@ bool menu_entries_ctl(enum menu_entries_ctl_state state, void *data) bool *nonblocking = (bool*)data; if (*nonblocking) - menu_entries_nonblocking_refresh = true; + menu_st->entries.nonblocking_refresh = true; else - menu_entries_need_refresh = true; + menu_st->entries.need_refresh = true; } break; case MENU_ENTRIES_CTL_UNSET_REFRESH: @@ -1860,16 +1915,16 @@ bool menu_entries_ctl(enum menu_entries_ctl_state state, void *data) bool *nonblocking = (bool*)data; if (*nonblocking) - menu_entries_nonblocking_refresh = false; + menu_st->entries.nonblocking_refresh = false; else - menu_entries_need_refresh = false; + menu_st->entries.need_refresh = false; } break; case MENU_ENTRIES_CTL_SET_START: { size_t *idx = (size_t*)data; if (idx) - menu_entries_begin = *idx; + menu_st->entries.begin = *idx; } case MENU_ENTRIES_CTL_START_GET: { @@ -1877,7 +1932,7 @@ bool menu_entries_ctl(enum menu_entries_ctl_state state, void *data) if (!idx) return 0; - *idx = menu_entries_begin; + *idx = menu_st->entries.begin; } break; case MENU_ENTRIES_CTL_REFRESH: @@ -1904,9 +1959,9 @@ bool menu_entries_ctl(enum menu_entries_ctl_state state, void *data) /* Returns true if a Back button should be shown * (i.e. we are at least * one level deep in the menu hierarchy). */ - if (!menu_entries_list) + if (!menu_st->entries.list) return false; - return (menu_list_get_stack_size(menu_entries_list, 0) > 1); + return (menu_list_get_stack_size(menu_st->entries.list, 0) > 1); case MENU_ENTRIES_CTL_NONE: default: break; @@ -2203,17 +2258,18 @@ static void strftime_am_pm(char* ptr, size_t maxsize, const char* format, * */ void menu_display_timedate(gfx_display_ctx_datetime_t *datetime) { + struct menu_state *menu_st = &menu_driver_state; if (!datetime) return; /* Trigger an update, if required */ - if (menu_driver_current_time_us - menu_driver_datetime_last_time_us >= + if (menu_st->current_time_us - menu_st->datetime_last_time_us >= DATETIME_CHECK_INTERVAL) { time_t time_; const struct tm *tm_; - menu_driver_datetime_last_time_us = menu_driver_current_time_us; + menu_st->datetime_last_time_us = menu_st->current_time_us; /* Get current time */ time(&time_); @@ -2226,107 +2282,107 @@ void menu_display_timedate(gfx_display_ctx_datetime_t *datetime) switch (datetime->time_mode) { case MENU_TIMEDATE_STYLE_YMD_HMS: /* YYYY-MM-DD HH:MM:SS */ - strftime(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%Y-%m-%d %H:%M:%S", tm_); break; case MENU_TIMEDATE_STYLE_YMD_HM: /* YYYY-MM-DD HH:MM */ - strftime(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%Y-%m-%d %H:%M", tm_); break; case MENU_TIMEDATE_STYLE_YMD: /* YYYY-MM-DD */ - strftime(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%Y-%m-%d", tm_); break; case MENU_TIMEDATE_STYLE_YM: /* YYYY-MM */ - strftime(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%Y-%m", tm_); break; case MENU_TIMEDATE_STYLE_MDYYYY_HMS: /* MM-DD-YYYY HH:MM:SS */ - strftime(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%m-%d-%Y %H:%M:%S", tm_); break; case MENU_TIMEDATE_STYLE_MDYYYY_HM: /* MM-DD-YYYY HH:MM */ - strftime(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%m-%d-%Y %H:%M", tm_); break; case MENU_TIMEDATE_STYLE_MD_HM: /* MM/DD HH:MM */ - strftime(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%m/%d %H:%M", tm_); break; case MENU_TIMEDATE_STYLE_MDYYYY: /* MM-DD-YYYY */ - strftime(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%m-%d-%Y", tm_); break; case MENU_TIMEDATE_STYLE_MD: /* MM-DD */ - strftime(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%m-%d", tm_); break; case MENU_TIMEDATE_STYLE_DDMMYYYY_HMS: /* DD/MM/YYYY HH:MM:SS */ - strftime(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%d/%m/%Y %H:%M:%S", tm_); break; case MENU_TIMEDATE_STYLE_DDMMYYYY_HM: /* DD/MM/YYYY HH:MM */ - strftime(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%d/%m/%Y %H:%M", tm_); break; case MENU_TIMEDATE_STYLE_DDMM_HM: /* DD/MM HH:MM */ - strftime(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%d/%m %H:%M", tm_); break; case MENU_TIMEDATE_STYLE_DDMMYYYY: /* DD/MM/YYYY */ - strftime(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%d/%m/%Y", tm_); break; case MENU_TIMEDATE_STYLE_DDMM: /* DD/MM */ - strftime(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%d/%m", tm_); break; case MENU_TIMEDATE_STYLE_HMS: /* HH:MM:SS */ - strftime(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%H:%M:%S", tm_); break; case MENU_TIMEDATE_STYLE_HM: /* HH:MM */ - strftime(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%H:%M", tm_); break; case MENU_TIMEDATE_STYLE_YMD_HMS_AM_PM: /* YYYY-MM-DD HH:MM:SS (am/pm) */ - strftime_am_pm(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%Y-%m-%d %I:%M:%S %p", tm_); break; case MENU_TIMEDATE_STYLE_YMD_HM_AM_PM: /* YYYY-MM-DD HH:MM (am/pm) */ - strftime_am_pm(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%Y-%m-%d %I:%M %p", tm_); break; case MENU_TIMEDATE_STYLE_MDYYYY_HMS_AM_PM: /* MM-DD-YYYY HH:MM:SS (am/pm) */ - strftime_am_pm(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%m-%d-%Y %I:%M:%S %p", tm_); break; case MENU_TIMEDATE_STYLE_MDYYYY_HM_AM_PM: /* MM-DD-YYYY HH:MM (am/pm) */ - strftime_am_pm(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%m-%d-%Y %I:%M %p", tm_); break; case MENU_TIMEDATE_STYLE_MD_HM_AM_PM: /* MM/DD HH:MM (am/pm) */ - strftime_am_pm(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%m/%d %I:%M %p", tm_); break; case MENU_TIMEDATE_STYLE_DDMMYYYY_HMS_AM_PM: /* DD/MM/YYYY HH:MM:SS (am/pm) */ - strftime_am_pm(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%d/%m/%Y %I:%M:%S %p", tm_); break; case MENU_TIMEDATE_STYLE_DDMMYYYY_HM_AM_PM: /* DD/MM/YYYY HH:MM (am/pm) */ - strftime_am_pm(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%d/%m/%Y %I:%M %p", tm_); break; case MENU_TIMEDATE_STYLE_DDMM_HM_AM_PM: /* DD/MM HH:MM (am/pm) */ - strftime_am_pm(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%d/%m %I:%M %p", tm_); break; case MENU_TIMEDATE_STYLE_HMS_AM_PM: /* HH:MM:SS (am/pm) */ - strftime_am_pm(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%I:%M:%S %p", tm_); break; case MENU_TIMEDATE_STYLE_HM_AM_PM: /* HH:MM (am/pm) */ - strftime_am_pm(menu_datetime_cache, sizeof(menu_datetime_cache), + strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%I:%M %p", tm_); break; } @@ -2334,7 +2390,7 @@ void menu_display_timedate(gfx_display_ctx_datetime_t *datetime) /* Copy cached datetime string to input * menu_display_ctx_datetime_t struct */ - strlcpy(datetime->s, menu_datetime_cache, datetime->len); + strlcpy(datetime->s, menu_st->datetime_cache, datetime->len); } @@ -2342,16 +2398,17 @@ void menu_display_timedate(gfx_display_ctx_datetime_t *datetime) void menu_display_powerstate(gfx_display_ctx_powerstate_t *powerstate) { int percent = 0; + struct menu_state *menu_st = &menu_driver_state; enum frontend_powerstate state = FRONTEND_POWERSTATE_NONE; if (!powerstate) return; /* Trigger an update, if required */ - if (menu_driver_current_time_us - menu_driver_powerstate_last_time_us >= + if (menu_st->current_time_us - menu_st->powerstate_last_time_us >= POWERSTATE_CHECK_INTERVAL) { - menu_driver_powerstate_last_time_us = menu_driver_current_time_us; + menu_st->powerstate_last_time_us = menu_st->current_time_us; task_push_get_powerstate(); } @@ -2380,24 +2437,26 @@ void menu_display_powerstate(gfx_display_ctx_powerstate_t *powerstate) bool menu_driver_iterate(menu_ctx_iterate_t *iterate, retro_time_t current_time) { - /* Get current time */ - menu_driver_current_time_us = current_time; + struct menu_state *menu_st = &menu_driver_state; - if (menu_driver_pending_quick_menu) + /* Get current time */ + menu_st->current_time_us = current_time; + + if (menu_st->pending_quick_menu) { /* If the user had requested that the Quick Menu * be spawned during the previous frame, do this now * and exit the function to go to the next frame. */ - menu_driver_pending_quick_menu = false; + menu_st->pending_quick_menu = false; menu_entries_flush_stack(NULL, MENU_SETTINGS); gfx_display_set_msg_force(true); generic_action_ok_displaylist_push("", NULL, "", 0, 0, 0, ACTION_OK_DL_CONTENT_SETTINGS); - menu_driver_selection_ptr = 0; + menu_st->selection_ptr = 0; return true; } @@ -2620,9 +2679,11 @@ void menu_driver_set_thumbnail_content(char *s, size_t len) /* Teardown function for the menu driver. */ void menu_driver_destroy(void) { - menu_driver_pending_quick_menu = false; - menu_driver_prevent_populate = false; - menu_driver_data_own = false; + struct menu_state *menu_st = &menu_driver_state; + + menu_st->pending_quick_menu = false; + menu_st->prevent_populate = false; + menu_st->data_own = false; menu_driver_ctx = NULL; menu_userdata = NULL; } @@ -2664,16 +2725,19 @@ bool menu_driver_list_get_size(menu_ctx_list_t *list) retro_time_t menu_driver_get_current_time(void) { - return menu_driver_current_time_us; + struct menu_state *menu_st = &menu_driver_state; + return menu_st->current_time_us; } bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) { + struct menu_state *menu_st = &menu_driver_state; + switch (state) { case RARCH_MENU_CTL_SET_PENDING_QUICK_MENU: menu_entries_flush_stack(NULL, MENU_SETTINGS); - menu_driver_pending_quick_menu = true; + menu_st->pending_quick_menu = true; break; case RARCH_MENU_CTL_FIND_DRIVER: { @@ -2716,26 +2780,26 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) } break; case RARCH_MENU_CTL_SET_PREVENT_POPULATE: - menu_driver_prevent_populate = true; + menu_st->prevent_populate = true; break; case RARCH_MENU_CTL_UNSET_PREVENT_POPULATE: - menu_driver_prevent_populate = false; + menu_st->prevent_populate = false; break; case RARCH_MENU_CTL_IS_PREVENT_POPULATE: - return menu_driver_prevent_populate; + return menu_st->prevent_populate; case RARCH_MENU_CTL_SET_OWN_DRIVER: - menu_driver_data_own = true; + menu_st->data_own = true; break; case RARCH_MENU_CTL_UNSET_OWN_DRIVER: - menu_driver_data_own = false; + menu_st->data_own = false; break; case RARCH_MENU_CTL_OWNS_DRIVER: - return menu_driver_data_own; + return menu_st->data_own; case RARCH_MENU_CTL_DEINIT: if (menu_driver_ctx && menu_driver_ctx->context_destroy) menu_driver_ctx->context_destroy(menu_userdata); - if (menu_driver_data_own) + if (menu_st->data_own) return true; playlist_free_cached(); @@ -2750,12 +2814,12 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) { unsigned i; - scroll_acceleration = 0; - menu_driver_selection_ptr = 0; - scroll_index_size = 0; + menu_st->scroll.acceleration = 0; + menu_st->selection_ptr = 0; + menu_st->scroll.index_size = 0; for (i = 0; i < SCROLL_INDEX_SIZE; i++) - scroll_index_list[i] = 0; + menu_st->scroll.index_list[i] = 0; menu_input_reset(); @@ -2784,11 +2848,11 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) if (menu_driver_data->core_buf) free(menu_driver_data->core_buf); - menu_driver_data->core_buf = NULL; + menu_driver_data->core_buf = NULL; - menu_entries_need_refresh = false; - menu_entries_nonblocking_refresh = false; - menu_entries_begin = 0; + menu_st->entries.need_refresh = false; + menu_st->entries.nonblocking_refresh = false; + menu_st->entries.begin = 0; command_event(CMD_EVENT_HISTORY_DEINIT, NULL); rarch_favorites_deinit(); @@ -2890,7 +2954,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) break; case RARCH_MENU_CTL_UPDATE_THUMBNAIL_PATH: { - size_t selection = menu_driver_selection_ptr; + size_t selection = menu_st->selection_ptr; if (!menu_driver_ctx || !menu_driver_ctx->update_thumbnail_path) return false; @@ -2916,7 +2980,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) break; case RARCH_MENU_CTL_UPDATE_SAVESTATE_THUMBNAIL_PATH: { - size_t selection = menu_driver_selection_ptr; + size_t selection = menu_st->selection_ptr; if (!menu_driver_ctx || !menu_driver_ctx->update_savestate_thumbnail_path) return false; @@ -2932,10 +2996,10 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) break; case MENU_NAVIGATION_CTL_CLEAR: { - bool *pending_push = (bool*)data; + bool *pending_push = (bool*)data; /* Always set current selection to first entry */ - menu_driver_selection_ptr = 0; + menu_st->selection_ptr = 0; /* menu_driver_navigation_set() will be called * at the next 'push'. @@ -2958,15 +3022,15 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) size_t menu_list_size = menu_entries_get_size(); bool wraparound_enable = settings->bools.menu_navigation_wraparound_enable; - if (menu_driver_selection_ptr >= menu_list_size - 1 + if (menu_st->selection_ptr >= menu_list_size - 1 && !wraparound_enable) return false; - if ((menu_driver_selection_ptr + scroll_speed) < menu_list_size) + if ((menu_st->selection_ptr + scroll_speed) < menu_list_size) { - size_t idx = menu_driver_selection_ptr + scroll_speed; + size_t idx = menu_st->selection_ptr + scroll_speed; - menu_driver_selection_ptr = idx; + menu_st->selection_ptr = idx; menu_driver_navigation_set(true); } else @@ -2992,11 +3056,11 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) size_t menu_list_size = menu_entries_get_size(); bool wraparound_enable = settings->bools.menu_navigation_wraparound_enable; - if (menu_driver_selection_ptr == 0 && !wraparound_enable) + if (menu_st->selection_ptr == 0 && !wraparound_enable) return false; - if (menu_driver_selection_ptr >= scroll_speed) - idx = menu_driver_selection_ptr - scroll_speed; + if (menu_st->selection_ptr >= scroll_speed) + idx = menu_st->selection_ptr - scroll_speed; else { idx = menu_list_size - 1; @@ -3004,7 +3068,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) idx = 0; } - menu_driver_selection_ptr = idx; + menu_st->selection_ptr = idx; menu_driver_navigation_set(true); if (menu_driver_ctx->navigation_decrement) @@ -3015,7 +3079,8 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) { size_t menu_list_size = menu_entries_get_size(); size_t new_selection = menu_list_size - 1; - menu_driver_selection_ptr = new_selection; + + menu_st->selection_ptr = new_selection; if (menu_driver_ctx->navigation_set_last) menu_driver_ctx->navigation_set_last(menu_userdata); @@ -3026,48 +3091,48 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) size_t i = 0; size_t menu_list_size = menu_entries_get_size(); - if (!scroll_index_size) + if (!menu_st->scroll.index_size) return false; - if (menu_driver_selection_ptr == scroll_index_list[scroll_index_size - 1]) - menu_driver_selection_ptr = menu_list_size - 1; + if (menu_st->selection_ptr == menu_st->scroll.index_list[menu_st->scroll.index_size - 1]) + menu_st->selection_ptr = menu_list_size - 1; else { - while (i < scroll_index_size - 1 - && scroll_index_list[i + 1] <= menu_driver_selection_ptr) + while (i < menu_st->scroll.index_size - 1 + && menu_st->scroll.index_list[i + 1] <= menu_st->selection_ptr) i++; - menu_driver_selection_ptr = scroll_index_list[i + 1]; + menu_st->selection_ptr = menu_st->scroll.index_list[i + 1]; - if (menu_driver_selection_ptr >= menu_list_size) - menu_driver_selection_ptr = menu_list_size - 1; + if (menu_st->selection_ptr >= menu_list_size) + menu_st->selection_ptr = menu_list_size - 1; } if (menu_driver_ctx->navigation_ascend_alphabet) menu_driver_ctx->navigation_ascend_alphabet( - menu_userdata, &menu_driver_selection_ptr); + menu_userdata, &menu_st->selection_ptr); } break; case MENU_NAVIGATION_CTL_DESCEND_ALPHABET: { size_t i = 0; - if (!scroll_index_size) + if (!menu_st->scroll.index_size) return false; - if (menu_driver_selection_ptr == 0) + if (menu_st->selection_ptr == 0) return false; - i = scroll_index_size - 1; + i = menu_st->scroll.index_size - 1; - while (i && scroll_index_list[i - 1] >= menu_driver_selection_ptr) + while (i && menu_st->scroll.index_list[i - 1] >= menu_st->selection_ptr) i--; if (i > 0) - menu_driver_selection_ptr = scroll_index_list[i - 1]; + menu_st->selection_ptr = menu_st->scroll.index_list[i - 1]; if (menu_driver_ctx->navigation_descend_alphabet) menu_driver_ctx->navigation_descend_alphabet( - menu_userdata, &menu_driver_selection_ptr); + menu_userdata, &menu_st->selection_ptr); } break; case MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL: @@ -3075,7 +3140,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) size_t *sel = (size_t*)data; if (!sel) return false; - *sel = scroll_acceleration; + *sel = menu_st->scroll.acceleration; } break; case MENU_NAVIGATION_CTL_SET_SCROLL_ACCEL: @@ -3083,7 +3148,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) size_t *sel = (size_t*)data; if (!sel) return false; - scroll_acceleration = (unsigned)(*sel); + menu_st->scroll.acceleration = (unsigned)(*sel); } break; default: From d4dd1f71a5aacc0da6bcb7bff1899764b39c69d6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 19 May 2020 14:59:06 +0200 Subject: [PATCH 110/192] (menu_displaylist.c) Move state into struct --- menu/menu_displaylist.c | 71 +++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 6fcd6cc379..52fa8005cc 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -101,13 +101,6 @@ #include "../runtime_file.h" #include "../manual_content_scan.h" -/* TODO/FIXME - globals - need to find a way to - * get rid of these */ -static char new_path_entry[4096] = {0}; -static char new_lbl_entry[4096] = {0}; -static char new_entry[4096] = {0}; -static enum msg_hash_enums new_type = MSG_UNKNOWN; - #define menu_displaylist_parse_settings_enum(list, label, parse_type, add_empty_entry) menu_displaylist_parse_settings_internal_enum(list, parse_type, add_empty_entry, menu_setting_find_enum(label), label, true) #define menu_displaylist_parse_settings(list, label, parse_type, add_empty_entry, entry_type) menu_displaylist_parse_settings_internal_enum(list, parse_type, add_empty_entry, menu_setting_find(label), entry_type, false) @@ -124,6 +117,18 @@ static enum msg_hash_enums new_type = MSG_UNKNOWN; #endif #endif +/* TODO/FIXME - globals - need to find a way to + * get rid of these */ +struct menu_displaylist_state +{ + enum msg_hash_enums new_type; + char new_path_entry[4096]; + char new_lbl_entry[4096]; + char new_entry[4096]; +}; + +static struct menu_displaylist_state menu_displist_st; + static int menu_displaylist_parse_core_info(file_list_t *list) { char tmp[PATH_MAX_LENGTH]; @@ -3685,9 +3690,10 @@ static void wifi_scan_callback(retro_task_t *task, bool menu_displaylist_process(menu_displaylist_info_t *info) { - size_t idx = 0; + size_t idx = 0; + struct menu_displaylist_state *p_displist = &menu_displist_st; #if defined(HAVE_NETWORKING) - settings_t *settings = config_get_ptr(); + settings_t *settings = config_get_ptr(); #endif if (info->need_navigation_clear) @@ -3757,20 +3763,20 @@ bool menu_displaylist_process(menu_displaylist_info_t *info) #endif } - if (!string_is_empty(new_entry)) + if (!string_is_empty(p_displist->new_entry)) { menu_entries_prepend(info->list, - new_path_entry, - new_lbl_entry, - new_type, + p_displist->new_path_entry, + p_displist->new_lbl_entry, + p_displist->new_type, FILE_TYPE_CORE, 0, 0); file_list_set_alt_at_offset(info->list, 0, - new_entry); + p_displist->new_entry); - new_type = MSG_UNKNOWN; - new_lbl_entry[0] = '\0'; - new_path_entry[0] = '\0'; - new_entry[0] = '\0'; + p_displist->new_type = MSG_UNKNOWN; + p_displist->new_lbl_entry[0] = '\0'; + p_displist->new_path_entry[0] = '\0'; + p_displist->new_entry[0] = '\0'; } if (info->need_refresh) @@ -9201,7 +9207,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, if (cores_names_size != 0) { - unsigned j = 0; + unsigned j = 0; + struct menu_displaylist_state + *p_displist = &menu_displist_st; struct string_list *cores_paths = string_list_new_special(STRING_LIST_SUPPORTED_CORES_PATHS, (void*)menu->deferred_path, @@ -9215,12 +9223,16 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, if ( !path_is_empty(RARCH_PATH_CORE) && string_is_equal(core_path, path_get(RARCH_PATH_CORE))) { - strlcpy(new_path_entry, core_path, sizeof(new_path_entry)); - snprintf(new_entry, sizeof(new_entry), "%s (%s)", + strlcpy(p_displist->new_path_entry, + core_path, sizeof(p_displist->new_path_entry)); + snprintf(p_displist->new_entry, + sizeof(p_displist->new_entry), "%s (%s)", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DETECT_CORE_LIST_OK_CURRENT_CORE), core_name); - strlcpy(new_lbl_entry, core_path, sizeof(new_lbl_entry)); - new_type = MENU_ENUM_LABEL_DETECT_CORE_LIST_OK_CURRENT_CORE; + strlcpy(p_displist->new_lbl_entry, + core_path, sizeof(p_displist->new_lbl_entry)); + p_displist->new_type = + MENU_ENUM_LABEL_DETECT_CORE_LIST_OK_CURRENT_CORE; } else if (core_path) { @@ -9296,6 +9308,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, if (cores_names_size != 0) { unsigned j = 0; + struct menu_displaylist_state + *p_displist = &menu_displist_st; struct string_list *cores_paths = string_list_new_special(STRING_LIST_SUPPORTED_CORES_PATHS, (void*)menu->deferred_path, @@ -9309,12 +9323,15 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, if ( !path_is_empty(RARCH_PATH_CORE) && string_is_equal(core_path, path_get(RARCH_PATH_CORE))) { - strlcpy(new_path_entry, core_path, sizeof(new_path_entry)); - snprintf(new_entry, sizeof(new_entry), "%s (%s)", + strlcpy(p_displist->new_path_entry, + core_path, sizeof(p_displist->new_path_entry)); + snprintf(p_displist->new_entry, + sizeof(p_displist->new_entry), "%s (%s)", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DETECT_CORE_LIST_OK_CURRENT_CORE), core_name); - new_lbl_entry[0] = '\0'; - new_type = MENU_ENUM_LABEL_FILE_BROWSER_CORE_SELECT_FROM_COLLECTION_CURRENT_CORE; + p_displist->new_lbl_entry[0] = '\0'; + p_displist->new_type = + MENU_ENUM_LABEL_FILE_BROWSER_CORE_SELECT_FROM_COLLECTION_CURRENT_CORE; } else if (core_path) { From 5eee8daa4f7dbf594fb9af439154180d6cc6fa62 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Tue, 19 May 2020 13:48:05 +0100 Subject: [PATCH 111/192] (gfx_thumbnail) Fix heap-use-after-free error --- gfx/gfx_thumbnail.c | 30 ++++++++++++++++++++++-------- gfx/gfx_thumbnail.h | 1 + 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/gfx/gfx_thumbnail.c b/gfx/gfx_thumbnail.c index 72a42cdae4..ad14c13557 100644 --- a/gfx/gfx_thumbnail.c +++ b/gfx/gfx_thumbnail.c @@ -155,6 +155,18 @@ bool gfx_thumbnail_get_fade_missing(bool fade_missing) /* Callbacks */ +/* Fade animation callback - simply resets thumbnail + * 'fade_active' status */ +static void gfx_thumbnail_fade_cb(void *userdata) +{ + gfx_thumbnail_t *thumbnail = (gfx_thumbnail_t*)userdata; + + if (!thumbnail) + return; + + thumbnail->fade_active = false; +} + /* Initialises thumbnail 'fade in' animation */ static void gfx_thumbnail_init_fade(gfx_thumbnail_t *thumbnail) { @@ -175,15 +187,16 @@ static void gfx_thumbnail_init_fade(gfx_thumbnail_t *thumbnail) { gfx_animation_ctx_entry_t animation_entry; - thumbnail->alpha = 0.0f; + thumbnail->alpha = 0.0f; + thumbnail->fade_active = true; animation_entry.easing_enum = EASING_OUT_QUAD; animation_entry.tag = (uintptr_t)&thumbnail->alpha; animation_entry.duration = p_gfx_thumb->fade_duration; animation_entry.target_value = 1.0f; animation_entry.subject = &thumbnail->alpha; - animation_entry.cb = NULL; - animation_entry.userdata = NULL; + animation_entry.cb = gfx_thumbnail_fade_cb; + animation_entry.userdata = thumbnail; gfx_animation_push(&animation_entry); } @@ -449,14 +462,14 @@ void gfx_thumbnail_reset(gfx_thumbnail_t *thumbnail) if (!thumbnail) return; + /* Unload texture */ if (thumbnail->texture) - { - gfx_animation_ctx_tag tag = (uintptr_t)&thumbnail->alpha; - - /* Unload texture */ video_driver_texture_unload(&thumbnail->texture); - /* Ensure any 'fade in' animation is killed */ + /* Ensure any 'fade in' animation is killed */ + if (thumbnail->fade_active) + { + gfx_animation_ctx_tag tag = (uintptr_t)&thumbnail->alpha; gfx_animation_kill_by_tag(&tag); } @@ -467,6 +480,7 @@ void gfx_thumbnail_reset(gfx_thumbnail_t *thumbnail) thumbnail->height = 0; thumbnail->alpha = 0.0f; thumbnail->delay_timer = 0.0f; + thumbnail->fade_active = false; } /* Stream processing */ diff --git a/gfx/gfx_thumbnail.h b/gfx/gfx_thumbnail.h index 1c27041a75..50d0a1af67 100644 --- a/gfx/gfx_thumbnail.h +++ b/gfx/gfx_thumbnail.h @@ -72,6 +72,7 @@ typedef struct unsigned height; float alpha; float delay_timer; + bool fade_active; } gfx_thumbnail_t; /* Holds all configuration parameters associated From 8c63ea251506f1b243d3a0642af282ba802bc1ea Mon Sep 17 00:00:00 2001 From: Autechre Date: Tue, 19 May 2020 15:14:24 +0200 Subject: [PATCH 112/192] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index c14d7af0bf..51dcf8e202 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ - CHEEVOS: Disable hardcore when cheats are enabled - CHD: Return false when special track cannot be found - INPUT MAPPING/REMAPPING: Restore broken 'reset to default' functionality with RetroPad 'start' button +- MENU/THUMBNAILS/BUGFIX: Fix heap-use-after-free error - WIIU: Gamepad hotplugging support - WIIU: Theoretical multi-gamepad support From 0aff65e77b69f241b45905f323413e84b9693610 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 19 May 2020 15:22:00 +0200 Subject: [PATCH 113/192] Sync libretro-common --- .../vfs/vfs_implementation_cdrom.c | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/libretro-common/vfs/vfs_implementation_cdrom.c b/libretro-common/vfs/vfs_implementation_cdrom.c index b6398796ac..a9f402a8e3 100644 --- a/libretro-common/vfs/vfs_implementation_cdrom.c +++ b/libretro-common/vfs/vfs_implementation_cdrom.c @@ -340,25 +340,15 @@ int64_t retro_vfs_file_read_cdrom(libretro_vfs_implementation_file *stream, if (string_is_equal_noncase(ext, "cue")) { - if ((int64_t)len < (int64_t)stream->cdrom.cue_len - stream->cdrom.byte_pos) - { + if ((int64_t)len >= (int64_t)stream->cdrom.cue_len - stream->cdrom.byte_pos) len = stream->cdrom.cue_len - stream->cdrom.byte_pos - 1; #ifdef CDROM_DEBUG - printf("[CDROM] Read: Reading %" PRIu64 " bytes from cuesheet starting at %" PRIu64 "...\n", len, stream->cdrom.byte_pos); - fflush(stdout); + printf("[CDROM] Read: Reading %" PRIu64 " bytes from cuesheet starting at %" PRIu64 "...\n", len, stream->cdrom.byte_pos); + fflush(stdout); #endif - memcpy(s, stream->cdrom.cue_buf + stream->cdrom.byte_pos, len); - stream->cdrom.byte_pos += len; + memcpy(s, stream->cdrom.cue_buf + stream->cdrom.byte_pos, len); + stream->cdrom.byte_pos += len; - return len; - } - else - { -#ifdef CDROM_DEBUG - printf("[CDROM] Read: Reading %" PRIu64 " bytes from cuesheet starting at %" PRIu64 " failed.\n", len, stream->cdrom.byte_pos); - fflush(stdout); -#endif - return 0; - } + return len; } else if (string_is_equal_noncase(ext, "bin")) { From 9ace693ec0c4550793e73b89617be8bedac6261e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 19 May 2020 16:20:43 +0200 Subject: [PATCH 114/192] Refactor menu_driver_frame --- gfx/common/metal_common.m | 4 +- gfx/drivers/caca_gfx.c | 2 +- gfx/drivers/ctr_gfx.c | 5 +- gfx/drivers/d3d10.c | 3 +- gfx/drivers/d3d11.c | 3 +- gfx/drivers/d3d12.c | 3 +- gfx/drivers/d3d8.c | 3 +- gfx/drivers/d3d9.c | 4 +- gfx/drivers/dispmanx_gfx.c | 3 +- gfx/drivers/drm_gfx.c | 3 +- gfx/drivers/exynos_gfx.c | 21 ++- gfx/drivers/fpga_gfx.c | 3 +- gfx/drivers/gdi_gfx.c | 3 +- gfx/drivers/gl.c | 3 +- gfx/drivers/gl1.c | 37 ++-- gfx/drivers/gl_core.c | 4 +- gfx/drivers/gx2_gfx.c | 89 ++++----- gfx/drivers/gx_gfx.c | 5 +- gfx/drivers/network_gfx.c | 35 ++-- gfx/drivers/oga_gfx.c | 337 +++++++++++++++++++---------------- gfx/drivers/omap_gfx.c | 7 +- gfx/drivers/psp1_gfx.c | 5 +- gfx/drivers/sdl2_gfx.c | 8 +- gfx/drivers/sdl_dingux_gfx.c | 97 +++++----- gfx/drivers/sdl_gfx.c | 7 +- gfx/drivers/sixel_gfx.c | 3 +- gfx/drivers/sunxi_gfx.c | 3 +- gfx/drivers/switch_gfx.c | 33 ++-- gfx/drivers/switch_nx_gfx.c | 211 +++++++++++----------- gfx/drivers/vg.c | 7 +- gfx/drivers/vga_gfx.c | 3 +- gfx/drivers/vita2d_gfx.c | 3 +- gfx/drivers/vulkan.c | 3 +- gfx/drivers/xenon360_gfx.c | 5 +- gfx/drivers/xshm_gfx.c | 11 +- gfx/drivers/xvideo.c | 3 +- menu/menu_driver.c | 3 +- menu/menu_driver.h | 2 +- 38 files changed, 528 insertions(+), 456 deletions(-) diff --git a/gfx/common/metal_common.m b/gfx/common/metal_common.m index a785d92a09..db3161fb69 100644 --- a/gfx/common/metal_common.m +++ b/gfx/common/metal_common.m @@ -443,6 +443,8 @@ - (void)_drawMenu:(video_frame_info_t *)video_info { + bool menu_is_alive = video_info->menu_is_alive; + if (!_menu.enabled) return; @@ -470,7 +472,7 @@ { [rce pushDebugGroup:@"menu"]; [_context resetRenderViewport:kFullscreenViewport]; - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); [rce popDebugGroup]; } #endif diff --git a/gfx/drivers/caca_gfx.c b/gfx/drivers/caca_gfx.c index 14bb65b0c7..fb3ee1c8ae 100644 --- a/gfx/drivers/caca_gfx.c +++ b/gfx/drivers/caca_gfx.c @@ -141,7 +141,7 @@ static bool caca_gfx_frame(void *data, const void *frame, caca_clear_canvas(caca->cv); #ifdef HAVE_MENU - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); #endif if (msg) diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index a7c4318267..1cda23d1b2 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -546,7 +546,7 @@ static bool ctr_frame(void* data, const void* frame, int custom_vp_y = video_info->custom_vp_y; unsigned custom_vp_width = video_info->custom_vp_width; unsigned custom_vp_height = video_info->custom_vp_height; - + bool menu_is_alive = video_info->menu_is_alive; if (!width || !height || !settings) { @@ -873,9 +873,8 @@ static bool ctr_frame(void* data, const void* frame, } ctr->msg_rendering_enabled = true; - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); ctr->msg_rendering_enabled = false; - } else if (statistics_show) { diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c index 8b15738328..d33c03bd4a 100644 --- a/gfx/drivers/d3d10.c +++ b/gfx/drivers/d3d10.c @@ -1211,6 +1211,7 @@ static bool d3d10_gfx_frame( *osd_params = (struct font_params*) &video_info->osd_stat_params; const char *stat_text = video_info->stat_text; + bool menu_is_alive = video_info->menu_is_alive; if (d3d10->resize_chain) { @@ -1471,7 +1472,7 @@ static bool d3d10_gfx_frame( #ifdef HAVE_MENU if (d3d10->menu.enabled) - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); else #endif if (statistics_show) diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index ab7232e78b..905edc92a3 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -1290,6 +1290,7 @@ static bool d3d11_gfx_frame( unsigned video_height = video_info->height; bool statistics_show = video_info->statistics_show; struct font_params* osd_params = (struct font_params*)&video_info->osd_stat_params; + bool menu_is_alive = video_info->menu_is_alive; if (d3d11->resize_chain) { @@ -1544,7 +1545,7 @@ static bool d3d11_gfx_frame( #ifdef HAVE_MENU if (d3d11->menu.enabled) - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); else #endif if (statistics_show) diff --git a/gfx/drivers/d3d12.c b/gfx/drivers/d3d12.c index 74c12da9cc..d43ac7cb59 100644 --- a/gfx/drivers/d3d12.c +++ b/gfx/drivers/d3d12.c @@ -1174,6 +1174,7 @@ static bool d3d12_gfx_frame( unsigned video_height = video_info->height; struct font_params *osd_params = (struct font_params*) &video_info->osd_stat_params; + bool menu_is_alive = video_info->menu_is_alive; d3d12_gfx_sync(d3d12); @@ -1513,7 +1514,7 @@ static bool d3d12_gfx_frame( #ifdef HAVE_MENU if (d3d12->menu.enabled) - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); else #endif if (statistics_show) diff --git a/gfx/drivers/d3d8.c b/gfx/drivers/d3d8.c index 0b25f82977..1e3ca02e73 100644 --- a/gfx/drivers/d3d8.c +++ b/gfx/drivers/d3d8.c @@ -1489,6 +1489,7 @@ static bool d3d8_frame(void *data, const void *frame, const char *stat_text = video_info->stat_text; bool statistics_show = video_info->statistics_show; bool black_frame_insertion = video_info->black_frame_insertion; + bool menu_is_alive = video_info->menu_is_alive; (void)i; @@ -1556,7 +1557,7 @@ static bool d3d8_frame(void *data, const void *frame, d3d8_set_stream_source(d3d->dev, 0, d3d->menu_display.buffer, 0, sizeof(Vertex)); d3d8_set_viewports(d3d->dev, &screen_vp); - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); } else if (statistics_show) { diff --git a/gfx/drivers/d3d9.c b/gfx/drivers/d3d9.c index f7d93a0b5e..044bcacf32 100644 --- a/gfx/drivers/d3d9.c +++ b/gfx/drivers/d3d9.c @@ -1532,7 +1532,7 @@ static bool d3d9_frame(void *data, const void *frame, struct font_params *osd_params = (struct font_params*) &video_info->osd_stat_params; const char *stat_text = video_info->stat_text; - + bool menu_is_alive = video_info->menu_is_alive; if (!frame) return true; @@ -1602,7 +1602,7 @@ static bool d3d9_frame(void *data, const void *frame, d3d9_set_stream_source(d3d->dev, 0, (LPDIRECT3DVERTEXBUFFER9)d3d->menu_display.buffer, 0, sizeof(Vertex)); d3d9_set_viewports(d3d->dev, &screen_vp); - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); } else if (statistics_show) { diff --git a/gfx/drivers/dispmanx_gfx.c b/gfx/drivers/dispmanx_gfx.c index 0466dfc952..941065a038 100644 --- a/gfx/drivers/dispmanx_gfx.c +++ b/gfx/drivers/dispmanx_gfx.c @@ -439,6 +439,7 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width, struct dispmanx_video *_dispvars = data; float aspect = video_driver_get_aspect_ratio(); unsigned max_swapchain_images = video_info->max_swapchain_images; + bool menu_is_alive = video_info->menu_is_alive; if (!frame) return true; @@ -480,7 +481,7 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width, } #ifdef HAVE_MENU - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); #endif /* Update main surface: locate free page, blit and flip. */ diff --git a/gfx/drivers/drm_gfx.c b/gfx/drivers/drm_gfx.c index 37fabae169..3f18f46410 100644 --- a/gfx/drivers/drm_gfx.c +++ b/gfx/drivers/drm_gfx.c @@ -757,6 +757,7 @@ static bool drm_gfx_frame(void *data, const void *frame, unsigned width, video_frame_info_t *video_info) { struct drm_video *_drmvars = data; + bool menu_is_alive = video_info->menu_is_alive; if ( ( width != _drmvars->core_width) || (height != _drmvars->core_height)) @@ -790,7 +791,7 @@ static bool drm_gfx_frame(void *data, const void *frame, unsigned width, } #ifdef HAVE_MENU - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); #endif /* Update main surface: locate free page, blit and flip. */ diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index bfb92226a5..d81e29b1ba 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -902,10 +902,13 @@ static void exynos_set_fake_blit(struct exynos_data *pdata) pdata->pages[i].clear = true; } -static int exynos_blit_frame(struct exynos_data *pdata, const void *frame, - unsigned src_pitch) +static int exynos_blit_frame( + struct exynos_data *pdata, + const void *frame, + unsigned src_pitch) { - const enum exynos_buffer_type buf_type = defaults[EXYNOS_IMAGE_FRAME].buf_type; + const enum exynos_buffer_type + buf_type = defaults[EXYNOS_IMAGE_FRAME].buf_type; const unsigned size = src_pitch * pdata->blit_params[5]; struct g2d_image *src = pdata->src[EXYNOS_IMAGE_FRAME]; @@ -1280,12 +1283,13 @@ static bool exynos_gfx_frame(void *data, const void *frame, unsigned width, { struct exynos_video *vid = data; struct exynos_page *page = NULL; + bool menu_is_alive = video_info->menu_is_alive; /* Check if neither menu nor core framebuffer is to be displayed. */ if (!vid->menu_active && !frame) return true; - if (frame != NULL) + if (frame) { if (width != vid->width || height != vid->height) { @@ -1315,15 +1319,16 @@ static bool exynos_gfx_frame(void *data, const void *frame, unsigned width, if (!page) page = exynos_free_page(vid->data); +#ifdef HAVE_MENU if (vid->menu_active) { if (exynos_blend_menu(vid->data, vid->menu_rotation) != 0) goto fail; -#ifdef HAVE_MENU - menu_driver_frame(video_info); -#endif + menu_driver_frame(menu_is_alive, video_info); } - else if (video_info->statistics_show) + else +#endif + if (video_info->statistics_show) { struct font_params *osd_params = video_info ? (struct font_params*)&video_info->osd_stat_params : NULL; diff --git a/gfx/drivers/fpga_gfx.c b/gfx/drivers/fpga_gfx.c index 25c5e8995e..2e6ebd7c58 100644 --- a/gfx/drivers/fpga_gfx.c +++ b/gfx/drivers/fpga_gfx.c @@ -209,12 +209,13 @@ static bool fpga_gfx_frame(void *data, const void *frame, bool draw = true; fpga_t *fpga = (fpga_t*)data; unsigned bits = fpga->video_bits; + bool menu_is_alive = video_info->menu_is_alive; if (!frame || !frame_width || !frame_height) return true; #ifdef HAVE_MENU - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); #endif if ( fpga->video_width != frame_width || diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c index 73cf5fcb8c..a3251f8f82 100644 --- a/gfx/drivers/gdi_gfx.c +++ b/gfx/drivers/gdi_gfx.c @@ -189,6 +189,7 @@ static bool gdi_gfx_frame(void *data, const void *frame, gdi_t *gdi = (gdi_t*)data; unsigned bits = gdi->video_bits; HWND hwnd = win32_get_window(); + bool menu_is_alive = video_info->menu_is_alive; /* FIXME: Force these settings off as they interfere with the rendering */ video_info->xmb_shadows_enable = false; @@ -198,7 +199,7 @@ static bool gdi_gfx_frame(void *data, const void *frame, return true; #ifdef HAVE_MENU - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); #endif if ( gdi->video_width != frame_width || diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 770dcd22c4..d0632baed1 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2829,6 +2829,7 @@ static bool gl2_frame(void *data, const void *frame, struct font_params *osd_params = (struct font_params*) &video_info->osd_stat_params; const char *stat_text = video_info->stat_text; + bool menu_is_alive = video_info->menu_is_alive; if (!gl) return false; @@ -3036,7 +3037,7 @@ static bool gl2_frame(void *data, const void *frame, #if defined(HAVE_MENU) if (gl->menu_texture_enable) { - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); if (gl->menu_texture) gl2_draw_texture(gl); diff --git a/gfx/drivers/gl1.c b/gfx/drivers/gl1.c index 7fe9ac35d6..fc0d1e11f7 100644 --- a/gfx/drivers/gl1.c +++ b/gfx/drivers/gl1.c @@ -696,6 +696,7 @@ static bool gl1_gfx_frame(void *data, const void *frame, unsigned pot_height = 0; unsigned video_width = video_info->width; unsigned video_height = video_info->height; + bool menu_is_alive = video_info->menu_is_alive; gl1_context_bind_hw_render(gl1, false); @@ -790,9 +791,8 @@ static bool gl1_gfx_frame(void *data, const void *frame, if (draw) { if (frame_to_copy) - { - draw_tex(gl1, pot_width, pot_height, width, height, gl1->tex, frame_to_copy); - } + draw_tex(gl1, pot_width, pot_height, + width, height, gl1->tex, frame_to_copy); } if (gl1->menu_frame && video_info->menu_is_alive) @@ -837,25 +837,26 @@ static bool gl1_gfx_frame(void *data, const void *frame, #ifdef HAVE_MENU if (gl1->menu_texture_enable) - menu_driver_frame(video_info); - else if (video_info->statistics_show) - { - struct font_params *osd_params = (struct font_params*) - &video_info->osd_stat_params; - - if (osd_params) + menu_driver_frame(menu_is_alive, video_info); + else +#endif + if (video_info->statistics_show) { - font_driver_render_msg(gl1, video_info->stat_text, - (const struct font_params*)&video_info->osd_stat_params, NULL); + struct font_params *osd_params = (struct font_params*) + &video_info->osd_stat_params; + + if (osd_params) + { + font_driver_render_msg(gl1, video_info->stat_text, + (const struct font_params*)&video_info->osd_stat_params, NULL); #if 0 - osd_params->y = 0.350f; - osd_params->scale = 0.75f; - font_driver_render_msg(gl1, video_info->chat_text, - (const struct font_params*)&video_info->osd_stat_params, NULL); + osd_params->y = 0.350f; + osd_params->scale = 0.75f; + font_driver_render_msg(gl1, video_info->chat_text, + (const struct font_params*)&video_info->osd_stat_params, NULL); #endif + } } - } -#endif #ifdef HAVE_GFX_WIDGETS gfx_widgets_frame(video_info); diff --git a/gfx/drivers/gl_core.c b/gfx/drivers/gl_core.c index fa98c8332b..4d01e9ab3a 100644 --- a/gfx/drivers/gl_core.c +++ b/gfx/drivers/gl_core.c @@ -1850,6 +1850,8 @@ static bool gl_core_frame(void *data, const void *frame, bool runloop_is_paused = video_info->runloop_is_paused; bool runloop_is_slowmotion = video_info->runloop_is_slowmotion; bool input_driver_nonblock_state = video_info->input_driver_nonblock_state; + bool menu_is_alive = video_info->menu_is_alive; + if (!gl) return false; @@ -1919,7 +1921,7 @@ static bool gl_core_frame(void *data, const void *frame, #if defined(HAVE_MENU) if (gl->menu_texture_enable) { - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); if (gl->menu_texture_enable && gl->menu_texture) gl_core_draw_menu_texture(gl, width, height); } diff --git a/gfx/drivers/gx2_gfx.c b/gfx/drivers/gx2_gfx.c index d0bf29ec8e..1cac6587c2 100644 --- a/gfx/drivers/gx2_gfx.c +++ b/gfx/drivers/gx2_gfx.c @@ -1140,44 +1140,45 @@ static bool wiiu_gfx_frame(void *data, const void *frame, if (wiiu->shader_preset) { + unsigned i; int32_t frame_direction = state_manager_frame_is_reversed() ? -1 : 1; - for (int i = 0; i < wiiu->shader_preset->passes; i++) + for (i = 0; i < wiiu->shader_preset->passes; i++) { - + unsigned j; GX2SetVertexShader(wiiu->pass[i].gfd->vs); - for (int j = 0; j < 2 && j < wiiu->pass[i].gfd->vs->uniformBlockCount; j++) + for (j = 0; j < 2 && j < wiiu->pass[i].gfd->vs->uniformBlockCount; j++) { wiiu_gfx_update_uniform_block(wiiu, i, wiiu->pass[i].vs_ubos[j], j, - wiiu->pass[i].gfd->vs->uniformBlocks[j].size, - wiiu->pass[i].gfd->vs->uniformVarCount, wiiu->pass[i].gfd->vs->uniformVars, - frame_count, frame_direction); + wiiu->pass[i].gfd->vs->uniformBlocks[j].size, + wiiu->pass[i].gfd->vs->uniformVarCount, wiiu->pass[i].gfd->vs->uniformVars, + frame_count, frame_direction); GX2SetVertexUniformBlock(wiiu->pass[i].gfd->vs->uniformBlocks[j].offset, - wiiu->pass[i].gfd->vs->uniformBlocks[j].size, wiiu->pass[i].vs_ubos[j]); + wiiu->pass[i].gfd->vs->uniformBlocks[j].size, wiiu->pass[i].vs_ubos[j]); } GX2SetPixelShader(wiiu->pass[i].gfd->ps); - for (int j = 0; j < 2 && j < wiiu->pass[i].gfd->ps->uniformBlockCount; j++) + for (j = 0; j < 2 && j < wiiu->pass[i].gfd->ps->uniformBlockCount; j++) { wiiu_gfx_update_uniform_block(wiiu, i, wiiu->pass[i].ps_ubos[j], j, - wiiu->pass[i].gfd->ps->uniformBlocks[j].size, - wiiu->pass[i].gfd->ps->uniformVarCount, wiiu->pass[i].gfd->ps->uniformVars, - frame_count, frame_direction); + wiiu->pass[i].gfd->ps->uniformBlocks[j].size, + wiiu->pass[i].gfd->ps->uniformVarCount, wiiu->pass[i].gfd->ps->uniformVars, + frame_count, frame_direction); GX2SetPixelUniformBlock(wiiu->pass[i].gfd->ps->uniformBlocks[j].offset, - wiiu->pass[i].gfd->ps->uniformBlocks[j].size, wiiu->pass[i].ps_ubos[j]); + wiiu->pass[i].gfd->ps->uniformBlocks[j].size, wiiu->pass[i].ps_ubos[j]); } - for (int j = 0; j < wiiu->pass[i].gfd->ps->samplerVarCount; j++) + for (j = 0; j < wiiu->pass[i].gfd->ps->samplerVarCount; j++) { if (string_is_equal(wiiu->pass[i].gfd->ps->samplerVars[j].name, "Source")) { GX2SetPixelTexture(texture, wiiu->pass[i].gfd->ps->samplerVars[j].location); GX2SetPixelSampler(wiiu->shader_preset->pass[i].filter ? - &wiiu->sampler_linear[wiiu->shader_preset->pass[i].wrap] : - &wiiu->sampler_nearest[wiiu->shader_preset->pass[i].wrap], - wiiu->pass[i].gfd->ps->samplerVars[j].location); + &wiiu->sampler_linear[wiiu->shader_preset->pass[i].wrap] : + &wiiu->sampler_nearest[wiiu->shader_preset->pass[i].wrap], + wiiu->pass[i].gfd->ps->samplerVars[j].location); continue; } @@ -1185,9 +1186,9 @@ static bool wiiu_gfx_frame(void *data, const void *frame, { GX2SetPixelTexture(&wiiu->texture, wiiu->pass[i].gfd->ps->samplerVars[j].location); GX2SetPixelSampler(wiiu->shader_preset->pass[0].filter ? - &wiiu->sampler_linear[wiiu->shader_preset->pass[0].wrap] : - &wiiu->sampler_nearest[wiiu->shader_preset->pass[0].wrap], - wiiu->pass[i].gfd->ps->samplerVars[j].location); + &wiiu->sampler_linear[wiiu->shader_preset->pass[0].wrap] : + &wiiu->sampler_nearest[wiiu->shader_preset->pass[0].wrap], + wiiu->pass[i].gfd->ps->samplerVars[j].location); continue; } @@ -1203,9 +1204,9 @@ static bool wiiu_gfx_frame(void *data, const void *frame, GX2Texture *source = (index > 0) ? &wiiu->pass[index - 1].texture : &wiiu->texture; GX2SetPixelTexture(source, wiiu->pass[i].gfd->ps->samplerVars[j].location); GX2SetPixelSampler(wiiu->shader_preset->pass[index].filter ? - &wiiu->sampler_linear[wiiu->shader_preset->pass[index].wrap] : - &wiiu->sampler_nearest[wiiu->shader_preset->pass[index].wrap], - wiiu->pass[i].gfd->ps->samplerVars[j].location); + &wiiu->sampler_linear[wiiu->shader_preset->pass[index].wrap] : + &wiiu->sampler_nearest[wiiu->shader_preset->pass[index].wrap], + wiiu->pass[i].gfd->ps->samplerVars[j].location); continue; } @@ -1216,9 +1217,9 @@ static bool wiiu_gfx_frame(void *data, const void *frame, index = i - 1; GX2SetPixelTexture(&wiiu->pass[index].texture, wiiu->pass[i].gfd->ps->samplerVars[j].location); GX2SetPixelSampler(wiiu->shader_preset->pass[index].filter ? - &wiiu->sampler_linear[wiiu->shader_preset->pass[index].wrap] : - &wiiu->sampler_nearest[wiiu->shader_preset->pass[index].wrap], - wiiu->pass[i].gfd->ps->samplerVars[j].location); + &wiiu->sampler_linear[wiiu->shader_preset->pass[index].wrap] : + &wiiu->sampler_nearest[wiiu->shader_preset->pass[index].wrap], + wiiu->pass[i].gfd->ps->samplerVars[j].location); continue; } @@ -1231,9 +1232,9 @@ static bool wiiu_gfx_frame(void *data, const void *frame, GX2SetPixelTexture(&wiiu->pass[index].texture, wiiu->pass[i].gfd->ps->samplerVars[j].location); GX2SetPixelSampler(wiiu->shader_preset->pass[i].filter ? - &wiiu->sampler_linear[wiiu->shader_preset->pass[i].wrap] : - &wiiu->sampler_nearest[wiiu->shader_preset->pass[i].wrap], - wiiu->pass[i].gfd->ps->samplerVars[j].location); + &wiiu->sampler_linear[wiiu->shader_preset->pass[i].wrap] : + &wiiu->sampler_nearest[wiiu->shader_preset->pass[i].wrap], + wiiu->pass[i].gfd->ps->samplerVars[j].location); continue; } @@ -1244,9 +1245,9 @@ static bool wiiu_gfx_frame(void *data, const void *frame, { GX2SetPixelTexture(&wiiu->luts[k], wiiu->pass[i].gfd->ps->samplerVars[j].location); GX2SetPixelSampler(wiiu->shader_preset->lut[k].filter ? - &wiiu->sampler_linear[wiiu->shader_preset->lut[k].wrap] : - &wiiu->sampler_nearest[wiiu->shader_preset->lut[k].wrap], - wiiu->pass[i].gfd->ps->samplerVars[j].location); + &wiiu->sampler_linear[wiiu->shader_preset->lut[k].wrap] : + &wiiu->sampler_nearest[wiiu->shader_preset->lut[k].wrap], + wiiu->pass[i].gfd->ps->samplerVars[j].location); } } @@ -1308,12 +1309,11 @@ static bool wiiu_gfx_frame(void *data, const void *frame, 0.0f, 1.0f); #ifdef HAVE_OVERLAY - if (wiiu->overlay_enable) gx2_render_overlay(wiiu); - #endif +#ifdef HAVE_MENU if (wiiu->menu.enable) { GX2SetAttribBuffer(0, 4 * sizeof(*wiiu->menu.v), sizeof(*wiiu->menu.v), wiiu->menu.v); @@ -1325,6 +1325,7 @@ static bool wiiu_gfx_frame(void *data, const void *frame, GX2DrawEx(GX2_PRIMITIVE_MODE_POINTS, 1, 0, 1); } +#endif wiiu->vertex_cache.current = 0; wiiu->vertex_cache_tex.current = 0; @@ -1335,9 +1336,12 @@ static bool wiiu_gfx_frame(void *data, const void *frame, wiiu->render_msg_enabled = true; +#ifdef HAVE_MENU if (wiiu->menu.enable) - menu_driver_frame(video_info); - else if (video_info->statistics_show) + menu_driver_frame(menu_is_alive, video_info); + else +#endif + if (video_info->statistics_show) { struct font_params *osd_params = (struct font_params*) &video_info->osd_stat_params; @@ -1446,6 +1450,7 @@ static bool wiiu_gfx_set_shader(void *data, for (i = 0; i < wiiu->shader_preset->passes; i++) { + unsigned j; char gfdpath[PATH_MAX_LENGTH]; struct video_shader_pass *pass = &wiiu->shader_preset->pass[i]; @@ -1470,22 +1475,22 @@ static bool wiiu_gfx_set_shader(void *data, return false; } - for (int j = 0; j < 2 && j < wiiu->pass[i].gfd->vs->uniformBlockCount; j++) + for (j = 0; j < 2 && j < wiiu->pass[i].gfd->vs->uniformBlockCount; j++) { wiiu->pass[i].vs_ubos[j] = MEM2_alloc(wiiu->pass[i].gfd->vs->uniformBlocks[j].size, - GX2_UNIFORM_BLOCK_ALIGNMENT); + GX2_UNIFORM_BLOCK_ALIGNMENT); memset(wiiu->pass[i].vs_ubos[j], 0, wiiu->pass[i].gfd->vs->uniformBlocks[j].size); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_UNIFORM_BLOCK, wiiu->pass[i].vs_ubos[j], - wiiu->pass[i].gfd->vs->uniformBlocks[j].size); + wiiu->pass[i].gfd->vs->uniformBlocks[j].size); } - for (int j = 0; j < 2 && j < wiiu->pass[i].gfd->ps->uniformBlockCount; j++) + for (j = 0; j < 2 && j < wiiu->pass[i].gfd->ps->uniformBlockCount; j++) { wiiu->pass[i].ps_ubos[j] = MEM2_alloc(wiiu->pass[i].gfd->ps->uniformBlocks[j].size, - GX2_UNIFORM_BLOCK_ALIGNMENT); + GX2_UNIFORM_BLOCK_ALIGNMENT); memset(wiiu->pass[i].ps_ubos[j], 0, wiiu->pass[i].gfd->ps->uniformBlocks[j].size); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_UNIFORM_BLOCK, wiiu->pass[i].ps_ubos[j], - wiiu->pass[i].gfd->ps->uniformBlocks[j].size); + wiiu->pass[i].gfd->ps->uniformBlocks[j].size); } } @@ -1510,7 +1515,7 @@ static bool wiiu_gfx_set_shader(void *data, wiiu->luts[i].surface.image = MEM2_alloc(wiiu->luts[i].surface.imageSize, wiiu->luts[i].surface.alignment); - for (int j = 0; (j < image.height) && (j < wiiu->luts[i].surface.height); j++) + for (j = 0; (j < image.height) && (j < wiiu->luts[i].surface.height); j++) memcpy((uint32_t *)wiiu->luts[i].surface.image + (j * wiiu->luts[i].surface.pitch), image.pixels + (j * image.width), image.width * sizeof(image.pixels)); diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index c3a227a434..28e08bfbe4 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -1574,6 +1574,7 @@ static bool gx_frame(void *data, const void *frame, unsigned overscan_corr_bottom = settings->uints.video_overscan_correction_bottom; bool video_smooth = settings->bools.video_smooth; unsigned video_aspect_ratio_idx = settings->uints.video_aspect_ratio_idx; + bool menu_is_alive = video_info->menu_is_alive; fps_text_buf[0] = '\0'; @@ -1615,7 +1616,7 @@ static bool gx_frame(void *data, const void *frame, gx->old_height = height; } - g_draw_done = false; + g_draw_done = false; gx->current_framebuf ^= 1; if (frame) @@ -1649,7 +1650,7 @@ static bool gx_frame(void *data, const void *frame, } #ifdef HAVE_MENU - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); #endif GX_InvalidateTexAll(); diff --git a/gfx/drivers/network_gfx.c b/gfx/drivers/network_gfx.c index d6a49d5c71..7b6feb6c1c 100644 --- a/gfx/drivers/network_gfx.c +++ b/gfx/drivers/network_gfx.c @@ -178,26 +178,30 @@ static bool network_gfx_frame(void *data, const void *frame, unsigned pixfmt = NETWORK_VIDEO_PIXELFORMAT_RGB565; bool draw = true; network_video_t *network = (network_video_t*)data; + bool menu_is_alive = video_info->menu_is_alive; if (!frame || !frame_width || !frame_height) return true; #ifdef HAVE_MENU - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); #endif - if (network_video_width != frame_width || network_video_height != frame_height || network_video_pitch != pitch) + if ( network_video_width != frame_width || + network_video_height != frame_height || + network_video_pitch != pitch) { if (frame_width > 4 && frame_height > 4) { - network_video_width = frame_width; - network_video_height = frame_height; - network_video_pitch = pitch; - network->screen_width = network_video_width; + network_video_width = frame_width; + network_video_height = frame_height; + network_video_pitch = pitch; + network->screen_width = network_video_width; network->screen_height = network_video_height; } } +#ifdef HAVE_MENU if (network_menu_frame && video_info->menu_is_alive) { frame_to_copy = network_menu_frame; @@ -207,16 +211,21 @@ static bool network_gfx_frame(void *data, const void *frame, bits = network_menu_bits; } else +#endif { width = network_video_width; height = network_video_height; pitch = network_video_pitch; - if (frame_width == 4 && frame_height == 4 && (frame_width < width && frame_height < height)) + if ( frame_width == 4 && + frame_height == 4 && + (frame_width < width && frame_height < height)) draw = false; +#ifdef HAVE_MENU if (video_info->menu_is_alive) draw = false; +#endif } if (network->video_width != width || network->video_height != height) @@ -225,9 +234,7 @@ static bool network_gfx_frame(void *data, const void *frame, network->video_height = height; if (network_video_temp_buf) - { free(network_video_temp_buf); - } network_video_temp_buf = (unsigned*)malloc(network->screen_width * network->screen_height * sizeof(unsigned)); } @@ -246,8 +253,8 @@ static bool network_gfx_frame(void *data, const void *frame, for (x = 0; x < network->screen_width; x++) { /* scale incoming frame to fit the screen */ - unsigned scaled_x = (width * x) / network->screen_width; - unsigned scaled_y = (height * y) / network->screen_height; + unsigned scaled_x = (width * x) / network->screen_width; + unsigned scaled_y = (height * y) / network->screen_height; unsigned short pixel = ((unsigned short*)frame_to_copy)[width * scaled_y + scaled_x]; /* convert RGBX4444 to RGBX8888 */ @@ -272,8 +279,8 @@ static bool network_gfx_frame(void *data, const void *frame, for (x = 0; x < network->screen_width; x++) { /* scale incoming frame to fit the screen */ - unsigned scaled_x = (width * x) / network->screen_width; - unsigned scaled_y = (height * y) / network->screen_height; + unsigned scaled_x = (width * x) / network->screen_width; + unsigned scaled_y = (height * y) / network->screen_height; unsigned short pixel = ((unsigned short*)frame_to_copy)[(pitch / (bits / 8)) * scaled_y + scaled_x]; /* convert RGB565 to RGBX8888 */ @@ -306,7 +313,7 @@ static bool network_gfx_frame(void *data, const void *frame, /* scale incoming frame to fit the screen */ unsigned scaled_x = (width * x) / network->screen_width; unsigned scaled_y = (height * y) / network->screen_height; - unsigned pixel = ((unsigned*)frame_to_copy)[(pitch / (bits / 8)) * scaled_y + scaled_x]; + unsigned pixel = ((unsigned*)frame_to_copy)[(pitch / (bits / 8)) * scaled_y + scaled_x]; network_video_temp_buf[network->screen_width * y + x] = pixel; } diff --git a/gfx/drivers/oga_gfx.c b/gfx/drivers/oga_gfx.c index d1619d968a..be7903fd15 100644 --- a/gfx/drivers/oga_gfx.c +++ b/gfx/drivers/oga_gfx.c @@ -76,85 +76,91 @@ go2_rotation_t oga_rotation = GO2_ROTATION_DEGREES_0; static void oga_gfx_free(void *data) { - oga_video_t *vid = (oga_video_t*)data; - if (!vid) - return; + unsigned i; + oga_video_t *vid = (oga_video_t*)data; - if (vid->font) { - vid->font_driver->free(vid->font); - vid->font_driver = NULL; - } + if (!vid) + return; - for (int i = 0; i < NUM_PAGES; ++i) - { - go2_frame_buffer_t* frameBuffer = vid->frameBuffer[i]; - go2_surface_t* surface = go2_frame_buffer_surface_get(frameBuffer); + if (vid->font) + { + vid->font_driver->free(vid->font); + vid->font_driver = NULL; + } - go2_frame_buffer_destroy(frameBuffer); - go2_surface_destroy(surface); - } + for (i = 0; i < NUM_PAGES; ++i) + { + go2_frame_buffer_t* frameBuffer = vid->frameBuffer[i]; + go2_surface_t* surface = go2_frame_buffer_surface_get(frameBuffer); - go2_surface_destroy(vid->frame); - go2_surface_destroy(vid->menu_surface); - go2_presenter_destroy(vid->presenter); - go2_display_destroy(vid->display); + go2_frame_buffer_destroy(frameBuffer); + go2_surface_destroy(surface); + } - free(vid); - vid = NULL; + go2_surface_destroy(vid->frame); + go2_surface_destroy(vid->menu_surface); + go2_presenter_destroy(vid->presenter); + go2_display_destroy(vid->display); + + free(vid); + vid = NULL; } static void *oga_gfx_init(const video_info_t *video, input_driver_t **input, void **input_data) { - oga_video_t *vid = NULL; - settings_t *settings = config_get_ptr(); - struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); + oga_video_t *vid = NULL; + settings_t *settings = config_get_ptr(); + struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); frontend_driver_install_signal_handler(); - if (input && input_data) { - void* udev = input_udev.init(settings->arrays.input_joypad_driver); - if (udev) { - *input = &input_udev; - *input_data = udev; - } - else - *input = NULL; - } + if (input && input_data) + { + void* udev = input_udev.init(settings->arrays.input_joypad_driver); + if (udev) + { + *input = &input_udev; + *input_data = udev; + } + else + *input = NULL; + } - vid = (oga_video_t*)calloc(1, sizeof(*vid)); + vid = (oga_video_t*)calloc(1, sizeof(*vid)); - vid->menu_frame = NULL; - vid->display = go2_display_create(); - vid->presenter = go2_presenter_create(vid->display, DRM_FORMAT_RGB565, 0xff000000, false); - vid->menu_surface = go2_surface_create(vid->display, NATIVE_WIDTH, NATIVE_HEIGHT, DRM_FORMAT_RGB565); - vid->font = NULL; - vid->font_driver = NULL; + vid->menu_frame = NULL; + vid->display = go2_display_create(); + vid->presenter = go2_presenter_create(vid->display, DRM_FORMAT_RGB565, 0xff000000, false); + vid->menu_surface = go2_surface_create(vid->display, NATIVE_WIDTH, NATIVE_HEIGHT, DRM_FORMAT_RGB565); + vid->font = NULL; + vid->font_driver = NULL; - int aw = MAX(ALIGN(av_info->geometry.max_width, 32), NATIVE_WIDTH); - int ah = MAX(ALIGN(av_info->geometry.max_height, 32), NATIVE_HEIGHT); + int aw = MAX(ALIGN(av_info->geometry.max_width, 32), NATIVE_WIDTH); + int ah = MAX(ALIGN(av_info->geometry.max_height, 32), NATIVE_HEIGHT); - printf("oga_gfx_init video %dx%d rgb32 %d smooth %d input_scale %u force_aspect %d fullscreen %d aw %d ah %d rgb %d\n", - video->width, video->height, video->rgb32, video->smooth, video->input_scale, video->force_aspect, - video->fullscreen, aw, ah, video->rgb32); + printf("oga_gfx_init video %dx%d rgb32 %d smooth %d input_scale %u force_aspect %d fullscreen %d aw %d ah %d rgb %d\n", + video->width, video->height, video->rgb32, video->smooth, video->input_scale, video->force_aspect, + video->fullscreen, aw, ah, video->rgb32); - vid->frame = go2_surface_create(vid->display, aw, ah, video->rgb32 ? DRM_FORMAT_XRGB8888 : DRM_FORMAT_RGB565); + vid->frame = go2_surface_create(vid->display, aw, ah, video->rgb32 ? DRM_FORMAT_XRGB8888 : DRM_FORMAT_RGB565); - // bitmap only for now - if (settings->bools.video_font_enable) { - vid->font_driver = &bitmap_font_renderer; - vid->font = vid->font_driver->init("", settings->floats.video_font_size); - } + /* bitmap only for now */ + if (settings->bools.video_font_enable) + { + vid->font_driver = &bitmap_font_renderer; + vid->font = vid->font_driver->init("", settings->floats.video_font_size); + } - for (int i = 0; i < NUM_PAGES; ++i) - { - go2_surface_t* surface = go2_surface_create(vid->display, NATIVE_HEIGHT, NATIVE_WIDTH, - video->rgb32 ? DRM_FORMAT_XRGB8888 : DRM_FORMAT_XRGB8888); - vid->frameBuffer[i] = go2_frame_buffer_create(surface); - } - vid->cur_page = 0; + for (int i = 0; i < NUM_PAGES; ++i) + { + go2_surface_t* surface = go2_surface_create(vid->display, NATIVE_HEIGHT, NATIVE_WIDTH, + video->rgb32 ? DRM_FORMAT_XRGB8888 : DRM_FORMAT_XRGB8888); + vid->frameBuffer[i] = go2_frame_buffer_create(surface); + } + vid->cur_page = 0; - return vid; + return vid; } int get_message_width(oga_video_t* vid, const char* msg) @@ -171,110 +177,126 @@ int get_message_width(oga_video_t* vid, const char* msg) return width; } -static void render_msg(oga_video_t* vid, go2_surface_t* surface, const char* msg, int width, int bpp) +static void render_msg(oga_video_t* vid, + go2_surface_t* surface, const char* msg, int width, int bpp) { - const struct font_atlas* atlas = vid->font_driver->get_atlas(vid->font); - int msg_width = get_message_width(vid, msg); - int dest_x = MAX(0, width - get_message_width(vid, msg)); - int dest_stride = go2_surface_stride_get(surface); + const struct font_atlas* atlas = vid->font_driver->get_atlas(vid->font); + int msg_width = get_message_width(vid, msg); + int dest_x = MAX(0, width - get_message_width(vid, msg)); + int dest_stride = go2_surface_stride_get(surface); + const char *c = msg; - const char* c = msg; - while (*c) { - const struct font_glyph* g = vid->font_driver->get_glyph(vid->font, *c); - if (!g) - continue; - if (dest_x + g->advance_x >= width) - break; + while (*c) + { + const struct font_glyph* g = vid->font_driver->get_glyph(vid->font, *c); + if (!g) + continue; + if (dest_x + g->advance_x >= width) + break; - const uint8_t* source = atlas->buffer + g->atlas_offset_y * atlas->width + g->atlas_offset_x; - uint8_t* dest = (uint8_t*)go2_surface_map(surface) + dest_x * bpp; + const uint8_t* source = atlas->buffer + g->atlas_offset_y * atlas->width + g->atlas_offset_x; + uint8_t* dest = (uint8_t*)go2_surface_map(surface) + dest_x * bpp; - for (int y = 0; y < g->height; y++) { - for (int x = 0; x < g->advance_x; x++) { - uint8_t px = (x < g->width) ? *(source++) : 0x00; - if (bpp == 4) { - *(dest++) = px; - *(dest++) = px; - *(dest++) = px; - *(dest++) = px; - } - else { - *(dest++) = px; - *(dest++) = px; - } + for (int y = 0; y < g->height; y++) + { + for (int x = 0; x < g->advance_x; x++) + { + uint8_t px = (x < g->width) ? *(source++) : 0x00; + if (bpp == 4) + { + *(dest++) = px; + *(dest++) = px; + *(dest++) = px; + *(dest++) = px; } - dest += dest_stride - g->advance_x * bpp; - source += atlas->width - g->width; - } + else + { + *(dest++) = px; + *(dest++) = px; + } + } + dest += dest_stride - g->advance_x * bpp; + source += atlas->width - g->width; + } - c++; - dest_x += g->advance_x; - } + c++; + dest_x += g->advance_x; + } } static bool oga_gfx_frame(void *data, const void *frame, unsigned width, unsigned height, uint64_t frame_count, unsigned pitch, const char *msg, video_frame_info_t *video_info) { - oga_video_t* vid = (oga_video_t*)data; - go2_surface_t* dst_surface = vid->frame; - uint8_t* src = (uint8_t*)frame; - int bpp = go2_drm_format_get_bpp(go2_surface_format_get(dst_surface)) / 8; + int out_w, out_h; + int yy, stride, dst_stride; + int out_x = 0; + int out_y = 0; + go2_display_t *display = NULL; + go2_frame_buffer_t *dstFrameBuffer = NULL; + go2_surface_t *dstSurface = NULL; + uint8_t *dst = NULL; + oga_video_t *vid = (oga_video_t*)data; + go2_surface_t *dst_surface = vid->frame; + uint8_t *src = (uint8_t*)frame; + int bpp = go2_drm_format_get_bpp( + go2_surface_format_get(dst_surface)) / 8; + bool menu_is_alive = video_info->menu_is_alive; - if (unlikely(video_info->menu_is_alive)) { #ifdef HAVE_MENU - menu_driver_frame(video_info); + if (unlikely(menu_is_alive)) + { + menu_driver_frame(menu_is_alive, video_info); + dst_surface = vid->menu_surface; + src = (uint8_t*)vid->menu_frame; + width = vid->menu_width; + height = vid->menu_height; + pitch = vid->menu_pitch; + bpp = vid->menu_pitch / vid->menu_width; + } #endif - dst_surface = vid->menu_surface; - src = (uint8_t*)vid->menu_frame; - width = vid->menu_width; - height = vid->menu_height; - pitch = vid->menu_pitch; - bpp = vid->menu_pitch / vid->menu_width; - } - if (unlikely(!frame || width == 0 || height == 0)) - return true; + if (unlikely(!frame || width == 0 || height == 0)) + return true; - // copy buffer to surface - uint8_t* dst = (uint8_t*)go2_surface_map(dst_surface); - int yy = height; - int stride = width * bpp; - int dst_stride = go2_surface_stride_get(dst_surface); - while (yy > 0) { - memcpy(dst, src, stride); - src += pitch; - dst += dst_stride; - --yy; - } + /* copy buffer to surface */ + dst = (uint8_t*)go2_surface_map(dst_surface); + yy = height; + stride = width * bpp; + dst_stride = go2_surface_stride_get(dst_surface); - int out_w = NATIVE_WIDTH; - int out_h = NATIVE_HEIGHT; - int out_x = 0; - int out_y = 0; + while (yy > 0) + { + memcpy(dst, src, stride); + src += pitch; + dst += dst_stride; + --yy; + } - if ((out_w != width || out_h != height)) - { - out_w = MIN(out_h * video_driver_get_aspect_ratio(), NATIVE_WIDTH); - out_x = MAX((NATIVE_WIDTH - out_w) / 2, 0); - } + out_w = NATIVE_WIDTH; + out_h = NATIVE_HEIGHT; - if (msg && vid->font) { - render_msg(vid, dst_surface, msg, width, bpp); - } + if ((out_w != width || out_h != height)) + { + out_w = MIN(out_h * video_driver_get_aspect_ratio(), NATIVE_WIDTH); + out_x = MAX((NATIVE_WIDTH - out_w) / 2, 0); + } - go2_frame_buffer_t* dstFrameBuffer = vid->frameBuffer[vid->cur_page]; - go2_surface_t* dstSurface = go2_frame_buffer_surface_get(dstFrameBuffer); + if (msg && vid->font) + render_msg(vid, dst_surface, msg, width, bpp); - go2_surface_blit(dst_surface, 0, 0, width, height, - dstSurface, out_y, out_x, out_h, out_w, - !video_info->menu_is_alive ? oga_rotation : GO2_ROTATION_DEGREES_270, 2); + dstFrameBuffer = vid->frameBuffer[vid->cur_page]; + dstSurface = go2_frame_buffer_surface_get(dstFrameBuffer); - go2_display_t* display = go2_presenter_display_get(vid->presenter); - go2_display_present(display, dstFrameBuffer); - vid->cur_page = !vid->cur_page; + go2_surface_blit(dst_surface, 0, 0, width, height, + dstSurface, out_y, out_x, out_h, out_w, + !menu_is_alive ? oga_rotation : GO2_ROTATION_DEGREES_270, 2); - return true; + display = go2_presenter_display_get(vid->presenter); + go2_display_present(display, dstFrameBuffer); + vid->cur_page = !vid->cur_page; + + return true; } static void oga_set_texture_frame(void *data, const void *frame, bool rgb32, @@ -353,25 +375,26 @@ static const video_poke_interface_t oga_poke_interface = { void oga_set_rotation(void *data, unsigned rotation) { - // called before init? - (void)data; - switch (rotation) { - case 0: - oga_rotation = GO2_ROTATION_DEGREES_270; - break; - case 1: - oga_rotation = GO2_ROTATION_DEGREES_180; - break; - case 2: - oga_rotation = GO2_ROTATION_DEGREES_90; - break; - case 3: - oga_rotation = GO2_ROTATION_DEGREES_0; - break; - default: - RARCH_ERR("Unhandled rotation %hu\n", rotation); - break; - } + /* called before init? */ + (void)data; + switch (rotation) + { + case 0: + oga_rotation = GO2_ROTATION_DEGREES_270; + break; + case 1: + oga_rotation = GO2_ROTATION_DEGREES_180; + break; + case 2: + oga_rotation = GO2_ROTATION_DEGREES_90; + break; + case 3: + oga_rotation = GO2_ROTATION_DEGREES_0; + break; + default: + RARCH_ERR("Unhandled rotation %hu\n", rotation); + break; + } } static void oga_get_poke_interface(void *data, const video_poke_interface_t **iface) diff --git a/gfx/drivers/omap_gfx.c b/gfx/drivers/omap_gfx.c index 8a0ed49797..2e9e010248 100644 --- a/gfx/drivers/omap_gfx.c +++ b/gfx/drivers/omap_gfx.c @@ -989,7 +989,8 @@ static bool omap_gfx_frame(void *data, const void *frame, unsigned width, unsigned height, uint64_t frame_count, unsigned pitch, const char *msg, video_frame_info_t *video_info) { - omap_video_t *vid = (omap_video_t*)data; + omap_video_t *vid = (omap_video_t*)data; + bool menu_is_alive = video_info->menu_is_alive; if (!frame) return true; @@ -1012,13 +1013,13 @@ static bool omap_gfx_frame(void *data, const void *frame, unsigned width, omapfb_blit_frame(vid->omap, frame, vid->height, pitch); #ifdef HAVE_MENU - menu_driver_frame(video_info); -#endif + menu_driver_frame(menu_is_alive, video_info); if (vid->menu.active) omapfb_blit_frame(vid->omap, vid->menu.frame, vid->menu.scaler.out_height, vid->menu.scaler.out_stride); +#endif if (msg) omap_render_msg(vid, msg); diff --git a/gfx/drivers/psp1_gfx.c b/gfx/drivers/psp1_gfx.c index 3fd759e8ae..ecaa3a9c5f 100644 --- a/gfx/drivers/psp1_gfx.c +++ b/gfx/drivers/psp1_gfx.c @@ -475,7 +475,8 @@ static bool psp_frame(void *data, const void *frame, unsigned width, unsigned height, uint64_t frame_count, unsigned pitch, const char *msg, video_frame_info_t *video_info) { - psp1_video_t *psp = (psp1_video_t*)data; + psp1_video_t *psp = (psp1_video_t*)data; + bool menu_is_alive = video_info->menu_is_alive; if (!width || !height) return false; @@ -536,7 +537,7 @@ static bool psp_frame(void *data, const void *frame, sceGuFinish(); #ifdef HAVE_MENU - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); #endif if(psp->menu.active) diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 572cb6a5e7..239fd0a702 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -487,13 +487,15 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width, unsigned height, uint64_t frame_count, unsigned pitch, const char *msg, video_frame_info_t *video_info) { - sdl2_video_t *vid = (sdl2_video_t*)data; char title[128]; + sdl2_video_t *vid = (sdl2_video_t*)data; + bool menu_is_alive = video_info->menu_is_alive; + bool libretro_running = video_info->libretro_running; if (vid->should_resize) sdl_refresh_viewport(vid); - if (frame && video_info->libretro_running) + if (frame && libretro_running) { SDL_RenderClear(vid->renderer); sdl_refresh_input_size(vid, false, vid->video.rgb32, width, height, pitch); @@ -503,7 +505,7 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width, SDL_RenderCopyEx(vid->renderer, vid->frame.tex, NULL, NULL, vid->rotation, NULL, SDL_FLIP_NONE); #ifdef HAVE_MENU - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); #endif if (vid->menu.active) diff --git a/gfx/drivers/sdl_dingux_gfx.c b/gfx/drivers/sdl_dingux_gfx.c index 352293de68..d27f1faf27 100644 --- a/gfx/drivers/sdl_dingux_gfx.c +++ b/gfx/drivers/sdl_dingux_gfx.c @@ -130,19 +130,21 @@ error: static void clear_screen(void* data) { - sdl_dingux_video_t* vid = (sdl_dingux_video_t*)data; - SDL_FillRect(vid->screen, 0, 0); - SDL_Flip(vid->screen); - SDL_FillRect(vid->screen, 0, 0); - SDL_Flip(vid->screen); - SDL_FillRect(vid->screen, 0, 0); - SDL_Flip(vid->screen); + sdl_dingux_video_t* vid = (sdl_dingux_video_t*)data; + SDL_FillRect(vid->screen, 0, 0); + SDL_Flip(vid->screen); + SDL_FillRect(vid->screen, 0, 0); + SDL_Flip(vid->screen); + SDL_FillRect(vid->screen, 0, 0); + SDL_Flip(vid->screen); } -static void set_output(sdl_dingux_video_t* vid, int width, int height, int pitch, bool rgb) +static void sdl_dingux_set_output( + sdl_dingux_video_t* vid, + int width, int height, int pitch, bool rgb) { #ifdef VERBOSE - printf("set_output current w %d h %d pitch %d new_w %d new_h %d pitch %d rgb %d\n", + printf("sdl_dingux_set_output current w %d h %d pitch %d new_w %d new_h %d pitch %d rgb %d\n", vid->screen->w, vid->screen->h, vid->screen->pitch, width, height, pitch, (int)vid->rgb); #endif @@ -153,61 +155,62 @@ static void set_output(sdl_dingux_video_t* vid, int width, int height, int pitch static void blit(uint32_t* d, uint32_t* s, int width, int height, int pitch) { - int skip = pitch/4 - width; - for (int i = 0; i < height; i++) - { - for (int j = 0; j < width; j++) - *(d++) = *(s++); - s += skip; - } + unsigned i; + int skip = pitch/4 - width; + for (i = 0; i < height; i++) + { + unsigned j; + for (j = 0; j < width; j++) + *(d++) = *(s++); + s += skip; + } } static bool sdl_dingux_gfx_frame(void *data, const void *frame, unsigned width, unsigned height, uint64_t frame_count, unsigned pitch, const char *msg, video_frame_info_t *video_info) { - sdl_dingux_video_t* vid = (sdl_dingux_video_t*)data; + sdl_dingux_video_t* vid = (sdl_dingux_video_t*)data; + bool menu_is_alive = video_info->menu_is_alive; - if (unlikely(!frame)) - return true; + if (unlikely(!frame)) + return true; - if (unlikely((vid->screen->w != width || vid->screen->h != height) && !vid->menu_active)) - { - set_output(vid, width, height, pitch, vid->rgb); - } + if (unlikely((vid->screen->w != width || vid->screen->h != height) && !vid->menu_active)) + sdl_dingux_set_output(vid, width, height, pitch, vid->rgb); - menu_driver_frame(video_info); +#ifdef HAVE_MENU + menu_driver_frame(menu_is_alive, video_info); +#endif - if (likely(!vid->menu_active)) - { - blit((uint32_t*)vid->screen->pixels, (uint32_t*)frame, vid->rgb ? width : width/2, height, pitch); - if (unlikely(vid->was_in_menu)) - vid->was_in_menu = false; - } - else - { - if (!vid->was_in_menu) - { - set_output(vid, 320, 240, 320*2, false); - vid->was_in_menu = true; - } - memcpy(vid->screen->pixels, vid->menu_frame, 320*240*2); - } + if (likely(!vid->menu_active)) + { + blit((uint32_t*)vid->screen->pixels, (uint32_t*)frame, vid->rgb ? width : width/2, height, pitch); + if (unlikely(vid->was_in_menu)) + vid->was_in_menu = false; + } + else + { + if (!vid->was_in_menu) + { + sdl_dingux_set_output(vid, 320, 240, 320*2, false); + vid->was_in_menu = true; + } + memcpy(vid->screen->pixels, vid->menu_frame, 320*240*2); + } - SDL_Flip(vid->screen); + SDL_Flip(vid->screen); - return true; + return true; } static void sdl_dingux_set_texture_enable(void *data, bool state, bool full_screen) { - sdl_dingux_video_t *vid = (sdl_dingux_video_t*)data; - (void)full_screen; + sdl_dingux_video_t *vid = (sdl_dingux_video_t*)data; + (void)full_screen; - if (vid->menu_active != state) - { - vid->menu_active = state; - } + if (vid->menu_active != state) + vid->menu_active = state; } static void sdl_dingux_set_texture_frame(void *data, const void *frame, bool rgb32, diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 43b7221305..c730bad005 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -363,8 +363,9 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width, unsigned height, uint64_t frame_count, unsigned pitch, const char *msg, video_frame_info_t *video_info) { - sdl_video_t *vid = (sdl_video_t*)data; char title[128]; + sdl_video_t *vid = (sdl_video_t*)data; + bool menu_is_alive = video_info->menu_is_alive; if (!frame) return true; @@ -389,11 +390,11 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width, pitch); #ifdef HAVE_MENU - menu_driver_frame(video_info); -#endif + menu_driver_frame(menu_is_alive, video_info); if (vid->menu.active) SDL_BlitSurface(vid->menu.frame, NULL, vid->screen, NULL); +#endif if (msg) sdl_render_msg(vid, vid->screen, diff --git a/gfx/drivers/sixel_gfx.c b/gfx/drivers/sixel_gfx.c index f115895d28..6f9ed7a08b 100644 --- a/gfx/drivers/sixel_gfx.c +++ b/gfx/drivers/sixel_gfx.c @@ -269,12 +269,13 @@ static bool sixel_gfx_frame(void *data, const void *frame, unsigned pixfmt = SIXEL_PIXELFORMAT_RGB565; bool draw = true; sixel_t *sixel = (sixel_t*)data; + bool menu_is_alive = video_info->menu_is_alive; if (!frame || !frame_width || !frame_height) return true; #ifdef HAVE_MENU - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); #endif if (sixel_video_width != frame_width || sixel_video_height != frame_height || sixel_video_pitch != pitch) diff --git a/gfx/drivers/sunxi_gfx.c b/gfx/drivers/sunxi_gfx.c index 659dff51ec..92bacc2406 100644 --- a/gfx/drivers/sunxi_gfx.c +++ b/gfx/drivers/sunxi_gfx.c @@ -776,6 +776,7 @@ static bool sunxi_gfx_frame(void *data, const void *frame, unsigned width, video_frame_info_t *video_info) { struct sunxi_video *_dispvars = (struct sunxi_video*)data; + bool menu_is_alive = video_info->menu_is_alive; if (_dispvars->src_width != width || _dispvars->src_height != height) { @@ -790,7 +791,7 @@ static bool sunxi_gfx_frame(void *data, const void *frame, unsigned width, } #ifdef HAVE_MENU - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); #endif if (_dispvars->menu_active) diff --git a/gfx/drivers/switch_gfx.c b/gfx/drivers/switch_gfx.c index 3b72106acd..c6b21038dc 100644 --- a/gfx/drivers/switch_gfx.c +++ b/gfx/drivers/switch_gfx.c @@ -142,7 +142,7 @@ static bool switch_frame(void *data, const void *frame, uint64_t frame_count, unsigned pitch, const char *msg, video_frame_info_t *video_info) { - static uint64_t last_frame = 0; + static uint64_t last_frame = 0; unsigned x, y; result_t r; @@ -152,6 +152,7 @@ static bool switch_frame(void *data, const void *frame, int xsf = 1280 / width; int ysf = 720 / height; int sf = xsf; + bool menu_is_alive = video_info->menu_is_alive; if (ysf < sf) sf = ysf; @@ -170,8 +171,8 @@ static bool switch_frame(void *data, const void *frame, if(width > 0 && height > 0) { - if(sw->last_width != width || - sw->last_height != height) + if(sw->last_width != width || + sw->last_height != height) { scaler_ctx_gen_reset(&sw->scaler); @@ -197,31 +198,31 @@ static bool switch_frame(void *data, const void *frame, sw->last_height = height; } - scaler_ctx_scale(&sw->scaler, sw->image + (centery * 1280) + centerx, frame); + scaler_ctx_scale(&sw->scaler, sw->image + (centery * 1280) + centerx, frame); } #if defined(HAVE_MENU) if (sw->menu_texture.enable) - { - menu_driver_frame(video_info); + { + menu_driver_frame(menu_is_alive, video_info); - if (sw->menu_texture.pixels) - { + if (sw->menu_texture.pixels) + { #if 0 - if (sw->menu_texture.fullscreen) + if (sw->menu_texture.fullscreen) { #endif - scaler_ctx_scale(&sw->menu_texture.scaler, sw->image + - ((720-sw->menu_texture.tgth)/2)*1280 + - ((1280-sw->menu_texture.tgtw)/2), sw->menu_texture.pixels); + scaler_ctx_scale(&sw->menu_texture.scaler, sw->image + + ((720-sw->menu_texture.tgth)/2)*1280 + + ((1280-sw->menu_texture.tgtw)/2), sw->menu_texture.pixels); #if 0 } else { } #endif - } - } + } + } else if (video_info->statistics_show) { struct font_params *osd_params = (struct font_params*) @@ -246,11 +247,11 @@ static bool switch_frame(void *data, const void *frame, r = surface_dequeue_buffer(&sw->surface, &out_buffer); if(r != RESULT_OK) - return true; /* just skip the frame */ + return true; /* just skip the frame */ r = surface_wait_buffer(&sw->surface); if(r != RESULT_OK) - return true; + return true; gfx_slow_swizzling_blit(out_buffer, sw->image, 1280, 720, 0, 0); r = surface_queue_buffer(&sw->surface); diff --git a/gfx/drivers/switch_nx_gfx.c b/gfx/drivers/switch_nx_gfx.c index 31d9d4478f..a392f07f51 100644 --- a/gfx/drivers/switch_nx_gfx.c +++ b/gfx/drivers/switch_nx_gfx.c @@ -344,135 +344,138 @@ static bool switch_frame(void *data, const void *frame, uint64_t frame_count, unsigned pitch, const char *msg, video_frame_info_t *video_info) { - switch_video_t *sw = data; - uint32_t *out_buffer = NULL; - bool ffwd_mode = video_info->input_driver_nonblock_state; + uint32_t stride; + switch_video_t *sw = data; + uint32_t *out_buffer = NULL; + bool ffwd_mode = video_info->input_driver_nonblock_state; + bool menu_is_alive = video_info->menu_is_alive; - if (!frame) - return true; + if (!frame) + return true; - if (ffwd_mode && !sw->is_threaded) - { - /* render every 4th frame when in ffwd mode and not threaded */ - if ((frame_count % 4) != 0) - return true; - } + if (ffwd_mode && !sw->is_threaded) + { + /* render every 4th frame when in ffwd mode and not threaded */ + if ((frame_count % 4) != 0) + return true; + } - if ( sw->should_resize || - width != sw->last_width || - height != sw->last_height) - { - switch_update_viewport(sw, video_info); + if ( sw->should_resize || + width != sw->last_width || + height != sw->last_height) + { + switch_update_viewport(sw, video_info); - /* Sanity check */ - sw->vp.width = MIN(sw->vp.width, sw->vp.full_width); - sw->vp.height = MIN(sw->vp.height, sw->vp.full_height); + /* Sanity check */ + sw->vp.width = MIN(sw->vp.width, sw->vp.full_width); + sw->vp.height = MIN(sw->vp.height, sw->vp.full_height); - scaler_ctx_gen_reset(&sw->scaler); + scaler_ctx_gen_reset(&sw->scaler); - sw->scaler.in_width = width; - sw->scaler.in_height = height; - sw->scaler.in_stride = pitch; - sw->scaler.in_fmt = sw->rgb32 - ? SCALER_FMT_ARGB8888 - : SCALER_FMT_RGB565; + sw->scaler.in_width = width; + sw->scaler.in_height = height; + sw->scaler.in_stride = pitch; + sw->scaler.in_fmt = sw->rgb32 + ? SCALER_FMT_ARGB8888 + : SCALER_FMT_RGB565; - if (!sw->smooth) - { - sw->scaler.out_width = sw->vp.width; - sw->scaler.out_height = sw->vp.height; - sw->scaler.out_stride = sw->vp.full_width * sizeof(uint32_t); - } - else - { - sw->scaler.out_width = width; - sw->scaler.out_height = height; - sw->scaler.out_stride = width * sizeof(uint32_t); + if (!sw->smooth) + { + sw->scaler.out_width = sw->vp.width; + sw->scaler.out_height = sw->vp.height; + sw->scaler.out_stride = sw->vp.full_width * sizeof(uint32_t); + } + else + { + sw->scaler.out_width = width; + sw->scaler.out_height = height; + sw->scaler.out_stride = width * sizeof(uint32_t); - float screen_ratio = (float)sw->vp.full_width / sw->vp.full_height; - float tgt_ratio = (float)sw->vp.width / sw->vp.height; + float screen_ratio = (float)sw->vp.full_width / sw->vp.full_height; + float tgt_ratio = (float)sw->vp.width / sw->vp.height; - sw->hw_scale.width = ceil(screen_ratio / tgt_ratio * sw->scaler.out_width); - sw->hw_scale.height = sw->scaler.out_height; - sw->hw_scale.x_offset = ceil((sw->hw_scale.width - sw->scaler.out_width) / 2.0); - if (!video_info->menu_is_alive) - { - clear_screen(sw); - nwindowSetDimensions(sw->win, sw->hw_scale.width, sw->hw_scale.height); - } - } - sw->scaler.out_fmt = SCALER_FMT_ABGR8888; + sw->hw_scale.width = ceil(screen_ratio / tgt_ratio * sw->scaler.out_width); + sw->hw_scale.height = sw->scaler.out_height; + sw->hw_scale.x_offset = ceil((sw->hw_scale.width - sw->scaler.out_width) / 2.0); + if (!video_info->menu_is_alive) + { + clear_screen(sw); + nwindowSetDimensions(sw->win, sw->hw_scale.width, sw->hw_scale.height); + } + } + sw->scaler.out_fmt = SCALER_FMT_ABGR8888; - sw->scaler.scaler_type = SCALER_TYPE_POINT; + sw->scaler.scaler_type = SCALER_TYPE_POINT; - if (!scaler_ctx_gen_filter(&sw->scaler)) - return false; + if (!scaler_ctx_gen_filter(&sw->scaler)) + return false; - sw->last_width = width; - sw->last_height = height; + sw->last_width = width; + sw->last_height = height; - sw->should_resize = false; - } + sw->should_resize = false; + } - uint32_t stride; + out_buffer = (uint32_t *)framebufferBegin(&sw->fb, &stride); + sw->out_buffer = out_buffer; + sw->stride = stride; - out_buffer = (uint32_t *)framebufferBegin(&sw->fb, &stride); - sw->out_buffer = out_buffer; - sw->stride = stride; + if (sw->in_menu && !video_info->menu_is_alive && sw->smooth) + { + memset(out_buffer, 0, stride * sw->vp.full_height); + nwindowSetDimensions(sw->win, sw->hw_scale.width, sw->hw_scale.height); + } + sw->in_menu = video_info->menu_is_alive; - if (sw->in_menu && !video_info->menu_is_alive && sw->smooth) - { - memset(out_buffer, 0, stride * sw->vp.full_height); - nwindowSetDimensions(sw->win, sw->hw_scale.width, sw->hw_scale.height); - } - sw->in_menu = video_info->menu_is_alive; +#ifdef HAVE_MENU + if (sw->menu_texture.enable) + { + menu_driver_frame(menu_is_alive, video_info); - if (sw->menu_texture.enable) - { - menu_driver_frame(video_info); + if (sw->menu_texture.pixels) + { + memset(out_buffer, 0, stride * sw->vp.full_height); + scaler_ctx_scale(&sw->menu_texture.scaler, sw->tmp_image + ((sw->vp.full_height - sw->menu_texture.tgth) / 2) * sw->vp.full_width + ((sw->vp.full_width - sw->menu_texture.tgtw) / 2), sw->menu_texture.pixels); + gfx_cpy_dsp_buf(out_buffer, sw->tmp_image, sw->vp.full_width, sw->vp.full_height, stride, true); + } + } + else +#endif + if (sw->smooth) /* bilinear */ + { + int w, h; + unsigned x, y; + struct scaler_ctx *ctx = &sw->scaler; + scaler_ctx_scale_direct(ctx, sw->image, frame); + w = sw->scaler.out_width; + h = sw->scaler.out_height; - if (sw->menu_texture.pixels) - { - memset(out_buffer, 0, stride * sw->vp.full_height); - scaler_ctx_scale(&sw->menu_texture.scaler, sw->tmp_image + ((sw->vp.full_height - sw->menu_texture.tgth) / 2) * sw->vp.full_width + ((sw->vp.full_width - sw->menu_texture.tgtw) / 2), sw->menu_texture.pixels); - gfx_cpy_dsp_buf(out_buffer, sw->tmp_image, sw->vp.full_width, sw->vp.full_height, stride, true); - } - } - else if (sw->smooth) /* bilinear */ - { - int w, h; - unsigned x, y; - struct scaler_ctx *ctx = &sw->scaler; - scaler_ctx_scale_direct(ctx, sw->image, frame); - w = sw->scaler.out_width; - h = sw->scaler.out_height; - - for (y = 0; y < h; y++) + for (y = 0; y < h; y++) for (x = 0; x < w; x++) - out_buffer[y * stride / sizeof(uint32_t) + (x + sw->hw_scale.x_offset)] = sw->image[y * w + x]; - } - else - { - struct scaler_ctx *ctx = &sw->scaler; - scaler_ctx_scale(ctx, sw->image + (sw->vp.y * sw->vp.full_width) + sw->vp.x, frame); - gfx_cpy_dsp_buf(out_buffer, sw->image, sw->vp.full_width, sw->vp.full_height, stride, false); - } + out_buffer[y * stride / sizeof(uint32_t) + (x + sw->hw_scale.x_offset)] = sw->image[y * w + x]; + } + else + { + struct scaler_ctx *ctx = &sw->scaler; + scaler_ctx_scale(ctx, sw->image + (sw->vp.y * sw->vp.full_width) + sw->vp.x, frame); + gfx_cpy_dsp_buf(out_buffer, sw->image, sw->vp.full_width, sw->vp.full_height, stride, false); + } - if (video_info->statistics_show && !sw->smooth) - { - struct font_params *osd_params = (struct font_params *)&video_info->osd_stat_params; + if (video_info->statistics_show && !sw->smooth) + { + struct font_params *osd_params = (struct font_params *)&video_info->osd_stat_params; - if (osd_params) - font_driver_render_msg(sw, video_info->stat_text, - (const struct font_params *)&video_info->osd_stat_params, NULL); - } + if (osd_params) + font_driver_render_msg(sw, video_info->stat_text, + (const struct font_params *)&video_info->osd_stat_params, NULL); + } - if (msg) - font_driver_render_msg(sw, msg, NULL, NULL); + if (msg) + font_driver_render_msg(sw, msg, NULL, NULL); framebufferEnd(&sw->fb); - return true; + return true; } static void switch_set_nonblock_state(void *data, bool toggle, bool c, unsigned d) diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 7e9482214b..dd3aa6906d 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -416,8 +416,9 @@ static bool vg_frame(void *data, const void *frame, video_frame_info_t *video_info) { vg_t *vg = (vg_t*)data; - unsigned width = video_info->width; - unsigned height = video_info->height; + unsigned width = video_info->width; + unsigned height = video_info->height; + bool menu_is_alive = video_info->menu_is_alive; if ( frame_width != vg->mRenderWidth || frame_height != vg->mRenderHeight @@ -444,7 +445,7 @@ static bool vg_frame(void *data, const void *frame, vg_copy_frame(vg, frame, frame_width, frame_height, pitch); #ifdef HAVE_MENU - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); #endif vgDrawImage(vg->mImage); diff --git a/gfx/drivers/vga_gfx.c b/gfx/drivers/vga_gfx.c index bbd58b4a4a..ee960074ae 100644 --- a/gfx/drivers/vga_gfx.c +++ b/gfx/drivers/vga_gfx.c @@ -144,12 +144,13 @@ static bool vga_gfx_frame(void *data, const void *frame, const void *frame_to_copy = frame; bool draw = true; vga_t *vga = (vga_t*)data; + bool menu_is_alive = video_info->menu_is_alive; if (!frame || !frame_width || !frame_height) return true; #ifdef HAVE_MENU - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); #endif if ( vga->vga_video_width != frame_width || diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index 1c36e8e918..781bb11e6e 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -145,6 +145,7 @@ static bool vita2d_gfx_frame(void *data, const void *frame, { void *tex_p; vita_video_t *vita = (vita_video_t *)data; + bool menu_is_alive = video_info->menu_is_alive; if (frame) { @@ -221,7 +222,7 @@ static bool vita2d_gfx_frame(void *data, const void *frame, if (vita->menu.active) { #ifdef HAVE_MENU - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); #endif if(vita->menu.texture) diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 331d6d2efc..e43df12b1c 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -1685,6 +1685,7 @@ static bool vulkan_frame(void *data, const void *frame, unsigned video_height = video_info->height; struct font_params *osd_params = (struct font_params*) &video_info->osd_stat_params; + bool menu_is_alive = video_info->menu_is_alive; VkCommandBufferBeginInfo begin_info = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO }; @@ -1934,7 +1935,7 @@ static bool vulkan_frame(void *data, const void *frame, settings_t *settings = config_get_ptr(); bool menu_linear_filter = settings->bools.menu_linear_filter; - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); if (vk->menu.textures[vk->menu.last_index].image != VK_NULL_HANDLE || vk->menu.textures[vk->menu.last_index].buffer != VK_NULL_HANDLE) diff --git a/gfx/drivers/xenon360_gfx.c b/gfx/drivers/xenon360_gfx.c index 8fcdb7cbe7..45ce3dfcc1 100644 --- a/gfx/drivers/xenon360_gfx.c +++ b/gfx/drivers/xenon360_gfx.c @@ -198,7 +198,8 @@ static bool xenon360_gfx_frame(void *data, uint64_t frame_count, unsigned pitch, const char *msg, video_frame_info_t *video_info) { - xenos_t *xenos = (xenos_t*)data; + xenos_t *xenos = (xenos_t*)data; + bool menu_is_alive = video_info->menu_is_alive; ScreenUv[UV_TOP] = ((float) (width) / (float) XE_W)*2; ScreenUv[UV_LEFT] = ((float) (height) / (float) XE_H)*2; @@ -238,7 +239,7 @@ static bool xenon360_gfx_frame(void *data, Xe_SetShader(xenos->device, SHADER_TYPE_VERTEX, xenos->g_pVertexShader, 0); #ifdef HAVE_MENU - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); #endif /* Draw */ diff --git a/gfx/drivers/xshm_gfx.c b/gfx/drivers/xshm_gfx.c index 1da7e9b2cf..851a8b6270 100644 --- a/gfx/drivers/xshm_gfx.c +++ b/gfx/drivers/xshm_gfx.c @@ -98,17 +98,16 @@ static bool xshm_gfx_frame(void *data, const void *frame, unsigned width, unsigned height, uint64_t frame_count, unsigned pitch, const char *msg, video_frame_info_t *video_info) { - xshm_t* xshm = (xshm_t*)data; - int y; + unsigned y; + xshm_t *xshm = (xshm_t*)data; + bool menu_is_alive = video_info->menu_is_alive; - for (y=0;yshmInfo.shmaddr + sizeof(uint32_t)*xshm->width*y, (uint8_t*)frame + pitch*y, pitch); - } #ifdef HAVE_MENU - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); #endif XShmPutImage(xshm->display, xshm->wndw, xshm->gc, xshm->image, diff --git a/gfx/drivers/xvideo.c b/gfx/drivers/xvideo.c index 21be1d9bed..2d14a1cb59 100644 --- a/gfx/drivers/xvideo.c +++ b/gfx/drivers/xvideo.c @@ -844,6 +844,7 @@ static bool xv_frame(void *data, const void *frame, unsigned width, { XWindowAttributes target; xv_t *xv = (xv_t*)data; + bool menu_is_alive = video_info->menu_is_alive; if (!frame) return true; @@ -859,7 +860,7 @@ static bool xv_frame(void *data, const void *frame, unsigned width, xv->vp.full_height = target.height; #ifdef HAVE_MENU - menu_driver_frame(video_info); + menu_driver_frame(menu_is_alive, video_info); #endif if (msg) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 5b987dac55..aa49b695b1 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -2215,9 +2215,8 @@ const char *menu_driver_ident(void) return menu_driver_ctx->ident; } -void menu_driver_frame(video_frame_info_t *video_info) +void menu_driver_frame(bool menu_is_alive, video_frame_info_t *video_info) { - bool menu_is_alive = video_info->menu_is_alive; if (menu_is_alive && menu_driver_ctx->frame) menu_driver_ctx->frame(menu_userdata, video_info); } diff --git a/menu/menu_driver.h b/menu/menu_driver.h index da972289de..3b7cce2891 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -427,7 +427,7 @@ const char *menu_driver_ident(void); bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data); -void menu_driver_frame(video_frame_info_t *video_info); +void menu_driver_frame(bool menu_is_alive, video_frame_info_t *video_info); bool menu_driver_get_load_content_animation_data( uintptr_t *icon, char **playlist_name); From 3f98cbc52d69e91a0aede1c0b50c7bf3f0c204fd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 19 May 2020 16:42:56 +0200 Subject: [PATCH 115/192] Get rid of some unneeded variables in video_frame_info --- retroarch.c | 27 ++++++++++++--------------- retroarch.h | 7 ------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/retroarch.c b/retroarch.c index 4f2ec6f36f..bfe6d31d04 100644 --- a/retroarch.c +++ b/retroarch.c @@ -22546,7 +22546,11 @@ static void video_driver_frame(const void *data, unsigned width, /* Get the amount of frames per seconds. */ if (video_driver_frame_count) { - size_t buf_pos = 1; /* set this to 1 to avoid an offset issue */ + settings_t *settings = configuration_settings; + unsigned fps_update_interval = + settings->uints.fps_update_interval; + size_t buf_pos = 1; + /* set this to 1 to avoid an offset issue */ unsigned write_index = video_driver_frame_time_count++ & (MEASURE_FRAME_TIME_SAMPLES_COUNT - 1); @@ -22586,10 +22590,10 @@ static void video_driver_frame(const void *data, unsigned width, strlcat(video_info.fps_text, mem, sizeof(video_info.fps_text)); } - if ((video_driver_frame_count % video_info.fps_update_interval) == 0) + if ((video_driver_frame_count % fps_update_interval) == 0) { last_fps = TIME_TO_FPS(curr_time, new_time, - video_info.fps_update_interval); + fps_update_interval); strlcpy(video_driver_window_title, video_driver_title_buf, sizeof(video_driver_window_title)); @@ -22622,10 +22626,6 @@ static void video_driver_frame(const void *data, unsigned width, video_driver_window_title_update = true; } - video_info.frame_rate = last_fps; - video_info.frame_time = frame_time / 1000.0f; - video_info.frame_count = (uint64_t) video_driver_frame_count; - /* Slightly messy code, * but we really need to do processing before blocking on VSync * for best possible scheduling. @@ -22639,7 +22639,7 @@ static void video_driver_frame(const void *data, unsigned width, ) && recording_data && recording_driver && recording_driver->push_video) recording_dump_frame(data, width, height, - pitch, video_info.runloop_is_idle); + pitch, runloop_idle); if (data && video_driver_state_filter) { @@ -22660,7 +22660,7 @@ static void video_driver_frame(const void *data, unsigned width, && recording_driver && recording_driver->push_video) recording_dump_frame(video_driver_state_buffer, output_width, output_height, output_pitch, - video_info.runloop_is_idle); + runloop_idle); data = video_driver_state_buffer; width = output_width; @@ -22754,10 +22754,10 @@ static void video_driver_frame(const void *data, unsigned width, " -Frame count: %" PRIu64"\n -Viewport: %d x %d x %3.2f\n" "Audio Statistics:\n -Average buffer saturation: %.2f %%\n -Standard deviation: %.2f %%\n -Time spent close to underrun: %.2f %%\n -Time spent close to blocking: %.2f %%\n -Sample count: %d\n" "Core Geometry:\n -Size: %u x %u\n -Max Size: %u x %u\n -Aspect: %3.2f\nCore Timing:\n -FPS: %3.2f\n -Sample Rate: %6.2f\n", - video_info.frame_rate, - video_info.frame_time, + last_fps, + frame_time / 1000.0f, 100.0 * stddev, - video_info.frame_count, + video_driver_frame_count, video_info.width, video_info.height, video_info.refresh_rate, @@ -22939,7 +22939,6 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->hard_sync_frames = settings->uints.video_hard_sync_frames; video_info->fps_show = settings->bools.video_fps_show; video_info->memory_show = settings->bools.video_memory_show; - video_info->fps_update_interval = settings->uints.fps_update_interval; video_info->statistics_show = settings->bools.video_statistics_show; video_info->framecount_show = settings->bools.video_framecount_show; video_info->scale_integer = settings->bools.video_scale_integer; @@ -23026,9 +23025,7 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->menu_wallpaper_opacity = 0.0f; #endif - video_info->is_perfcnt_enable = runloop_perfcnt_enable; video_info->runloop_is_paused = runloop_paused; - video_info->runloop_is_idle = runloop_idle; video_info->runloop_is_slowmotion = runloop_slowmotion; video_info->input_driver_nonblock_state = input_driver_nonblock_state; diff --git a/retroarch.h b/retroarch.h index db93f87d15..e4ddbcffec 100644 --- a/retroarch.h +++ b/retroarch.h @@ -1119,9 +1119,7 @@ typedef struct video_frame_info bool battery_level_enable; bool timedate_enable; bool runloop_is_slowmotion; - bool runloop_is_idle; bool runloop_is_paused; - bool is_perfcnt_enable; bool menu_is_alive; bool msg_bgcolor_enable; @@ -1129,7 +1127,6 @@ typedef struct video_frame_info int custom_vp_y; int crt_switch_center_adjust; - unsigned fps_update_interval; unsigned hard_sync_frames; unsigned aspect_ratio_idx; unsigned max_swapchain_images; @@ -1164,10 +1161,6 @@ typedef struct video_frame_info char stat_text[512]; char chat_text[256]; - uint64_t frame_count; - float frame_time; - float frame_rate; - struct { float x; From 26c6c34817e4cdcdbefca90c64cd99d7565f3918 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 19 May 2020 16:51:05 +0200 Subject: [PATCH 116/192] video_frame_info - remove more unused settings --- retroarch.c | 1 - retroarch.h | 1 - 2 files changed, 2 deletions(-) diff --git a/retroarch.c b/retroarch.c index bfe6d31d04..e9a779f1c9 100644 --- a/retroarch.c +++ b/retroarch.c @@ -22941,7 +22941,6 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->memory_show = settings->bools.video_memory_show; video_info->statistics_show = settings->bools.video_statistics_show; video_info->framecount_show = settings->bools.video_framecount_show; - video_info->scale_integer = settings->bools.video_scale_integer; video_info->aspect_ratio_idx = settings->uints.video_aspect_ratio_idx; video_info->post_filter_record = settings->bools.video_post_filter_record; video_info->input_menu_swap_ok_cancel_buttons = settings->bools.input_menu_swap_ok_cancel_buttons; diff --git a/retroarch.h b/retroarch.h index e4ddbcffec..fbcd16b521 100644 --- a/retroarch.h +++ b/retroarch.h @@ -1108,7 +1108,6 @@ typedef struct video_frame_info bool memory_show; bool statistics_show; bool framecount_show; - bool scale_integer; bool post_filter_record; bool windowed_fullscreen; bool fullscreen; From 6800fadafe152408413cfd41537fdfeec89eb127 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Tue, 19 May 2020 16:32:26 +0100 Subject: [PATCH 117/192] Fix memory leak when loading overlays --- retroarch.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/retroarch.c b/retroarch.c index e9a779f1c9..b9eeacce93 100644 --- a/retroarch.c +++ b/retroarch.c @@ -13341,21 +13341,19 @@ void input_overlay_free_overlay(struct overlay *overlay) free(overlay->descs); overlay->descs = NULL; image_texture_free(&overlay->image); - - if (overlay_ptr) - free(overlay_ptr); - overlay_ptr = NULL; } static void input_overlay_free_overlays(input_overlay_t *ol) { size_t i; + if (!ol || !ol->overlays) + return; + for (i = 0; i < ol->size; i++) input_overlay_free_overlay(&ol->overlays[i]); - if (ol->overlays) - free(ol->overlays); + free(ol->overlays); ol->overlays = NULL; } @@ -13722,7 +13720,6 @@ static void input_overlay_free(input_overlay_t *ol) { if (!ol) return; - overlay_ptr = NULL; input_overlay_free_overlays(ol); @@ -13785,7 +13782,16 @@ static void input_overlay_loaded(retro_task_t *task, ol->next_index = (unsigned)((ol->index + 1) % ol->size); ol->state = OVERLAY_STATUS_NONE; ol->alive = true; - overlay_ptr = ol; + + /* Due to the asynchronous nature of overlay loading + * it is possible for overlay_ptr to be non-NULL here + * > Ensure it is free()'d before assigning new pointer */ + if (overlay_ptr) + { + input_overlay_free_overlays(overlay_ptr); + free(overlay_ptr); + } + overlay_ptr = ol; free(data); @@ -14012,6 +14018,7 @@ static void retroarch_overlay_init(void) float overlay_opacity = settings->floats.input_overlay_opacity; float overlay_scale = settings->floats.input_overlay_scale; bool overlay_hide_in_menu = settings->bools.input_overlay_hide_in_menu; + bool load_enabled = input_overlay_enable; #if defined(GEKKO) /* Avoid a crash at startup or even when toggling overlay in rgui */ uint64_t memory_free = frontend_driver_get_free_memory(); @@ -14021,7 +14028,12 @@ static void retroarch_overlay_init(void) retroarch_overlay_deinit(); - if (input_overlay_enable) + /* Cancel load if 'hide_in_menu' is enabled and + * menu is currently active */ + if (overlay_hide_in_menu) + load_enabled = load_enabled && !menu_driver_alive; + + if (load_enabled) task_push_overlay_load_default(input_overlay_loaded, path_overlay, overlay_hide_in_menu, From 521f4bfefc169ca8e3b9814081b893f7126b43ac Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 19 May 2020 17:52:54 +0200 Subject: [PATCH 118/192] Remove more unneeded video_frame_info variables --- retroarch.c | 38 +++++++++++++++----------------------- retroarch.h | 3 --- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/retroarch.c b/retroarch.c index e9a779f1c9..f6d3736f6d 100644 --- a/retroarch.c +++ b/retroarch.c @@ -22507,6 +22507,7 @@ unsigned video_pixel_get_alignment(unsigned pitch) static void video_driver_frame(const void *data, unsigned width, unsigned height, size_t pitch) { + char fps_text[128]; static char video_driver_msg[256]; video_frame_info_t video_info; static retro_time_t curr_time; @@ -22560,19 +22561,19 @@ static void video_driver_frame(const void *data, unsigned width, if (video_info.fps_show) buf_pos = snprintf( - video_info.fps_text, sizeof(video_info.fps_text), + fps_text, sizeof(fps_text), "FPS: %6.2f", last_fps); if (video_info.framecount_show) { char frames_text[64]; - if (video_info.fps_text[buf_pos-1] != '\0') - strlcat(video_info.fps_text, " || ", sizeof(video_info.fps_text)); + if (fps_text[buf_pos-1] != '\0') + strlcat(fps_text, " || ", sizeof(fps_text)); snprintf(frames_text, sizeof(frames_text), "%s: %" PRIu64, msg_hash_to_str(MSG_FRAMES), (uint64_t)video_driver_frame_count); - buf_pos = strlcat(video_info.fps_text, frames_text, sizeof(video_info.fps_text)); + buf_pos = strlcat(fps_text, frames_text, sizeof(fps_text)); } if (video_info.memory_show) @@ -22585,9 +22586,9 @@ static void video_driver_frame(const void *data, unsigned width, snprintf( mem, sizeof(mem), "MEM: %.2f/%.2fMB", mem_bytes_used / (1024.0f * 1024.0f), mem_bytes_total / (1024.0f * 1024.0f)); - if (video_info.fps_text[buf_pos-1] != '\0') - strlcat(video_info.fps_text, " || ", sizeof(video_info.fps_text)); - strlcat(video_info.fps_text, mem, sizeof(video_info.fps_text)); + if (fps_text[buf_pos-1] != '\0') + strlcat(fps_text, " || ", sizeof(fps_text)); + strlcat(fps_text, mem, sizeof(fps_text)); } if ((video_driver_frame_count % fps_update_interval) == 0) @@ -22598,12 +22599,12 @@ static void video_driver_frame(const void *data, unsigned width, strlcpy(video_driver_window_title, video_driver_title_buf, sizeof(video_driver_window_title)); - if (!string_is_empty(video_info.fps_text)) + if (!string_is_empty(fps_text)) { strlcat(video_driver_window_title, " || ", sizeof(video_driver_window_title)); strlcat(video_driver_window_title, - video_info.fps_text, sizeof(video_driver_window_title)); + fps_text, sizeof(video_driver_window_title)); } curr_time = new_time; @@ -22619,9 +22620,9 @@ static void video_driver_frame(const void *data, unsigned width, sizeof(video_driver_window_title)); if (video_info.fps_show) - strlcpy(video_info.fps_text, + strlcpy(fps_text, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), - sizeof(video_info.fps_text)); + sizeof(fps_text)); video_driver_window_title_update = true; } @@ -22775,10 +22776,6 @@ static void video_driver_frame(const void *data, unsigned width, av_info->timing.sample_rate); /* TODO/FIXME - add OSD chat text here */ -#if 0 - snprintf(video_info.chat_text, sizeof(video_info.chat_text), - "anon: does retroarch netplay have in-game chat?\nradius: I don't know \u2605"); -#endif } if (current_video && current_video->frame) @@ -22797,11 +22794,12 @@ static void video_driver_frame(const void *data, unsigned width, { #if defined(HAVE_GFX_WIDGETS) if (widgets_active) - gfx_widgets_set_fps_text(video_info.fps_text); + gfx_widgets_set_fps_text(fps_text); else #endif { - runloop_msg_queue_push(video_info.fps_text, 2, 1, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + runloop_msg_queue_push(fps_text, 2, 1, true, NULL, + MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); } } @@ -22949,10 +22947,6 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->fullscreen = settings->bools.video_fullscreen || retroarch_is_forced_fullscreen(); video_info->menu_mouse_enable = settings->bools.menu_mouse_enable; video_info->monitor_index = settings->uints.video_monitor_index; - video_info->shared_context = settings->bools.video_shared_context; - - if (core_set_shared_context && hwr && hwr->context_type != RETRO_HW_CONTEXT_NONE) - video_info->shared_context = true; video_info->font_enable = settings->bools.video_font_enable; video_info->font_msg_pos_x = settings->floats.video_msg_pos_x; @@ -22967,8 +22961,6 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->custom_vp_full_width = custom_vp->full_width; video_info->custom_vp_full_height = custom_vp->full_height; - video_info->fps_text[0] = '\0'; - #if defined(HAVE_GFX_WIDGETS) video_info->widgets_is_paused = gfx_widgets_paused; video_info->widgets_is_fast_forwarding = gfx_widgets_fast_forward; diff --git a/retroarch.h b/retroarch.h index fbcd16b521..c7d78ceb7a 100644 --- a/retroarch.h +++ b/retroarch.h @@ -1101,7 +1101,6 @@ typedef struct video_frame_info bool widgets_is_rewinding; bool input_menu_swap_ok_cancel_buttons; bool input_driver_nonblock_state; - bool shared_context; bool black_frame_insertion; bool hard_sync; bool fps_show; @@ -1156,9 +1155,7 @@ typedef struct video_frame_info float font_msg_color_b; float xmb_alpha_factor; - char fps_text[128]; char stat_text[512]; - char chat_text[256]; struct { From 4b90fcdeac39763935d5678fa1b8d0b98530e6ba Mon Sep 17 00:00:00 2001 From: Autechre Date: Tue, 19 May 2020 18:06:04 +0200 Subject: [PATCH 119/192] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 51dcf8e202..6f18509806 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,7 @@ - CHD: Return false when special track cannot be found - INPUT MAPPING/REMAPPING: Restore broken 'reset to default' functionality with RetroPad 'start' button - MENU/THUMBNAILS/BUGFIX: Fix heap-use-after-free error +- OVERLAYS: Fix memory leak when loading overlays - WIIU: Gamepad hotplugging support - WIIU: Theoretical multi-gamepad support From 73b9b5b270f15183e77bf0113d5ddc52f3ad9f2c Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Tue, 19 May 2020 17:29:12 +0100 Subject: [PATCH 120/192] Remove last remaining menu hash --- menu/cbs/menu_cbs_start.c | 9 +++------ msg_hash.h | 3 --- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index f7443bec87..cc62e57dfd 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -548,8 +548,10 @@ static int menu_cbs_init_bind_start_compare_label(menu_file_list_cbs_t *cbs) return -1; } } + else + return -1; - return -1; + return 0; } static int menu_cbs_init_bind_start_compare_type(menu_file_list_cbs_t *cbs, @@ -588,11 +590,6 @@ static int menu_cbs_init_bind_start_compare_type(menu_file_list_cbs_t *cbs, { BIND_ACTION_START(cbs, action_start_core_setting); } - /* TODO/FIXME - refactor this */ - else if (type == MENU_LABEL_SCREEN_RESOLUTION) - { - BIND_ACTION_START(cbs, action_start_video_resolution); - } else { switch (type) diff --git a/msg_hash.h b/msg_hash.h index 2b1564de57..df6d0ef7da 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -2812,9 +2812,6 @@ enum msg_hash_enums }; /* Callback strings */ -/* TODO/FIXME - get rid of this */ - -#define MENU_LABEL_SCREEN_RESOLUTION 0x5c9b3a58U const char *msg_hash_to_str(enum msg_hash_enums msg); From 6d37d014a001219b01236726d9a5e609568ae277 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 19 May 2020 20:51:40 +0200 Subject: [PATCH 121/192] Simplify ozone_get_entries_padding --- menu/drivers/ozone/ozone_entries.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/menu/drivers/ozone/ozone_entries.c b/menu/drivers/ozone/ozone_entries.c index de41b106c8..e71a52bd4e 100644 --- a/menu/drivers/ozone/ozone_entries.c +++ b/menu/drivers/ozone/ozone_entries.c @@ -33,17 +33,16 @@ static int ozone_get_entries_padding(ozone_handle_t* ozone, bool old_list) { if (ozone->depth == 1) - if (old_list) - return ozone->dimensions.entry_padding_horizontal_full; - else + { + if (!old_list) return ozone->dimensions.entry_padding_horizontal_half; + } else if (ozone->depth == 2) + { if (old_list && !ozone->fade_direction) /* false = left to right */ return ozone->dimensions.entry_padding_horizontal_half; - else - return ozone->dimensions.entry_padding_horizontal_full; - else - return ozone->dimensions.entry_padding_horizontal_full; + } + return ozone->dimensions.entry_padding_horizontal_full; } static void ozone_draw_entry_value( @@ -146,12 +145,12 @@ static void ozone_draw_entry_value( */ void ozone_update_scroll(ozone_handle_t *ozone, bool allow_animation, ozone_node_t *node) { - file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); - gfx_animation_ctx_tag tag = (uintptr_t) selection_buf; + unsigned video_info_height; gfx_animation_ctx_entry_t entry; float new_scroll = 0, entries_middle; float bottom_boundary, current_selection_middle_onscreen; - unsigned video_info_height; + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + gfx_animation_ctx_tag tag = (uintptr_t) selection_buf; video_driver_get_size(NULL, &video_info_height); @@ -393,16 +392,15 @@ void ozone_draw_entries( settings_t *settings = config_get_ptr(); bool menu_show_sublabels= settings->bools.menu_show_sublabels; bool use_smooth_ticker = settings->bools.menu_ticker_smooth; + enum gfx_animation_ticker_type + menu_ticker_type = (enum gfx_animation_ticker_type) + settings->uints.menu_ticker_type; bool old_list = selection_buf == ozone->selection_buf_old; int x_offset = 0; size_t selection_y = 0; /* 0 means no selection (we assume that no entry has y = 0) */ size_t old_selection_y = 0; int entry_padding = ozone_get_entries_padding(ozone, old_list); - float scale_factor = ozone->last_scale_factor; - enum gfx_animation_ticker_type - menu_ticker_type = (enum gfx_animation_ticker_type) - settings->uints.menu_ticker_type; menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i); From ad1aa59ce103ec4a55fee291383a91b7420df2b3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 19 May 2020 21:15:06 +0200 Subject: [PATCH 122/192] Cleanup != NULL comparisons --- camera/drivers/video4linux2.c | 2 +- frontend/drivers/platform_unix.c | 20 ++++++++++---------- gfx/common/dbus_common.c | 2 +- gfx/drivers/dispmanx_gfx.c | 2 +- gfx/drivers/drm_gfx.c | 2 +- gfx/drivers/exynos_gfx.c | 4 ++-- gfx/drivers_context/x_ctx.c | 6 +++--- input/drivers_joypad/udev_joypad.c | 2 +- input/drivers_joypad/wiiu_joypad.c | 2 +- menu/menu_setting.c | 2 +- network/netplay/netplay_room_parse.c | 4 ++-- wifi/drivers/connmanctl.c | 14 +++++++------- 12 files changed, 31 insertions(+), 31 deletions(-) diff --git a/camera/drivers/video4linux2.c b/camera/drivers/video4linux2.c index 28e8376cdf..cc5d57110c 100644 --- a/camera/drivers/video4linux2.c +++ b/camera/drivers/video4linux2.c @@ -402,7 +402,7 @@ static bool v4l_poll(void *data, if (preprocess_image(data)) { - if (frame_raw_cb != NULL) + if (frame_raw_cb) frame_raw_cb(v4l->buffer_output, v4l->width, v4l->height, v4l->width * 4); return true; diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c index be649a0316..e7ac2bc24b 100644 --- a/frontend/drivers/platform_unix.c +++ b/frontend/drivers/platform_unix.c @@ -164,7 +164,7 @@ int system_property_get(const char *command, while (!feof(pipe)) { - if (fgets(buffer, 128, pipe) != NULL) + if (fgets(buffer, 128, pipe)) { int curlen = strlen(buffer); @@ -306,11 +306,11 @@ static void* onSaveInstanceState( while (!android_app->stateSaved) scond_wait(android_app->cond, android_app->mutex); - if (android_app->savedState != NULL) + if (android_app->savedState) { - savedState = android_app->savedState; - *outLen = android_app->savedStateSize; - android_app->savedState = NULL; + savedState = android_app->savedState; + *outLen = android_app->savedStateSize; + android_app->savedState = NULL; android_app->savedStateSize = 0; } @@ -451,9 +451,9 @@ static struct android_app* android_app_create(ANativeActivity* activity, android_app->mutex = slock_new(); android_app->cond = scond_new(); - if (savedState != NULL) + if (savedState) { - android_app->savedState = malloc(savedStateSize); + android_app->savedState = malloc(savedStateSize); android_app->savedStateSize = savedStateSize; memcpy(android_app->savedState, savedState, savedStateSize); } @@ -1783,10 +1783,10 @@ static void free_saved_state(struct android_app* android_app) { slock_lock(android_app->mutex); - if (android_app->savedState != NULL) + if (android_app->savedState) { free(android_app->savedState); - android_app->savedState = NULL; + android_app->savedState = NULL; android_app->savedStateSize = 0; } @@ -2414,7 +2414,7 @@ enum retro_language frontend_unix_get_user_language(void) #else char *envvar = getenv("LANG"); - if (envvar != NULL) + if (envvar) lang = rarch_get_language_from_iso(envvar); #endif #endif diff --git a/gfx/common/dbus_common.c b/gfx/common/dbus_common.c index 7270510337..68c4838187 100644 --- a/gfx/common/dbus_common.c +++ b/gfx/common/dbus_common.c @@ -93,7 +93,7 @@ bool dbus_screensaver_inhibit(void) reply = dbus_connection_send_with_reply_and_block(dbus_connection, msg, 300, NULL); - if (reply != NULL) + if (reply) { if (!dbus_message_get_args(reply, NULL, DBUS_TYPE_UINT32, &dbus_screensaver_cookie, diff --git a/gfx/drivers/dispmanx_gfx.c b/gfx/drivers/dispmanx_gfx.c index 941065a038..20fbfaaec4 100644 --- a/gfx/drivers/dispmanx_gfx.c +++ b/gfx/drivers/dispmanx_gfx.c @@ -457,7 +457,7 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width, _dispvars->core_pitch = pitch; _dispvars->aspect_ratio = aspect; - if (_dispvars->main_surface != NULL) + if (_dispvars->main_surface) dispmanx_surface_free(_dispvars, &_dispvars->main_surface); /* Internal resolution or ratio has changed, so we need diff --git a/gfx/drivers/drm_gfx.c b/gfx/drivers/drm_gfx.c index 3f18f46410..42e426918a 100644 --- a/gfx/drivers/drm_gfx.c +++ b/gfx/drivers/drm_gfx.c @@ -770,7 +770,7 @@ static bool drm_gfx_frame(void *data, const void *frame, unsigned width, _drmvars->core_height = height; _drmvars->core_pitch = pitch; - if (_drmvars->main_surface != NULL) + if (_drmvars->main_surface) drm_surface_free(_drmvars, &_drmvars->main_surface); /* We need to recreate the main surface and it's pages (buffers). */ diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index d81e29b1ba..cbf5862383 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -247,7 +247,7 @@ static void exynos_clean_up_pages(struct exynos_page *p, unsigned cnt) for (i = 0; i < cnt; ++i) { - if (p[i].bo != NULL) + if (p[i].bo) { if (p[i].buf_id != 0) drmModeRmFB(p[i].buf_id, p[i].bo->handle); @@ -1271,7 +1271,7 @@ static void exynos_gfx_free(void *data) free(pdata); - if (vid->font != NULL && vid->font_driver != NULL) + if (vid->font && vid->font_driver) vid->font_driver->free(vid->font); free(vid); diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index 9446253899..30923add44 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -132,7 +132,7 @@ static int GLXExtensionSupported(Display *dpy, const char *extension) const char *client_extensions = glXGetClientString(dpy, GLX_EXTENSIONS); const char *pos = strstr(extensionsString, extension); - if ( (pos != NULL) && + if ( pos && (pos == extensionsString || pos[-1] == ' ') && (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0') ) @@ -141,7 +141,7 @@ static int GLXExtensionSupported(Display *dpy, const char *extension) pos = strstr(client_extensions, extension); if ( - (pos != NULL) && + pos && (pos == extensionsString || pos[-1] == ' ') && (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0') ) @@ -878,7 +878,7 @@ static bool gfx_ctx_x_set_video_mode(void *data, x->g_glx_win, x->g_glx_win, x->g_ctx); version = (const char*)glGetString(GL_VERSION); - if (strstr(version, " Mesa ") != NULL || !x->g_core_es) + if (strstr(version, " Mesa ") || !x->g_core_es) { /* we are done, break switch case */ XSetErrorHandler(old_handler); diff --git a/input/drivers_joypad/udev_joypad.c b/input/drivers_joypad/udev_joypad.c index 8fb55b3995..e60a8b24ad 100644 --- a/input/drivers_joypad/udev_joypad.c +++ b/input/drivers_joypad/udev_joypad.c @@ -582,7 +582,7 @@ static bool udev_joypad_init(void *data) struct udev_device *dev = udev_device_new_from_syspath(udev_joypad_fd, name); const char *devnode = udev_device_get_devnode(dev); - if (devnode != NULL) + if (devnode) udev_check_device(dev, devnode); udev_device_unref(dev); } diff --git a/input/drivers_joypad/wiiu_joypad.c b/input/drivers_joypad/wiiu_joypad.c index b15746c48f..c490436419 100644 --- a/input/drivers_joypad/wiiu_joypad.c +++ b/input/drivers_joypad/wiiu_joypad.c @@ -45,7 +45,7 @@ static bool wiiu_joypad_query_pad(unsigned pad) { return ready && pad < MAX_USERS && - pad_drivers[pad] != NULL && + pad_drivers[pad] && pad_drivers[pad]->query_pad(pad); } diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 6f92962843..30f6239e24 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -950,7 +950,7 @@ int setting_set_with_string_representation(rarch_setting_t* setting, case ST_STRING: case ST_STRING_OPTIONS: case ST_ACTION: - if ( setting->value.target.string != NULL) + if (setting->value.target.string) strlcpy(setting->value.target.string, value, setting->size); break; case ST_BOOL: diff --git a/network/netplay/netplay_room_parse.c b/network/netplay/netplay_room_parse.c index 6a274c467e..e910bbba88 100644 --- a/network/netplay/netplay_room_parse.c +++ b/network/netplay/netplay_room_parse.c @@ -436,7 +436,7 @@ struct netplay_room* netplay_room_get(int index) if (index < 0) return NULL; - while (room != NULL) + while (room) { if (cur == index) break; @@ -461,7 +461,7 @@ int netplay_rooms_get_count(void) if (!room) return count; - while(room != NULL) + while (room) { count++; diff --git a/wifi/drivers/connmanctl.c b/wifi/drivers/connmanctl.c index c83f3ddd1f..77437ed621 100644 --- a/wifi/drivers/connmanctl.c +++ b/wifi/drivers/connmanctl.c @@ -111,7 +111,7 @@ static void connmanctl_tether_toggle(bool switch_on, char* apname, char* passkey RARCH_LOG("[CONNMANCTL] Tether toggle: command: \"%s\"\n", command); - while (fgets(output, sizeof(output), command_file) != NULL) + while (fgets(output, sizeof(output), command_file)) { if (output[strlen(output)-1] == '\n') output[strlen(output)-1] = '\0'; @@ -176,7 +176,7 @@ static void connmanctl_scan(void) MESSAGE_QUEUE_CATEGORY_INFO); serv_file = popen("connmanctl services", "r"); - while (fgets (line, 512, serv_file) != NULL) + while (fgets(line, 512, serv_file)) { size_t len = strlen(line); if (len > 0 && line[len-1] == '\n') @@ -236,7 +236,7 @@ static bool connmanctl_ssid_is_online(unsigned i) command_file = popen(command, "r"); - while (fgets (ln, 512, command_file) != NULL) + while (fgets(ln, 512, command_file)) { connman_cache[i] = true; return true; @@ -333,7 +333,7 @@ static bool connmanctl_connect_ssid(unsigned idx, const char* passphrase) command_file = popen(command, "r"); - while (fgets (ln, sizeof(ln), command_file) != NULL) + while (fgets(ln, sizeof(ln), command_file)) { #ifdef HAVE_GFX_WIDGETS if (!gfx_widgets_ready()) @@ -414,7 +414,7 @@ static void connmanctl_get_connected_servicename(char* servicename, size_t buffe RARCH_LOG("[CONNMANCTL] Testing configured services for activity: command: \"%s\"\n", command); - while (fgets(temp, buffersize, command_file) != NULL) + while (fgets(temp, buffersize, command_file)) { if (strlen(temp) > 0) if (temp[strlen(temp)-1] == '\n') @@ -547,7 +547,7 @@ static void connmanctl_tether_start_stop(bool start, char* configfile) RARCH_LOG("[CONNMANCTL] Tether start stop: parsing command: \"%s\"\n", command); - while (fgets(ln, sizeof(ln), command_file) != NULL) + while (fgets(ln, sizeof(ln), command_file)) { i++; if (strlen(ln) > 1) @@ -632,7 +632,7 @@ static void connmanctl_tether_start_stop(bool start, char* configfile) RARCH_LOG("[CONNMANCTL] Tether start stop: disconnecting from service \"%s\", command: \"%s\"\n", service, command); - while (fgets(ln, sizeof(ln), command_file) != NULL) + while (fgets(ln, sizeof(ln), command_file)) { if (ln[strlen(ln)-1] == '\n') ln[strlen(ln)-1] = '\0'; From 2a36fa0855394b1ec1ffed7f5e0612105622d72e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 19 May 2020 21:29:35 +0200 Subject: [PATCH 123/192] Remove double ';' --- gfx/drivers_shader/glslang_util_cxx.cpp | 2 +- record/drivers/record_ffmpeg.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/drivers_shader/glslang_util_cxx.cpp b/gfx/drivers_shader/glslang_util_cxx.cpp index ffb65dcfd3..4155119926 100644 --- a/gfx/drivers_shader/glslang_util_cxx.cpp +++ b/gfx/drivers_shader/glslang_util_cxx.cpp @@ -54,7 +54,7 @@ static std::string build_stage_source( return ""; /* Version header. */ - str << lines->elems[0].data;; + str << lines->elems[0].data; str << '\n'; for (i = 1; i < lines->size; i++) diff --git a/record/drivers/record_ffmpeg.c b/record/drivers/record_ffmpeg.c index 7a5383d292..bfd6531098 100644 --- a/record/drivers/record_ffmpeg.c +++ b/record/drivers/record_ffmpeg.c @@ -1604,7 +1604,7 @@ static void ffmpeg_flush_video(ffmpeg_t *handle) static void ffmpeg_flush_buffers(ffmpeg_t *handle) { void *audio_buf = NULL; - bool did_work = false;; + bool did_work = false; void *video_buf = av_malloc(2 * handle->params.fb_width * handle->params.fb_height * handle->video.pix_size); size_t audio_buf_size = handle->config.audio_enable ? From 182ad31c635f0241ba2892902e1260fb5a17e323 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 02:19:20 +0200 Subject: [PATCH 124/192] (retroarch.c) Relocate structs and enums --- retroarch.c | 97 ++++++++++++++++++++++++++--------------------------- 1 file changed, 48 insertions(+), 49 deletions(-) diff --git a/retroarch.c b/retroarch.c index 87b5d31801..cbc83ac021 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1068,6 +1068,13 @@ enum runloop_state RUNLOOP_STATE_QUIT }; +enum rarch_movie_type +{ + RARCH_MOVIE_PLAYBACK = 0, + RARCH_MOVIE_RECORD +}; + + typedef struct runloop_ctx_msg_info { const char *msg; @@ -1076,6 +1083,47 @@ typedef struct runloop_ctx_msg_info bool flush; } runloop_ctx_msg_info_t; +struct rarch_dir_list +{ + struct string_list *list; + size_t ptr; +}; + +struct bsv_state +{ + bool movie_start_recording; + bool movie_start_playback; + bool movie_playback; + bool eof_exit; + bool movie_end; + + /* Movie playback/recording support. */ + char movie_path[PATH_MAX_LENGTH]; + /* Immediate playback/recording. */ + char movie_start_path[PATH_MAX_LENGTH]; +}; + +struct bsv_movie +{ + intfstream_t *file; + + /* A ring buffer keeping track of positions + * in the file for each frame. */ + size_t *frame_pos; + size_t frame_mask; + size_t frame_ptr; + + size_t min_file_pos; + + size_t state_size; + uint8_t *state; + + bool playback; + bool first_rewind; + bool did_rewind; +}; + + static struct global g_extern; static struct retro_callbacks retro_ctx; static struct retro_core_t current_core; @@ -1191,13 +1239,6 @@ static char current_valid_extensions[1024] = {0}; static char error_string[255] = {0}; static char cached_video_driver[32] = {0}; -/* PATHS */ -struct rarch_dir_list -{ - struct string_list *list; - size_t ptr; -}; - static struct string_list *subsystem_fullpaths = NULL; static char subsystem_path[PATH_MAX_LENGTH] = {0}; @@ -1217,48 +1258,6 @@ static char current_savefile_dir[PATH_MAX_LENGTH] = {0}; static char current_savestate_dir[PATH_MAX_LENGTH] = {0}; static char dir_savestate[PATH_MAX_LENGTH] = {0}; -/* BSV MOVIE GLOBAL VARIABLES */ - -enum rarch_movie_type -{ - RARCH_MOVIE_PLAYBACK = 0, - RARCH_MOVIE_RECORD -}; - -struct bsv_state -{ - bool movie_start_recording; - bool movie_start_playback; - bool movie_playback; - bool eof_exit; - bool movie_end; - - /* Movie playback/recording support. */ - char movie_path[PATH_MAX_LENGTH]; - /* Immediate playback/recording. */ - char movie_start_path[PATH_MAX_LENGTH]; -}; - -struct bsv_movie -{ - intfstream_t *file; - - /* A ring buffer keeping track of positions - * in the file for each frame. */ - size_t *frame_pos; - size_t frame_mask; - size_t frame_ptr; - - size_t min_file_pos; - - size_t state_size; - uint8_t *state; - - bool playback; - bool first_rewind; - bool did_rewind; -}; - #define BSV_MAGIC 0x42535631 #define MAGIC_INDEX 0 From 5852251d56aeda4c61b5d2f3b34bc7a916b248c5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 02:25:33 +0200 Subject: [PATCH 125/192] Fix --disable-menu --- retroarch.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/retroarch.c b/retroarch.c index cbc83ac021..ad17a5742a 100644 --- a/retroarch.c +++ b/retroarch.c @@ -14016,8 +14016,12 @@ static void retroarch_overlay_init(void) const char *path_overlay = settings->paths.path_overlay; float overlay_opacity = settings->floats.input_overlay_opacity; float overlay_scale = settings->floats.input_overlay_scale; - bool overlay_hide_in_menu = settings->bools.input_overlay_hide_in_menu; bool load_enabled = input_overlay_enable; +#ifdef HAVE_MENU + bool overlay_hide_in_menu = settings->bools.input_overlay_hide_in_menu; +#else + bool overlay_hide_in_menu = false; +#endif #if defined(GEKKO) /* Avoid a crash at startup or even when toggling overlay in rgui */ uint64_t memory_free = frontend_driver_get_free_memory(); @@ -14027,10 +14031,12 @@ static void retroarch_overlay_init(void) retroarch_overlay_deinit(); +#ifdef HAVE_MENU /* Cancel load if 'hide_in_menu' is enabled and * menu is currently active */ if (overlay_hide_in_menu) load_enabled = load_enabled && !menu_driver_alive; +#endif if (load_enabled) task_push_overlay_load_default(input_overlay_loaded, From 2cc776d2d9a8b4fef025aee205eae3808607cb13 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 02:42:39 +0200 Subject: [PATCH 126/192] Cleanups --- gfx/gfx_widgets.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gfx/gfx_widgets.c b/gfx/gfx_widgets.c index 53219d776c..32a5c437a5 100644 --- a/gfx/gfx_widgets.c +++ b/gfx/gfx_widgets.c @@ -1407,6 +1407,7 @@ static void gfx_widgets_draw_regular_msg( } } +#ifdef HAVE_MENU static void gfx_widgets_draw_backdrop( void *userdata, unsigned video_width, @@ -1425,7 +1426,6 @@ static void gfx_widgets_draw_load_content_animation( unsigned video_width, unsigned video_height) { -#ifdef HAVE_MENU /* TODO: change metrics? */ int icon_size = (int)load_content_animation_icon_size; uint32_t text_alpha = load_content_animation_fade_alpha * 255.0f; @@ -1476,8 +1476,8 @@ static void gfx_widgets_draw_load_content_animation( gfx_widgets_draw_backdrop(userdata, video_width, video_height, load_content_animation_final_fade_alpha); -#endif } +#endif static void INLINE gfx_widgets_font_bind(gfx_widget_font_data_t *font_data) { @@ -2287,6 +2287,7 @@ void gfx_widgets_ai_service_overlay_unload(void) } #endif +#ifdef HAVE_MENU static void gfx_widgets_end_load_content_animation(void *userdata) { #if 0 @@ -2296,13 +2297,12 @@ static void gfx_widgets_end_load_content_animation(void *userdata) void gfx_widgets_cleanup_load_content_animation(void) { -#ifdef HAVE_MENU load_content_animation_running = false; if (load_content_animation_content_name) free(load_content_animation_content_name); load_content_animation_content_name = NULL; -#endif } +#endif void gfx_widgets_start_load_content_animation(const char *content_name, bool remove_extension) { From 969475254f241ad2c49f5ca05cc42a90ae09bc7a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 03:30:04 +0200 Subject: [PATCH 127/192] (retroarch.c) Reorganize globals, forward declarations, and defines --- retroarch.c | 1472 +++++++++++++++++++++++++-------------------------- 1 file changed, 724 insertions(+), 748 deletions(-) diff --git a/retroarch.c b/retroarch.c index ad17a5742a..f9c9a6ca17 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1028,6 +1028,50 @@ static const camera_driver_t *camera_drivers[] = { #define DEBUG_INFO_FILENAME "debug_info.txt" +#define BSV_MAGIC 0x42535631 + +#define MAGIC_INDEX 0 +#define SERIALIZER_INDEX 1 +#define CRC_INDEX 2 +#define STATE_SIZE_INDEX 3 + +#define BSV_MOVIE_IS_PLAYBACK_ON() (bsv_movie_state_handle && bsv_movie_state.movie_playback) +#define BSV_MOVIE_IS_PLAYBACK_OFF() (bsv_movie_state_handle && !bsv_movie_state.movie_playback) + +#define MEASURE_FRAME_TIME_SAMPLES_COUNT (2 * 1024) + +#define TIME_TO_FPS(last_time, new_time, frames) ((1000000.0f * (frames)) / ((new_time) - (last_time))) + +#define AUDIO_BUFFER_FREE_SAMPLES_COUNT (8 * 1024) + +#define MENU_SOUND_FORMATS "ogg|mod|xm|s3m|mp3|flac" + +#define MIDI_DRIVER_BUF_SIZE 4096 + +/** + * db_to_gain: + * @db : Decibels. + * + * Converts decibels to voltage gain. + * + * Returns: voltage gain value. + **/ +#define db_to_gain(db) (powf(10.0f, (db) / 20.0f)) + +#define DEFAULT_NETWORK_GAMEPAD_PORT 55400 +#define UDP_FRAME_PACKETS 16 + +#ifdef HAVE_OVERLAY +#define OVERLAY_GET_KEY(state, key) (((state)->keys[(key) / 32] >> ((key) % 32)) & 1) +#define OVERLAY_SET_KEY(state, key) (state)->keys[(key) / 32] |= 1 << ((key) % 32) + +#define MAX_VISIBILITY 32 +#endif + +#define DECLARE_BIND(x, bind, desc) { true, 0, #x, desc, bind } +#define DECLARE_META_BIND(level, x, bind, desc) { true, level, #x, desc, bind } + + /* Descriptive names for options without short variant. * * Please keep the name in sync with the option name. @@ -1123,6 +1167,18 @@ struct bsv_movie bool did_rewind; }; +typedef struct video_pixel_scaler +{ + struct scaler_ctx *scaler; + void *scaler_out; +} video_pixel_scaler_t; + +typedef struct +{ + enum gfx_ctx_api api; + struct string_list *list; +} gfx_api_gpu_map; + static struct global g_extern; static struct retro_callbacks retro_ctx; @@ -1219,11 +1275,9 @@ static bool runloop_max_frames_screenshot = false; #ifdef HAVE_RUNAHEAD static bool has_variable_update = false; #endif -#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) -static bool shader_presets_need_reload = true; -#endif #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) +static bool shader_presets_need_reload = true; static char cli_shader[PATH_MAX_LENGTH] = {0}; static bool cli_shader_disable = false; static char runtime_shader_preset[PATH_MAX_LENGTH] = {0}; @@ -1258,21 +1312,615 @@ static char current_savefile_dir[PATH_MAX_LENGTH] = {0}; static char current_savestate_dir[PATH_MAX_LENGTH] = {0}; static char dir_savestate[PATH_MAX_LENGTH] = {0}; -#define BSV_MAGIC 0x42535631 +#ifdef HAVE_GFX_WIDGETS +static bool gfx_widgets_paused = false; +static bool gfx_widgets_fast_forward = false; +static bool gfx_widgets_rewinding = false; +#endif -#define MAGIC_INDEX 0 -#define SERIALIZER_INDEX 1 -#define CRC_INDEX 2 -#define STATE_SIZE_INDEX 3 +#ifdef HAVE_ACCESSIBILITY +/* Is text-to-speech accessibility turned on? */ +static bool accessibility_enabled = false; +#endif -#define BSV_MOVIE_IS_PLAYBACK_ON() (bsv_movie_state_handle && bsv_movie_state.movie_playback) -#define BSV_MOVIE_IS_PLAYBACK_OFF() (bsv_movie_state_handle && !bsv_movie_state.movie_playback) +#ifdef HAVE_MENU +static const char **menu_input_dialog_keyboard_buffer = {NULL}; +static unsigned menu_input_dialog_keyboard_type = 0; +static unsigned menu_input_dialog_keyboard_idx = 0; +static char menu_input_dialog_keyboard_label_setting[256] = {0}; +static char menu_input_dialog_keyboard_label[256] = {0}; +static bool menu_input_dialog_keyboard_display = false; +static unsigned char menu_keyboard_key_state[RETROK_LAST] = {0}; + +/* Since these are static/global, they are initialised to zero */ +static menu_input_pointer_hw_state_t menu_input_pointer_hw_state; +static menu_input_t menu_input_state; + +/* Is the menu driver still running? */ +static bool menu_driver_alive = false; +/* Are we binding a button inside the menu? */ +static bool menu_driver_is_binding = false; +#endif + +static unsigned recording_width = 0; +static unsigned recording_height = 0; +static size_t recording_gpu_width = 0; +static size_t recording_gpu_height = 0; +static bool recording_enable = false; +static bool streaming_enable = false; + +static const record_driver_t *recording_driver = NULL; +static void *recording_data = NULL; + +static uint8_t *video_driver_record_gpu_buffer = NULL; + +#ifdef HAVE_THREADS +static slock_t *_runloop_msg_queue_lock = NULL; +#endif + +static struct retro_camera_callback camera_cb; +static const camera_driver_t *camera_driver = NULL; +static void *camera_data = NULL; +static bool camera_driver_active = false; + +static midi_driver_t *midi_drv = &midi_null; +static void *midi_drv_data = NULL; +static struct string_list *midi_drv_inputs = NULL; +static struct string_list *midi_drv_outputs = NULL; +static bool midi_drv_input_enabled = false; +static bool midi_drv_output_enabled = false; +static uint8_t *midi_drv_input_buffer = NULL; +static uint8_t *midi_drv_output_buffer = NULL; +static midi_event_t midi_drv_input_event; +static midi_event_t midi_drv_output_event; +static bool midi_drv_output_pending = false; + +static const uint8_t midi_drv_ev_sizes[128] = +{ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 0, 2, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +}; + +static bool main_ui_companion_is_on_foreground = false; +static const ui_companion_driver_t *ui_companion = NULL; +static void *ui_companion_data = NULL; + +#ifdef HAVE_QT +static void *ui_companion_qt_data = NULL; +static bool qt_is_inited = false; +#endif + +static const location_driver_t *location_driver = NULL; +static void *location_data = NULL; + +static bool location_driver_active = false; + +static const wifi_driver_t *wifi_driver = NULL; +static void *wifi_data = NULL; +static bool wifi_driver_active = false; + +static const video_display_server_t *current_display_server = &dispserv_null; +static void *current_display_server_data = NULL; +static enum rotation initial_screen_orientation = ORIENTATION_NORMAL; +static enum rotation current_screen_orientation = ORIENTATION_NORMAL; typedef struct bsv_movie bsv_movie_t; static bsv_movie_t *bsv_movie_state_handle = NULL; static struct bsv_state bsv_movie_state; +struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { + { "4:3", 1.3333f }, + { "16:9", 1.7778f }, + { "16:10", 1.6f }, + { "16:15", 16.0f / 15.0f }, + { "21:9", 21.0f / 9.0f }, + { "1:1", 1.0f }, + { "2:1", 2.0f }, + { "3:2", 1.5f }, + { "3:4", 0.75f }, + { "4:1", 4.0f }, + { "9:16", 0.5625f }, + { "5:4", 1.25f }, + { "6:5", 1.2f }, + { "7:9", 0.7777f }, + { "8:3", 2.6666f }, + { "8:7", 1.1428f }, + { "19:12", 1.5833f }, + { "19:14", 1.3571f }, + { "30:17", 1.7647f }, + { "32:9", 3.5555f }, + { "Config", 0.0f }, + { "Square pixel", 1.0f }, + { "Core provided", 1.0f }, + { "Custom", 0.0f } +}; + +static gfx_api_gpu_map gpu_map[] = { + { GFX_CTX_VULKAN_API, NULL }, + { GFX_CTX_DIRECT3D10_API, NULL }, + { GFX_CTX_DIRECT3D11_API, NULL }, + { GFX_CTX_DIRECT3D12_API, NULL } +}; + +/* Opaque handles to currently running window. + * Used by e.g. input drivers which bind to a window. + * Drivers are responsible for setting these if an input driver + * could potentially make use of this. */ +static uintptr_t video_driver_display_userdata = 0; +static uintptr_t video_driver_display = 0; +static uintptr_t video_driver_window = 0; + +static rarch_softfilter_t *video_driver_state_filter = NULL; +static void *video_driver_state_buffer = NULL; +static unsigned video_driver_state_scale = 0; +static unsigned video_driver_state_out_bpp = 0; +static bool video_driver_state_out_rgb32 = false; +static bool video_driver_crt_switching_active = false; +static bool video_driver_crt_dynamic_super_width = false; + +static enum retro_pixel_format video_driver_pix_fmt = RETRO_PIXEL_FORMAT_0RGB1555; + +static const void *frame_cache_data = NULL; +static unsigned frame_cache_width = 0; +static unsigned frame_cache_height = 0; +static size_t frame_cache_pitch = 0; +static bool video_driver_threaded = false; + +static float video_driver_core_hz = 0.0f; +static float video_driver_aspect_ratio = 0.0f; +static unsigned video_driver_width = 0; +static unsigned video_driver_height = 0; + +static enum rarch_display_type video_driver_display_type = RARCH_DISPLAY_NONE; +static char video_driver_title_buf[64] = {0}; +static char video_driver_window_title[512] = {0}; +static bool video_driver_window_title_update = true; + +static retro_time_t video_driver_frame_time_samples[MEASURE_FRAME_TIME_SAMPLES_COUNT]; +static uint64_t video_driver_frame_time_count = 0; +static uint64_t video_driver_frame_count = 0; + +static void *video_driver_data = NULL; +static video_driver_t *current_video = NULL; + +/* Interface for "poking". */ +static const video_poke_interface_t *video_driver_poke = NULL; + +/* Used for 15-bit -> 16-bit conversions that take place before + * being passed to video driver. */ +static video_pixel_scaler_t *video_driver_scaler_ptr = NULL; + +static struct retro_hw_render_callback hw_render; + +static const struct +retro_hw_render_context_negotiation_interface * +hw_render_context_negotiation = NULL; + +/* 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 bool video_driver_use_rgba = 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; + +#ifdef HAVE_THREADS +static slock_t *display_lock = NULL; +static slock_t *context_lock = NULL; +#endif + +static gfx_ctx_driver_t current_video_context; + +static void *video_context_data = NULL; + +/** + * dynamic.c:dynamic_request_hw_context will try to set flag data when the context + * is in the middle of being rebuilt; in these cases we will save flag + * data and set this to true. + * When the context is reinit, it checks this, reads from + * deferred_flag_data and cleans it. + * + * TODO - Dirty hack, fix it better + */ +static bool deferred_video_context_driver_set_flags = false; +static gfx_ctx_flags_t deferred_flag_data = {0}; + +static bool video_started_fullscreen = false; + +static char video_driver_gpu_device_string[128] = {0}; +static char video_driver_gpu_api_version_string[128] = {0}; + +static struct retro_system_av_info video_driver_av_info; + +#ifdef HAVE_AUDIOMIXER +static struct audio_mixer_stream +audio_mixer_streams[AUDIO_MIXER_MAX_SYSTEM_STREAMS] = {{0}}; + +static bool audio_driver_mixer_mute_enable = false; +static bool audio_mixer_active = false; +static float audio_driver_mixer_volume_gain = 0.0f; +#endif + +static size_t audio_driver_chunk_size = 0; +static size_t audio_driver_chunk_nonblock_size = 0; +static size_t audio_driver_chunk_block_size = 0; + +static size_t audio_driver_rewind_ptr = 0; +static size_t audio_driver_rewind_size = 0; + +static int16_t *audio_driver_rewind_buf = NULL; +static int16_t *audio_driver_output_samples_conv_buf = NULL; + +static unsigned audio_driver_free_samples_buf[AUDIO_BUFFER_FREE_SAMPLES_COUNT]; +static uint64_t audio_driver_free_samples_count = 0; + +static size_t audio_driver_buffer_size = 0; +static size_t audio_driver_data_ptr = 0; + +static bool audio_driver_control = false; +static bool audio_driver_mute_enable = false; +static bool audio_driver_use_float = false; +static bool audio_driver_active = false; + +static float audio_driver_rate_control_delta = 0.0f; +static float audio_driver_input = 0.0f; +static float audio_driver_volume_gain = 0.0f; + +static float *audio_driver_input_data = NULL; +static float *audio_driver_output_samples_buf = NULL; + +static double audio_source_ratio_original = 0.0f; +static double audio_source_ratio_current = 0.0f; + +static struct retro_audio_callback audio_callback = {0}; + +static retro_dsp_filter_t *audio_driver_dsp = NULL; +static struct string_list *audio_driver_devices_list = NULL; +static const retro_resampler_t *audio_driver_resampler = NULL; + +static void *audio_driver_resampler_data = NULL; +static const audio_driver_t *current_audio = NULL; +static void *audio_driver_context_audio_data = NULL; + +static bool audio_suspended = false; +static bool audio_is_threaded = false; + +typedef struct input_list_element_t +{ + unsigned port; + unsigned device; + unsigned index; + int16_t *state; + unsigned int state_size; +} input_list_element; + +#ifdef HAVE_RUNAHEAD +static size_t runahead_save_state_size = 0; + +static bool runahead_save_state_size_known = false; +static bool request_fast_savestate = false; +static bool hard_disable_audio = false; + +/* Save State List for Run Ahead */ +typedef void *(*constructor_t)(void); +typedef void (*destructor_t )(void*); + +typedef struct MyList_t +{ + void **data; + int capacity; + int size; + constructor_t constructor; + destructor_t destructor; +} MyList; + +static MyList *runahead_save_state_list = NULL; +static MyList *input_state_list = NULL; + +static bool input_is_dirty = false; + +typedef bool(*runahead_load_state_function)(const void*, size_t); + +static retro_input_state_t input_state_callback_original; +static function_t retro_reset_callback_original = NULL; +static runahead_load_state_function +retro_unserialize_callback_original = NULL; + +static function_t original_retro_deinit = NULL; +static function_t original_retro_unload = NULL; + +static bool runahead_video_driver_is_active = true; +static bool runahead_available = true; +static bool runahead_secondary_core_available = true; +static bool runahead_force_input_dirty = true; +static uint64_t runahead_last_frame_count = 0; +#endif + +#if defined(HAVE_NETWORKING) +static bool has_set_netplay_mode = false; +static bool has_set_netplay_ip_address = false; +static bool has_set_netplay_ip_port = false; +static bool has_set_netplay_stateless_mode = false; +static bool has_set_netplay_check_frames = false; +#endif + +struct remote_message +{ + int port; + int device; + int index; + int id; + uint16_t state; +}; + +struct input_remote +{ + bool state[RARCH_BIND_LIST_END]; +#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) + int net_fd[MAX_USERS]; +#endif +}; + +typedef struct input_remote input_remote_t; + +typedef struct input_remote_state +{ + /* Left X, Left Y, Right X, Right Y */ + int16_t analog[4][MAX_USERS]; + /* This is a bitmask of (1 << key_bind_id). */ + uint64_t buttons[MAX_USERS]; +} input_remote_state_t; + +#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) +static input_remote_state_t remote_st_ptr; +#endif + +#ifdef HAVE_OVERLAY +static enum overlay_visibility* visibility = NULL; + +typedef struct input_overlay_state +{ + /* Left X, Left Y, Right X, Right Y */ + int16_t analog[4]; + uint32_t keys[RETROK_LAST / 32 + 1]; + /* This is a bitmask of (1 << key_bind_id). */ + input_bits_t buttons; +} input_overlay_state_t; + +struct input_overlay +{ + enum overlay_status state; + + bool enable; + bool blocked; + bool alive; + + unsigned next_index; + + size_t index; + size_t size; + + struct overlay *overlays; + const struct overlay *active; + void *iface_data; + const video_overlay_interface_t *iface; + + input_overlay_state_t overlay_state; +}; + +static input_overlay_t *overlay_ptr = NULL; +#endif + +/* Input config. */ +struct input_bind_map +{ + bool valid; + + /* Meta binds get input as prefix, not input_playerN". + * 0 = libretro related. + * 1 = Common hotkey. + * 2 = Uncommon/obscure hotkey. + */ + uint8_t meta; + + const char *base; + enum msg_hash_enums desc; + uint8_t retro_key; +}; + +static pad_connection_listener_t *pad_connection_listener = NULL; + +static uint16_t input_config_vid[MAX_USERS]; +static uint16_t input_config_pid[MAX_USERS]; + +static char input_device_display_names[MAX_INPUT_DEVICES][64]; +static char input_device_config_names [MAX_INPUT_DEVICES][64]; +static char input_device_config_paths [MAX_INPUT_DEVICES][64]; +char input_device_names [MAX_INPUT_DEVICES][64]; + +uint64_t lifecycle_state; +struct retro_keybind input_config_binds[MAX_USERS][RARCH_BIND_LIST_END]; +struct retro_keybind input_autoconf_binds[MAX_USERS][RARCH_BIND_LIST_END]; +static const struct retro_keybind *libretro_input_binds[MAX_USERS]; + +const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = { + DECLARE_BIND(b, RETRO_DEVICE_ID_JOYPAD_B, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B), + DECLARE_BIND(y, RETRO_DEVICE_ID_JOYPAD_Y, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y), + DECLARE_BIND(select, RETRO_DEVICE_ID_JOYPAD_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT), + DECLARE_BIND(start, RETRO_DEVICE_ID_JOYPAD_START, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START), + DECLARE_BIND(up, RETRO_DEVICE_ID_JOYPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP), + DECLARE_BIND(down, RETRO_DEVICE_ID_JOYPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN), + DECLARE_BIND(left, RETRO_DEVICE_ID_JOYPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT), + DECLARE_BIND(right, RETRO_DEVICE_ID_JOYPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT), + DECLARE_BIND(a, RETRO_DEVICE_ID_JOYPAD_A, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A), + DECLARE_BIND(x, RETRO_DEVICE_ID_JOYPAD_X, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X), + DECLARE_BIND(l, RETRO_DEVICE_ID_JOYPAD_L, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L), + DECLARE_BIND(r, RETRO_DEVICE_ID_JOYPAD_R, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R), + DECLARE_BIND(l2, RETRO_DEVICE_ID_JOYPAD_L2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2), + DECLARE_BIND(r2, RETRO_DEVICE_ID_JOYPAD_R2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2), + DECLARE_BIND(l3, RETRO_DEVICE_ID_JOYPAD_L3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3), + DECLARE_BIND(r3, RETRO_DEVICE_ID_JOYPAD_R3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3), + DECLARE_BIND(l_x_plus, RARCH_ANALOG_LEFT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS), + DECLARE_BIND(l_x_minus, RARCH_ANALOG_LEFT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS), + DECLARE_BIND(l_y_plus, RARCH_ANALOG_LEFT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS), + DECLARE_BIND(l_y_minus, RARCH_ANALOG_LEFT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS), + DECLARE_BIND(r_x_plus, RARCH_ANALOG_RIGHT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS), + DECLARE_BIND(r_x_minus, RARCH_ANALOG_RIGHT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS), + DECLARE_BIND(r_y_plus, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS), + DECLARE_BIND(r_y_minus, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS), + + DECLARE_BIND( gun_trigger, RARCH_LIGHTGUN_TRIGGER, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER ), + DECLARE_BIND( gun_offscreen_shot, RARCH_LIGHTGUN_RELOAD, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD ), + DECLARE_BIND( gun_aux_a, RARCH_LIGHTGUN_AUX_A, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A ), + DECLARE_BIND( gun_aux_b, RARCH_LIGHTGUN_AUX_B, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B ), + DECLARE_BIND( gun_aux_c, RARCH_LIGHTGUN_AUX_C, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C ), + DECLARE_BIND( gun_start, RARCH_LIGHTGUN_START, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START ), + DECLARE_BIND( gun_select, RARCH_LIGHTGUN_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT ), + DECLARE_BIND( gun_dpad_up, RARCH_LIGHTGUN_DPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP ), + DECLARE_BIND( gun_dpad_down, RARCH_LIGHTGUN_DPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN ), + DECLARE_BIND( gun_dpad_left, RARCH_LIGHTGUN_DPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT ), + DECLARE_BIND( gun_dpad_right, RARCH_LIGHTGUN_DPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT ), + + DECLARE_BIND(turbo, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE), + + DECLARE_META_BIND(1, toggle_fast_forward, RARCH_FAST_FORWARD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY), + DECLARE_META_BIND(2, hold_fast_forward, RARCH_FAST_FORWARD_HOLD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_HOLD_KEY), + DECLARE_META_BIND(1, toggle_slowmotion, RARCH_SLOWMOTION_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION_KEY), + DECLARE_META_BIND(2, hold_slowmotion, RARCH_SLOWMOTION_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION_HOLD_KEY), + DECLARE_META_BIND(1, load_state, RARCH_LOAD_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_LOAD_STATE_KEY), + DECLARE_META_BIND(1, save_state, RARCH_SAVE_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SAVE_STATE_KEY), + DECLARE_META_BIND(2, toggle_fullscreen, RARCH_FULLSCREEN_TOGGLE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY), +#ifdef HAVE_LAKKA + DECLARE_META_BIND(2, exit_emulator, RARCH_QUIT_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_RESTART_KEY), +#else + DECLARE_META_BIND(2, exit_emulator, RARCH_QUIT_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_QUIT_KEY), +#endif + DECLARE_META_BIND(2, state_slot_increase, RARCH_STATE_SLOT_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_PLUS), + DECLARE_META_BIND(2, state_slot_decrease, RARCH_STATE_SLOT_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_MINUS), + DECLARE_META_BIND(1, rewind, RARCH_REWIND, MENU_ENUM_LABEL_VALUE_INPUT_META_REWIND), + DECLARE_META_BIND(2, movie_record_toggle, RARCH_BSV_RECORD_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_BSV_RECORD_TOGGLE), + DECLARE_META_BIND(2, pause_toggle, RARCH_PAUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_PAUSE_TOGGLE), + DECLARE_META_BIND(2, frame_advance, RARCH_FRAMEADVANCE, MENU_ENUM_LABEL_VALUE_INPUT_META_FRAMEADVANCE), + DECLARE_META_BIND(2, reset, RARCH_RESET, MENU_ENUM_LABEL_VALUE_INPUT_META_RESET), + DECLARE_META_BIND(2, shader_next, RARCH_SHADER_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_NEXT), + DECLARE_META_BIND(2, shader_prev, RARCH_SHADER_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_PREV), + DECLARE_META_BIND(2, cheat_index_plus, RARCH_CHEAT_INDEX_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_PLUS), + DECLARE_META_BIND(2, cheat_index_minus, RARCH_CHEAT_INDEX_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_MINUS), + DECLARE_META_BIND(2, cheat_toggle, RARCH_CHEAT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_TOGGLE), + DECLARE_META_BIND(2, screenshot, RARCH_SCREENSHOT, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT), + DECLARE_META_BIND(2, audio_mute, RARCH_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE), + DECLARE_META_BIND(2, osk_toggle, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK), + DECLARE_META_BIND(2, fps_toggle, RARCH_FPS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE), + DECLARE_META_BIND(2, send_debug_info, RARCH_SEND_DEBUG_INFO, MENU_ENUM_LABEL_VALUE_INPUT_META_SEND_DEBUG_INFO), + DECLARE_META_BIND(2, netplay_host_toggle, RARCH_NETPLAY_HOST_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_HOST_TOGGLE), + DECLARE_META_BIND(2, netplay_game_watch, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH), + DECLARE_META_BIND(2, enable_hotkey, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY), + DECLARE_META_BIND(2, volume_up, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP), + DECLARE_META_BIND(2, volume_down, RARCH_VOLUME_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_DOWN), + DECLARE_META_BIND(2, overlay_next, RARCH_OVERLAY_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_OVERLAY_NEXT), + DECLARE_META_BIND(2, disk_eject_toggle, RARCH_DISK_EJECT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_EJECT_TOGGLE), + DECLARE_META_BIND(2, disk_next, RARCH_DISK_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_NEXT), + DECLARE_META_BIND(2, disk_prev, RARCH_DISK_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_PREV), + DECLARE_META_BIND(2, grab_mouse_toggle, RARCH_GRAB_MOUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GRAB_MOUSE_TOGGLE), + DECLARE_META_BIND(2, game_focus_toggle, RARCH_GAME_FOCUS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GAME_FOCUS_TOGGLE), + DECLARE_META_BIND(2, desktop_menu_toggle, RARCH_UI_COMPANION_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_UI_COMPANION_TOGGLE), +#ifdef HAVE_MENU + DECLARE_META_BIND(1, menu_toggle, RARCH_MENU_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MENU_TOGGLE), +#endif + DECLARE_META_BIND(2, recording_toggle, RARCH_RECORDING_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_RECORDING_TOGGLE), + DECLARE_META_BIND(2, streaming_toggle, RARCH_STREAMING_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_STREAMING_TOGGLE), + DECLARE_META_BIND(2, ai_service, RARCH_AI_SERVICE, MENU_ENUM_LABEL_VALUE_INPUT_META_AI_SERVICE), +}; + +typedef struct turbo_buttons turbo_buttons_t; + +/* Turbo support. */ +struct turbo_buttons +{ + bool frame_enable[MAX_USERS]; + uint16_t enable[MAX_USERS]; + bool mode1_enable[MAX_USERS]; + int32_t turbo_pressed[MAX_USERS]; + unsigned count; +}; + +struct input_keyboard_line +{ + char *buffer; + size_t ptr; + size_t size; + + /** Line complete callback. + * Calls back after return is + * pressed with the completed line. + * Line can be NULL. + **/ + input_keyboard_line_complete_t cb; + void *userdata; +}; + +static bool input_driver_keyboard_linefeed_enable = false; +static input_keyboard_line_t *g_keyboard_line = NULL; + +static void *g_keyboard_press_data = NULL; + +static unsigned osk_last_codepoint = 0; +static unsigned osk_last_codepoint_len = 0; + +static input_keyboard_press_t g_keyboard_press_cb; + +static turbo_buttons_t input_driver_turbo_btns; +#ifdef HAVE_COMMAND +static command_t *input_driver_command = NULL; +#endif +#ifdef HAVE_NETWORKGAMEPAD +static input_remote_t *input_driver_remote = NULL; +#endif +static input_mapper_t *input_driver_mapper = NULL; +static 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_nonblock_state = false; +static unsigned input_driver_flushing_input = 0; +static float input_driver_axis_threshold = 0.0f; +static unsigned input_driver_max_users = 0; + +#ifdef HAVE_HID +static const void *hid_data = NULL; +#endif + +#if defined(HAVE_RUNAHEAD) +static enum rarch_core_type last_core_type; +static retro_ctx_load_content_info_t *load_content_info; + +#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB) +static int port_map[16]; + +static dylib_t secondary_module; +static struct retro_core_t secondary_core; +static struct retro_callbacks secondary_callbacks; +static char *secondary_library_path = NULL; +#endif +#endif /* Forward declarations */ static void retroarch_core_options_intl_init(const struct @@ -1314,6 +1962,72 @@ static void retroarch_deinit_core_options(void); static void retroarch_init_core_variables(const struct retro_variable *vars); static void rarch_init_core_options( const struct retro_core_option_definition *option_defs); +static bool secondary_core_create(void); +static int16_t input_state_get_last(unsigned port, + unsigned device, unsigned index, unsigned id); +static void video_driver_frame(const void *data, unsigned width, + unsigned height, size_t pitch); +static void retro_frame_null(const void *data, unsigned width, + unsigned height, size_t pitch); +static void retro_run_null(void); +static void retro_input_poll_null(void); + +static void uninit_libretro_symbols(struct retro_core_t *current_core); +static bool init_libretro_symbols(enum rarch_core_type type, + struct retro_core_t *current_core); + +static void ui_companion_driver_deinit(void); + +static bool audio_driver_stop(void); +static bool audio_driver_start(bool is_shutdown); + +static bool recording_init(void); +static bool recording_deinit(void); + +#ifdef HAVE_OVERLAY +static void retroarch_overlay_init(void); +static void retroarch_overlay_deinit(void); +#endif + +static void video_driver_gpu_record_deinit(void); +static retro_proc_address_t video_driver_get_proc_address(const char *sym); +static uintptr_t video_driver_get_current_framebuffer(void); +static bool video_driver_find_driver(void); + +static int16_t input_state(unsigned port, unsigned device, + unsigned idx, unsigned id); + +#ifdef HAVE_OVERLAY +static void input_overlay_set_alpha_mod(input_overlay_t *ol, float mod); +static void input_overlay_set_scale_factor(input_overlay_t *ol, float scale); +static void input_overlay_load_active(input_overlay_t *ol, float opacity); +static void input_overlay_auto_rotate(input_overlay_t *ol); +#endif + +static void bsv_movie_deinit(void); +static bool bsv_movie_init(void); +static bool bsv_movie_check(void); + +static void driver_uninit(int flags); +static void drivers_init(int flags); + +#if defined(HAVE_RUNAHEAD) +static void core_free_retro_game_info(struct retro_game_info *dest); +#endif +static bool core_load(unsigned poll_type_behavior); +static bool core_unload_game(void); + +static bool rarch_environment_cb(unsigned cmd, void *data); + +static bool driver_location_get_position(double *lat, double *lon, + double *horiz_accuracy, double *vert_accuracy); +static void driver_location_set_interval(unsigned interval_msecs, + unsigned interval_distance); +static void driver_location_stop(void); +static bool driver_location_start(void); +static void driver_camera_stop(void); +static bool driver_camera_start(void); + struct string_list *dir_list_new_special(const char *input_dir, enum dir_list_type type, const char *filter, @@ -2627,11 +3341,6 @@ void dir_check_defaults(void) } #ifdef HAVE_ACCESSIBILITY -/* Is text-to-speech accessibility turned on? */ -static bool accessibility_enabled = false; - -/* Accessibility */ - bool is_accessibility_enabled(void) { settings_t *settings = configuration_settings; @@ -2642,13 +3351,6 @@ bool is_accessibility_enabled(void) } #endif -#ifdef HAVE_GFX_WIDGETS -/* Status icons */ -static bool gfx_widgets_paused = false; -static bool gfx_widgets_fast_forward = false; -static bool gfx_widgets_rewinding = false; -#endif - bool gfx_widgets_ready(void) { #ifdef HAVE_GFX_WIDGETS @@ -2659,24 +3361,6 @@ bool gfx_widgets_ready(void) } #ifdef HAVE_MENU -/* MENU INPUT GLOBAL VARIABLES */ -static const char **menu_input_dialog_keyboard_buffer = {NULL}; -static unsigned menu_input_dialog_keyboard_type = 0; -static unsigned menu_input_dialog_keyboard_idx = 0; -static char menu_input_dialog_keyboard_label_setting[256] = {0}; -static char menu_input_dialog_keyboard_label[256] = {0}; -static bool menu_input_dialog_keyboard_display = false; -static unsigned char menu_keyboard_key_state[RETROK_LAST] = {0}; - -/* Since these are static/global, they are initialised to zero */ -static menu_input_pointer_hw_state_t menu_input_pointer_hw_state; -static menu_input_t menu_input_state; - -/* Is the menu driver still running? */ -static bool menu_driver_alive = false; -/* Are we binding a button inside the menu? */ -static bool menu_driver_is_binding = false; - #ifdef HAVE_LIBNX #define LIBNX_SWKBD_LIMIT 500 /* enforced by HOS */ extern u32 __nx_applet_type; @@ -2877,24 +3561,7 @@ void menu_driver_set_binding_state(bool on) #endif -/* RECORDING GLOBAL VARIABLES */ -static unsigned recording_width = 0; -static unsigned recording_height = 0; -static size_t recording_gpu_width = 0; -static size_t recording_gpu_height = 0; -static bool recording_enable = false; -static bool streaming_enable = false; - -static const record_driver_t *recording_driver = NULL; -static void *recording_data = NULL; - -static uint8_t *video_driver_record_gpu_buffer = NULL; - -/* MESSAGE QUEUE GLOBAL VARIABLES */ - #ifdef HAVE_THREADS -static slock_t *_runloop_msg_queue_lock = NULL; - #define runloop_msg_queue_lock() slock_lock(_runloop_msg_queue_lock) #define runloop_msg_queue_unlock() slock_unlock(_runloop_msg_queue_lock) #else @@ -2902,71 +3569,6 @@ static slock_t *_runloop_msg_queue_lock = NULL; #define runloop_msg_queue_unlock() #endif -/* CAMERA GLOBAL VARIABLES */ - -static struct retro_camera_callback camera_cb; -static const camera_driver_t *camera_driver = NULL; -static void *camera_data = NULL; -static bool camera_driver_active = false; - -/* MIDI GLOBAL VARIABLES */ - -#define MIDI_DRIVER_BUF_SIZE 4096 - -static midi_driver_t *midi_drv = &midi_null; -static void *midi_drv_data = NULL; -static struct string_list *midi_drv_inputs = NULL; -static struct string_list *midi_drv_outputs = NULL; -static bool midi_drv_input_enabled = false; -static bool midi_drv_output_enabled = false; -static uint8_t *midi_drv_input_buffer = NULL; -static uint8_t *midi_drv_output_buffer = NULL; -static midi_event_t midi_drv_input_event; -static midi_event_t midi_drv_output_event; -static bool midi_drv_output_pending = false; - -static const uint8_t midi_drv_ev_sizes[128] = -{ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 0, 2, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 -}; - - -/* UI COMPANION GLOBAL VARIABLES */ - -static bool main_ui_companion_is_on_foreground = false; -static const ui_companion_driver_t *ui_companion = NULL; -static void *ui_companion_data = NULL; - -#ifdef HAVE_QT -static void *ui_companion_qt_data = NULL; -static bool qt_is_inited = false; -#endif - -/* LOCATION GLOBAL VARIABLES */ -static const location_driver_t *location_driver = NULL; -static void *location_data = NULL; - -static bool location_driver_active = false; - -/* WIFI GLOBAL VARIABLES */ -static const wifi_driver_t *wifi_driver = NULL; -static void *wifi_data = NULL; -static bool wifi_driver_active = false; - -/* VIDEO GLOBAL VARIABLES */ - -static const video_display_server_t *current_display_server = &dispserv_null; -static void *current_display_server_data = NULL; -static enum rotation initial_screen_orientation = ORIENTATION_NORMAL; -static enum rotation current_screen_orientation = ORIENTATION_NORMAL; - #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) static void retroarch_set_runtime_shader_preset(const char *arg) { @@ -2984,10 +3586,6 @@ static void retroarch_unset_runtime_shader_preset(void) #endif } -#define MEASURE_FRAME_TIME_SAMPLES_COUNT (2 * 1024) - -#define TIME_TO_FPS(last_time, new_time, frames) ((1000000.0f * (frames)) / ((new_time) - (last_time))) - #ifdef HAVE_THREADS #define video_driver_is_threaded_internal() ((!video_driver_is_hw_context() && video_driver_threaded) ? true : false) #else @@ -3034,549 +3632,6 @@ static void retroarch_unset_runtime_shader_preset(void) #define video_driver_context_unlock() ((void)0) #endif -typedef struct video_pixel_scaler -{ - struct scaler_ctx *scaler; - void *scaler_out; -} video_pixel_scaler_t; - -typedef struct -{ - enum gfx_ctx_api api; - struct string_list *list; -} gfx_api_gpu_map; - -struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { - { "4:3", 1.3333f }, - { "16:9", 1.7778f }, - { "16:10", 1.6f }, - { "16:15", 16.0f / 15.0f }, - { "21:9", 21.0f / 9.0f }, - { "1:1", 1.0f }, - { "2:1", 2.0f }, - { "3:2", 1.5f }, - { "3:4", 0.75f }, - { "4:1", 4.0f }, - { "9:16", 0.5625f }, - { "5:4", 1.25f }, - { "6:5", 1.2f }, - { "7:9", 0.7777f }, - { "8:3", 2.6666f }, - { "8:7", 1.1428f }, - { "19:12", 1.5833f }, - { "19:14", 1.3571f }, - { "30:17", 1.7647f }, - { "32:9", 3.5555f }, - { "Config", 0.0f }, - { "Square pixel", 1.0f }, - { "Core provided", 1.0f }, - { "Custom", 0.0f } -}; - -static gfx_api_gpu_map gpu_map[] = { - { GFX_CTX_VULKAN_API, NULL }, - { GFX_CTX_DIRECT3D10_API, NULL }, - { GFX_CTX_DIRECT3D11_API, NULL }, - { GFX_CTX_DIRECT3D12_API, NULL } -}; - - -/* Opaque handles to currently running window. - * Used by e.g. input drivers which bind to a window. - * Drivers are responsible for setting these if an input driver - * could potentially make use of this. */ -static uintptr_t video_driver_display_userdata = 0; -static uintptr_t video_driver_display = 0; -static uintptr_t video_driver_window = 0; - -static rarch_softfilter_t *video_driver_state_filter = NULL; -static void *video_driver_state_buffer = NULL; -static unsigned video_driver_state_scale = 0; -static unsigned video_driver_state_out_bpp = 0; -static bool video_driver_state_out_rgb32 = false; -static bool video_driver_crt_switching_active = false; -static bool video_driver_crt_dynamic_super_width = false; - -static enum retro_pixel_format video_driver_pix_fmt = RETRO_PIXEL_FORMAT_0RGB1555; - -static const void *frame_cache_data = NULL; -static unsigned frame_cache_width = 0; -static unsigned frame_cache_height = 0; -static size_t frame_cache_pitch = 0; -static bool video_driver_threaded = false; - -static float video_driver_core_hz = 0.0f; -static float video_driver_aspect_ratio = 0.0f; -static unsigned video_driver_width = 0; -static unsigned video_driver_height = 0; - -static enum rarch_display_type video_driver_display_type = RARCH_DISPLAY_NONE; -static char video_driver_title_buf[64] = {0}; -static char video_driver_window_title[512] = {0}; -static bool video_driver_window_title_update = true; - -static retro_time_t video_driver_frame_time_samples[MEASURE_FRAME_TIME_SAMPLES_COUNT]; -static uint64_t video_driver_frame_time_count = 0; -static uint64_t video_driver_frame_count = 0; - -static void *video_driver_data = NULL; -static video_driver_t *current_video = NULL; - -/* Interface for "poking". */ -static const video_poke_interface_t *video_driver_poke = NULL; - -/* Used for 15-bit -> 16-bit conversions that take place before - * being passed to video driver. */ -static video_pixel_scaler_t *video_driver_scaler_ptr = NULL; - -static struct retro_hw_render_callback hw_render; - -static const struct -retro_hw_render_context_negotiation_interface * -hw_render_context_negotiation = NULL; - -/* 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 bool video_driver_use_rgba = 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; - -#ifdef HAVE_THREADS -static slock_t *display_lock = NULL; -static slock_t *context_lock = NULL; -#endif - -static gfx_ctx_driver_t current_video_context; - -static void *video_context_data = NULL; - -/** - * dynamic.c:dynamic_request_hw_context will try to set flag data when the context - * is in the middle of being rebuilt; in these cases we will save flag - * data and set this to true. - * When the context is reinit, it checks this, reads from - * deferred_flag_data and cleans it. - * - * TODO - Dirty hack, fix it better - */ -static bool deferred_video_context_driver_set_flags = false; -static gfx_ctx_flags_t deferred_flag_data = {0}; - -static bool video_started_fullscreen = false; - -static char video_driver_gpu_device_string[128] = {0}; -static char video_driver_gpu_api_version_string[128] = {0}; - -static struct retro_system_av_info video_driver_av_info; - -/* AUDIO GLOBAL VARIABLES */ -#define AUDIO_BUFFER_FREE_SAMPLES_COUNT (8 * 1024) - -#define MENU_SOUND_FORMATS "ogg|mod|xm|s3m|mp3|flac" - -/** - * db_to_gain: - * @db : Decibels. - * - * Converts decibels to voltage gain. - * - * Returns: voltage gain value. - **/ -#define db_to_gain(db) (powf(10.0f, (db) / 20.0f)) - - -#ifdef HAVE_AUDIOMIXER -static struct audio_mixer_stream -audio_mixer_streams[AUDIO_MIXER_MAX_SYSTEM_STREAMS] = {{0}}; - -static bool audio_driver_mixer_mute_enable = false; -static bool audio_mixer_active = false; -static float audio_driver_mixer_volume_gain = 0.0f; -#endif - -static size_t audio_driver_chunk_size = 0; -static size_t audio_driver_chunk_nonblock_size = 0; -static size_t audio_driver_chunk_block_size = 0; - -static size_t audio_driver_rewind_ptr = 0; -static size_t audio_driver_rewind_size = 0; - -static int16_t *audio_driver_rewind_buf = NULL; -static int16_t *audio_driver_output_samples_conv_buf = NULL; - -static unsigned audio_driver_free_samples_buf[AUDIO_BUFFER_FREE_SAMPLES_COUNT]; -static uint64_t audio_driver_free_samples_count = 0; - -static size_t audio_driver_buffer_size = 0; -static size_t audio_driver_data_ptr = 0; - -static bool audio_driver_control = false; -static bool audio_driver_mute_enable = false; -static bool audio_driver_use_float = false; -static bool audio_driver_active = false; - -static float audio_driver_rate_control_delta = 0.0f; -static float audio_driver_input = 0.0f; -static float audio_driver_volume_gain = 0.0f; - -static float *audio_driver_input_data = NULL; -static float *audio_driver_output_samples_buf = NULL; - -static double audio_source_ratio_original = 0.0f; -static double audio_source_ratio_current = 0.0f; - -static struct retro_audio_callback audio_callback = {0}; - -static retro_dsp_filter_t *audio_driver_dsp = NULL; -static struct string_list *audio_driver_devices_list = NULL; -static const retro_resampler_t *audio_driver_resampler = NULL; - -static void *audio_driver_resampler_data = NULL; -static const audio_driver_t *current_audio = NULL; -static void *audio_driver_context_audio_data = NULL; - -static bool audio_suspended = false; -static bool audio_is_threaded = false; - -/* RUNAHEAD GLOBAL VARIABLES */ - -typedef struct input_list_element_t -{ - unsigned port; - unsigned device; - unsigned index; - int16_t *state; - unsigned int state_size; -} input_list_element; - -#ifdef HAVE_RUNAHEAD -static size_t runahead_save_state_size = 0; - -static bool runahead_save_state_size_known = false; -static bool request_fast_savestate = false; -static bool hard_disable_audio = false; - -/* Save State List for Run Ahead */ -typedef void *(*constructor_t)(void); -typedef void (*destructor_t )(void*); - -typedef struct MyList_t -{ - void **data; - int capacity; - int size; - constructor_t constructor; - destructor_t destructor; -} MyList; - -static MyList *runahead_save_state_list = NULL; -static MyList *input_state_list = NULL; - -static bool input_is_dirty = false; - -typedef bool(*runahead_load_state_function)(const void*, size_t); - -static retro_input_state_t input_state_callback_original; -static function_t retro_reset_callback_original = NULL; -static runahead_load_state_function -retro_unserialize_callback_original = NULL; - -static function_t original_retro_deinit = NULL; -static function_t original_retro_unload = NULL; - -static bool runahead_video_driver_is_active = true; -static bool runahead_available = true; -static bool runahead_secondary_core_available = true; -static bool runahead_force_input_dirty = true; -static uint64_t runahead_last_frame_count = 0; -#endif - -#if defined(HAVE_NETWORKING) -/* NETWORKING GLOBAL VARIABLES */ - -static bool has_set_netplay_mode = false; -static bool has_set_netplay_ip_address = false; -static bool has_set_netplay_ip_port = false; -static bool has_set_netplay_stateless_mode = false; -static bool has_set_netplay_check_frames = false; -#endif - -/* INPUT REMOTE GLOBAL VARIABLES */ - -#define DEFAULT_NETWORK_GAMEPAD_PORT 55400 -#define UDP_FRAME_PACKETS 16 - -struct remote_message -{ - int port; - int device; - int index; - int id; - uint16_t state; -}; - -struct input_remote -{ - bool state[RARCH_BIND_LIST_END]; -#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) - int net_fd[MAX_USERS]; -#endif -}; - -typedef struct input_remote input_remote_t; - -typedef struct input_remote_state -{ - /* Left X, Left Y, Right X, Right Y */ - int16_t analog[4][MAX_USERS]; - /* This is a bitmask of (1 << key_bind_id). */ - uint64_t buttons[MAX_USERS]; -} input_remote_state_t; - -#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) -static input_remote_state_t remote_st_ptr; -#endif - -/* INPUT OVERLAY GLOBAL VARIABLES */ -#ifdef HAVE_OVERLAY - -#define OVERLAY_GET_KEY(state, key) (((state)->keys[(key) / 32] >> ((key) % 32)) & 1) -#define OVERLAY_SET_KEY(state, key) (state)->keys[(key) / 32] |= 1 << ((key) % 32) - -#define MAX_VISIBILITY 32 - -static enum overlay_visibility* visibility = NULL; - -typedef struct input_overlay_state -{ - /* Left X, Left Y, Right X, Right Y */ - int16_t analog[4]; - uint32_t keys[RETROK_LAST / 32 + 1]; - /* This is a bitmask of (1 << key_bind_id). */ - input_bits_t buttons; -} input_overlay_state_t; - -struct input_overlay -{ - enum overlay_status state; - - bool enable; - bool blocked; - bool alive; - - unsigned next_index; - - size_t index; - size_t size; - - struct overlay *overlays; - const struct overlay *active; - void *iface_data; - const video_overlay_interface_t *iface; - - input_overlay_state_t overlay_state; -}; - -static input_overlay_t *overlay_ptr = NULL; -#endif - -/* INPUT GLOBAL VARIABLES */ - -/* Input config. */ -struct input_bind_map -{ - bool valid; - - /* Meta binds get input as prefix, not input_playerN". - * 0 = libretro related. - * 1 = Common hotkey. - * 2 = Uncommon/obscure hotkey. - */ - uint8_t meta; - - const char *base; - enum msg_hash_enums desc; - uint8_t retro_key; -}; - -static pad_connection_listener_t *pad_connection_listener = NULL; - -static uint16_t input_config_vid[MAX_USERS]; -static uint16_t input_config_pid[MAX_USERS]; - -static char input_device_display_names[MAX_INPUT_DEVICES][64]; -static char input_device_config_names [MAX_INPUT_DEVICES][64]; -static char input_device_config_paths [MAX_INPUT_DEVICES][64]; -char input_device_names [MAX_INPUT_DEVICES][64]; - -uint64_t lifecycle_state; -struct retro_keybind input_config_binds[MAX_USERS][RARCH_BIND_LIST_END]; -struct retro_keybind input_autoconf_binds[MAX_USERS][RARCH_BIND_LIST_END]; -static const struct retro_keybind *libretro_input_binds[MAX_USERS]; - -#define DECLARE_BIND(x, bind, desc) { true, 0, #x, desc, bind } -#define DECLARE_META_BIND(level, x, bind, desc) { true, level, #x, desc, bind } - -const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = { - DECLARE_BIND(b, RETRO_DEVICE_ID_JOYPAD_B, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B), - DECLARE_BIND(y, RETRO_DEVICE_ID_JOYPAD_Y, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y), - DECLARE_BIND(select, RETRO_DEVICE_ID_JOYPAD_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT), - DECLARE_BIND(start, RETRO_DEVICE_ID_JOYPAD_START, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START), - DECLARE_BIND(up, RETRO_DEVICE_ID_JOYPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP), - DECLARE_BIND(down, RETRO_DEVICE_ID_JOYPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN), - DECLARE_BIND(left, RETRO_DEVICE_ID_JOYPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT), - DECLARE_BIND(right, RETRO_DEVICE_ID_JOYPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT), - DECLARE_BIND(a, RETRO_DEVICE_ID_JOYPAD_A, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A), - DECLARE_BIND(x, RETRO_DEVICE_ID_JOYPAD_X, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X), - DECLARE_BIND(l, RETRO_DEVICE_ID_JOYPAD_L, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L), - DECLARE_BIND(r, RETRO_DEVICE_ID_JOYPAD_R, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R), - DECLARE_BIND(l2, RETRO_DEVICE_ID_JOYPAD_L2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2), - DECLARE_BIND(r2, RETRO_DEVICE_ID_JOYPAD_R2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2), - DECLARE_BIND(l3, RETRO_DEVICE_ID_JOYPAD_L3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3), - DECLARE_BIND(r3, RETRO_DEVICE_ID_JOYPAD_R3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3), - DECLARE_BIND(l_x_plus, RARCH_ANALOG_LEFT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS), - DECLARE_BIND(l_x_minus, RARCH_ANALOG_LEFT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS), - DECLARE_BIND(l_y_plus, RARCH_ANALOG_LEFT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS), - DECLARE_BIND(l_y_minus, RARCH_ANALOG_LEFT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS), - DECLARE_BIND(r_x_plus, RARCH_ANALOG_RIGHT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS), - DECLARE_BIND(r_x_minus, RARCH_ANALOG_RIGHT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS), - DECLARE_BIND(r_y_plus, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS), - DECLARE_BIND(r_y_minus, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS), - - DECLARE_BIND( gun_trigger, RARCH_LIGHTGUN_TRIGGER, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER ), - DECLARE_BIND( gun_offscreen_shot, RARCH_LIGHTGUN_RELOAD, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD ), - DECLARE_BIND( gun_aux_a, RARCH_LIGHTGUN_AUX_A, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A ), - DECLARE_BIND( gun_aux_b, RARCH_LIGHTGUN_AUX_B, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B ), - DECLARE_BIND( gun_aux_c, RARCH_LIGHTGUN_AUX_C, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C ), - DECLARE_BIND( gun_start, RARCH_LIGHTGUN_START, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START ), - DECLARE_BIND( gun_select, RARCH_LIGHTGUN_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT ), - DECLARE_BIND( gun_dpad_up, RARCH_LIGHTGUN_DPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP ), - DECLARE_BIND( gun_dpad_down, RARCH_LIGHTGUN_DPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN ), - DECLARE_BIND( gun_dpad_left, RARCH_LIGHTGUN_DPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT ), - DECLARE_BIND( gun_dpad_right, RARCH_LIGHTGUN_DPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT ), - - DECLARE_BIND(turbo, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE), - - DECLARE_META_BIND(1, toggle_fast_forward, RARCH_FAST_FORWARD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY), - DECLARE_META_BIND(2, hold_fast_forward, RARCH_FAST_FORWARD_HOLD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_HOLD_KEY), - DECLARE_META_BIND(1, toggle_slowmotion, RARCH_SLOWMOTION_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION_KEY), - DECLARE_META_BIND(2, hold_slowmotion, RARCH_SLOWMOTION_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION_HOLD_KEY), - DECLARE_META_BIND(1, load_state, RARCH_LOAD_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_LOAD_STATE_KEY), - DECLARE_META_BIND(1, save_state, RARCH_SAVE_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SAVE_STATE_KEY), - DECLARE_META_BIND(2, toggle_fullscreen, RARCH_FULLSCREEN_TOGGLE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY), -#ifdef HAVE_LAKKA - DECLARE_META_BIND(2, exit_emulator, RARCH_QUIT_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_RESTART_KEY), -#else - DECLARE_META_BIND(2, exit_emulator, RARCH_QUIT_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_QUIT_KEY), -#endif - DECLARE_META_BIND(2, state_slot_increase, RARCH_STATE_SLOT_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_PLUS), - DECLARE_META_BIND(2, state_slot_decrease, RARCH_STATE_SLOT_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_MINUS), - DECLARE_META_BIND(1, rewind, RARCH_REWIND, MENU_ENUM_LABEL_VALUE_INPUT_META_REWIND), - DECLARE_META_BIND(2, movie_record_toggle, RARCH_BSV_RECORD_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_BSV_RECORD_TOGGLE), - DECLARE_META_BIND(2, pause_toggle, RARCH_PAUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_PAUSE_TOGGLE), - DECLARE_META_BIND(2, frame_advance, RARCH_FRAMEADVANCE, MENU_ENUM_LABEL_VALUE_INPUT_META_FRAMEADVANCE), - DECLARE_META_BIND(2, reset, RARCH_RESET, MENU_ENUM_LABEL_VALUE_INPUT_META_RESET), - DECLARE_META_BIND(2, shader_next, RARCH_SHADER_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_NEXT), - DECLARE_META_BIND(2, shader_prev, RARCH_SHADER_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_PREV), - DECLARE_META_BIND(2, cheat_index_plus, RARCH_CHEAT_INDEX_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_PLUS), - DECLARE_META_BIND(2, cheat_index_minus, RARCH_CHEAT_INDEX_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_MINUS), - DECLARE_META_BIND(2, cheat_toggle, RARCH_CHEAT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_TOGGLE), - DECLARE_META_BIND(2, screenshot, RARCH_SCREENSHOT, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT), - DECLARE_META_BIND(2, audio_mute, RARCH_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE), - DECLARE_META_BIND(2, osk_toggle, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK), - DECLARE_META_BIND(2, fps_toggle, RARCH_FPS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE), - DECLARE_META_BIND(2, send_debug_info, RARCH_SEND_DEBUG_INFO, MENU_ENUM_LABEL_VALUE_INPUT_META_SEND_DEBUG_INFO), - DECLARE_META_BIND(2, netplay_host_toggle, RARCH_NETPLAY_HOST_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_HOST_TOGGLE), - DECLARE_META_BIND(2, netplay_game_watch, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH), - DECLARE_META_BIND(2, enable_hotkey, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY), - DECLARE_META_BIND(2, volume_up, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP), - DECLARE_META_BIND(2, volume_down, RARCH_VOLUME_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_DOWN), - DECLARE_META_BIND(2, overlay_next, RARCH_OVERLAY_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_OVERLAY_NEXT), - DECLARE_META_BIND(2, disk_eject_toggle, RARCH_DISK_EJECT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_EJECT_TOGGLE), - DECLARE_META_BIND(2, disk_next, RARCH_DISK_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_NEXT), - DECLARE_META_BIND(2, disk_prev, RARCH_DISK_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_PREV), - DECLARE_META_BIND(2, grab_mouse_toggle, RARCH_GRAB_MOUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GRAB_MOUSE_TOGGLE), - DECLARE_META_BIND(2, game_focus_toggle, RARCH_GAME_FOCUS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GAME_FOCUS_TOGGLE), - DECLARE_META_BIND(2, desktop_menu_toggle, RARCH_UI_COMPANION_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_UI_COMPANION_TOGGLE), -#ifdef HAVE_MENU - DECLARE_META_BIND(1, menu_toggle, RARCH_MENU_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MENU_TOGGLE), -#endif - DECLARE_META_BIND(2, recording_toggle, RARCH_RECORDING_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_RECORDING_TOGGLE), - DECLARE_META_BIND(2, streaming_toggle, RARCH_STREAMING_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_STREAMING_TOGGLE), - DECLARE_META_BIND(2, ai_service, RARCH_AI_SERVICE, MENU_ENUM_LABEL_VALUE_INPUT_META_AI_SERVICE), -}; - -typedef struct turbo_buttons turbo_buttons_t; - -/* Turbo support. */ -struct turbo_buttons -{ - bool frame_enable[MAX_USERS]; - uint16_t enable[MAX_USERS]; - bool mode1_enable[MAX_USERS]; - int32_t turbo_pressed[MAX_USERS]; - unsigned count; -}; - -struct input_keyboard_line -{ - char *buffer; - size_t ptr; - size_t size; - - /** Line complete callback. - * Calls back after return is - * pressed with the completed line. - * Line can be NULL. - **/ - input_keyboard_line_complete_t cb; - void *userdata; -}; - -static bool input_driver_keyboard_linefeed_enable = false; -static input_keyboard_line_t *g_keyboard_line = NULL; - -static void *g_keyboard_press_data = NULL; - -static unsigned osk_last_codepoint = 0; -static unsigned osk_last_codepoint_len = 0; - -static input_keyboard_press_t g_keyboard_press_cb; - -static turbo_buttons_t input_driver_turbo_btns; -#ifdef HAVE_COMMAND -static command_t *input_driver_command = NULL; -#endif -#ifdef HAVE_NETWORKGAMEPAD -static input_remote_t *input_driver_remote = NULL; -#endif -static input_mapper_t *input_driver_mapper = NULL; -static 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_nonblock_state = false; -static unsigned input_driver_flushing_input = 0; -static float input_driver_axis_threshold = 0.0f; -static unsigned input_driver_max_users = 0; - -#ifdef HAVE_HID -static const void *hid_data = NULL; -#endif - #ifdef HAVE_THREADS #define video_driver_get_ptr_internal(force) ((video_driver_is_threaded_internal() && !force) ? video_thread_get_ptr(NULL) : video_driver_data) #else @@ -3584,9 +3639,6 @@ static const void *hid_data = NULL; #endif #if defined(HAVE_RUNAHEAD) -static enum rarch_core_type last_core_type; -static retro_ctx_load_content_info_t *load_content_info; - #if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB) static char *strcpy_alloc(const char *src) { @@ -3609,85 +3661,9 @@ static char *strcpy_alloc_force(const char *src) return result; } -/* Forward declarations */ -static bool secondary_core_create(void); -static int16_t input_state_get_last(unsigned port, - unsigned device, unsigned index, unsigned id); - -/* RUNAHEAD - SECONDARY CORE GLOBAL VARIABLES */ -static int port_map[16]; - -static dylib_t secondary_module; -static struct retro_core_t secondary_core; -static struct retro_callbacks secondary_callbacks; -static char *secondary_library_path = NULL; #endif #endif -/* Forward declarations */ -static void video_driver_frame(const void *data, unsigned width, - unsigned height, size_t pitch); -static void retro_frame_null(const void *data, unsigned width, - unsigned height, size_t pitch); -static void retro_run_null(void); -static void retro_input_poll_null(void); - -static void uninit_libretro_symbols(struct retro_core_t *current_core); -static bool init_libretro_symbols(enum rarch_core_type type, - struct retro_core_t *current_core); - -static void ui_companion_driver_deinit(void); - -static bool audio_driver_stop(void); -static bool audio_driver_start(bool is_shutdown); - -static bool recording_init(void); -static bool recording_deinit(void); - -#ifdef HAVE_OVERLAY -static void retroarch_overlay_init(void); -static void retroarch_overlay_deinit(void); -#endif - -static void video_driver_gpu_record_deinit(void); -static retro_proc_address_t video_driver_get_proc_address(const char *sym); -static uintptr_t video_driver_get_current_framebuffer(void); -static bool video_driver_find_driver(void); - -static int16_t input_state(unsigned port, unsigned device, - unsigned idx, unsigned id); - -#ifdef HAVE_OVERLAY -static void input_overlay_set_alpha_mod(input_overlay_t *ol, float mod); -static void input_overlay_set_scale_factor(input_overlay_t *ol, float scale); -static void input_overlay_load_active(input_overlay_t *ol, float opacity); -static void input_overlay_auto_rotate(input_overlay_t *ol); -#endif - -static void bsv_movie_deinit(void); -static bool bsv_movie_init(void); -static bool bsv_movie_check(void); - -static void driver_uninit(int flags); -static void drivers_init(int flags); - -#if defined(HAVE_RUNAHEAD) -static void core_free_retro_game_info(struct retro_game_info *dest); -#endif -static bool core_load(unsigned poll_type_behavior); -static bool core_unload_game(void); - -static bool rarch_environment_cb(unsigned cmd, void *data); - -static bool driver_location_get_position(double *lat, double *lon, - double *horiz_accuracy, double *vert_accuracy); -static void driver_location_set_interval(unsigned interval_msecs, - unsigned interval_distance); -static void driver_location_stop(void); -static bool driver_location_start(void); -static void driver_camera_stop(void); -static bool driver_camera_start(void); - /* GLOBAL POINTER GETTERS */ #define video_driver_get_hw_context_internal() (&hw_render) From 7b5b14b0a7514413ae80ab71d1e13be2c50408d1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 03:38:16 +0200 Subject: [PATCH 128/192] More reorganization of globals, enums, defines --- retroarch.c | 336 ++++++++++++++++++++++++++-------------------------- 1 file changed, 169 insertions(+), 167 deletions(-) diff --git a/retroarch.c b/retroarch.c index f9c9a6ca17..576867bdc1 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1071,6 +1071,8 @@ static const camera_driver_t *camera_drivers[] = { #define DECLARE_BIND(x, bind, desc) { true, 0, #x, desc, bind } #define DECLARE_META_BIND(level, x, bind, desc) { true, level, #x, desc, bind } +#define DEFAULT_NETWORK_CMD_PORT 55355 +#define STDIN_BUF_SIZE 4096 /* Descriptive names for options without short variant. * @@ -1118,6 +1120,12 @@ enum rarch_movie_type RARCH_MOVIE_RECORD }; +enum cmd_source_t +{ + CMD_NONE = 0, + CMD_STDIN, + CMD_NETWORK +}; typedef struct runloop_ctx_msg_info { @@ -1179,6 +1187,160 @@ typedef struct struct string_list *list; } gfx_api_gpu_map; +struct remote_message +{ + int port; + int device; + int index; + int id; + uint16_t state; +}; + +struct input_remote +{ + bool state[RARCH_BIND_LIST_END]; +#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) + int net_fd[MAX_USERS]; +#endif +}; + +typedef struct bsv_movie bsv_movie_t; + +typedef struct input_remote input_remote_t; + +typedef struct input_remote_state +{ + /* Left X, Left Y, Right X, Right Y */ + int16_t analog[4][MAX_USERS]; + /* This is a bitmask of (1 << key_bind_id). */ + uint64_t buttons[MAX_USERS]; +} input_remote_state_t; + +typedef struct input_list_element_t +{ + unsigned port; + unsigned device; + unsigned index; + int16_t *state; + unsigned int state_size; +} input_list_element; + +typedef void *(*constructor_t)(void); +typedef void (*destructor_t )(void*); + +typedef struct MyList_t +{ + void **data; + int capacity; + int size; + constructor_t constructor; + destructor_t destructor; +} MyList; + +#ifdef HAVE_OVERLAY +typedef struct input_overlay_state +{ + /* Left X, Left Y, Right X, Right Y */ + int16_t analog[4]; + uint32_t keys[RETROK_LAST / 32 + 1]; + /* This is a bitmask of (1 << key_bind_id). */ + input_bits_t buttons; +} input_overlay_state_t; + +struct input_overlay +{ + enum overlay_status state; + + bool enable; + bool blocked; + bool alive; + + unsigned next_index; + + size_t index; + size_t size; + + struct overlay *overlays; + const struct overlay *active; + void *iface_data; + const video_overlay_interface_t *iface; + + input_overlay_state_t overlay_state; +}; +#endif + +struct cmd_map +{ + const char *str; + unsigned id; +}; + +#if defined(HAVE_COMMAND) +struct cmd_action_map +{ + const char *str; + bool (*action)(const char *arg); + const char *arg_desc; +}; +#endif + +struct command +{ + bool stdin_enable; + bool state[RARCH_BIND_LIST_END]; +#ifdef HAVE_STDIN_CMD + char stdin_buf[STDIN_BUF_SIZE]; + size_t stdin_buf_ptr; +#endif +#ifdef HAVE_NETWORK_CMD + int net_fd; +#endif +}; + +/* Input config. */ +struct input_bind_map +{ + bool valid; + + /* Meta binds get input as prefix, not input_playerN". + * 0 = libretro related. + * 1 = Common hotkey. + * 2 = Uncommon/obscure hotkey. + */ + uint8_t meta; + + const char *base; + enum msg_hash_enums desc; + uint8_t retro_key; +}; + +typedef struct turbo_buttons turbo_buttons_t; + +/* Turbo support. */ +struct turbo_buttons +{ + bool frame_enable[MAX_USERS]; + uint16_t enable[MAX_USERS]; + bool mode1_enable[MAX_USERS]; + int32_t turbo_pressed[MAX_USERS]; + unsigned count; +}; + +struct input_keyboard_line +{ + char *buffer; + size_t ptr; + size_t size; + + /** Line complete callback. + * Calls back after return is + * pressed with the completed line. + * Line can be NULL. + **/ + input_keyboard_line_complete_t cb; + void *userdata; +}; + static struct global g_extern; static struct retro_callbacks retro_ctx; @@ -1410,8 +1572,6 @@ static void *current_display_server_data = NULL; static enum rotation initial_screen_orientation = ORIENTATION_NORMAL; static enum rotation current_screen_orientation = ORIENTATION_NORMAL; -typedef struct bsv_movie bsv_movie_t; - static bsv_movie_t *bsv_movie_state_handle = NULL; static struct bsv_state bsv_movie_state; @@ -1603,15 +1763,6 @@ static void *audio_driver_context_audio_data = NULL; static bool audio_suspended = false; static bool audio_is_threaded = false; -typedef struct input_list_element_t -{ - unsigned port; - unsigned device; - unsigned index; - int16_t *state; - unsigned int state_size; -} input_list_element; - #ifdef HAVE_RUNAHEAD static size_t runahead_save_state_size = 0; @@ -1619,19 +1770,6 @@ static bool runahead_save_state_size_known = false; static bool request_fast_savestate = false; static bool hard_disable_audio = false; -/* Save State List for Run Ahead */ -typedef void *(*constructor_t)(void); -typedef void (*destructor_t )(void*); - -typedef struct MyList_t -{ - void **data; - int capacity; - int size; - constructor_t constructor; - destructor_t destructor; -} MyList; - static MyList *runahead_save_state_list = NULL; static MyList *input_state_list = NULL; @@ -1662,32 +1800,15 @@ static bool has_set_netplay_stateless_mode = false; static bool has_set_netplay_check_frames = false; #endif -struct remote_message -{ - int port; - int device; - int index; - int id; - uint16_t state; -}; - -struct input_remote -{ - bool state[RARCH_BIND_LIST_END]; -#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) - int net_fd[MAX_USERS]; +#if defined(HAVE_COMMAND) +static enum cmd_source_t lastcmd_source; +#ifdef HAVE_NETWORK_CMD +static int lastcmd_net_fd; +static struct sockaddr_storage lastcmd_net_source; +static socklen_t lastcmd_net_source_len; +#endif #endif -}; -typedef struct input_remote input_remote_t; - -typedef struct input_remote_state -{ - /* Left X, Left Y, Right X, Right Y */ - int16_t analog[4][MAX_USERS]; - /* This is a bitmask of (1 << key_bind_id). */ - uint64_t buttons[MAX_USERS]; -} input_remote_state_t; #if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) static input_remote_state_t remote_st_ptr; @@ -1696,56 +1817,9 @@ static input_remote_state_t remote_st_ptr; #ifdef HAVE_OVERLAY static enum overlay_visibility* visibility = NULL; -typedef struct input_overlay_state -{ - /* Left X, Left Y, Right X, Right Y */ - int16_t analog[4]; - uint32_t keys[RETROK_LAST / 32 + 1]; - /* This is a bitmask of (1 << key_bind_id). */ - input_bits_t buttons; -} input_overlay_state_t; - -struct input_overlay -{ - enum overlay_status state; - - bool enable; - bool blocked; - bool alive; - - unsigned next_index; - - size_t index; - size_t size; - - struct overlay *overlays; - const struct overlay *active; - void *iface_data; - const video_overlay_interface_t *iface; - - input_overlay_state_t overlay_state; -}; - static input_overlay_t *overlay_ptr = NULL; #endif -/* Input config. */ -struct input_bind_map -{ - bool valid; - - /* Meta binds get input as prefix, not input_playerN". - * 0 = libretro related. - * 1 = Common hotkey. - * 2 = Uncommon/obscure hotkey. - */ - uint8_t meta; - - const char *base; - enum msg_hash_enums desc; - uint8_t retro_key; -}; - static pad_connection_listener_t *pad_connection_listener = NULL; static uint16_t input_config_vid[MAX_USERS]; @@ -1850,33 +1924,6 @@ const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = { DECLARE_META_BIND(2, ai_service, RARCH_AI_SERVICE, MENU_ENUM_LABEL_VALUE_INPUT_META_AI_SERVICE), }; -typedef struct turbo_buttons turbo_buttons_t; - -/* Turbo support. */ -struct turbo_buttons -{ - bool frame_enable[MAX_USERS]; - uint16_t enable[MAX_USERS]; - bool mode1_enable[MAX_USERS]; - int32_t turbo_pressed[MAX_USERS]; - unsigned count; -}; - -struct input_keyboard_line -{ - char *buffer; - size_t ptr; - size_t size; - - /** Line complete callback. - * Calls back after return is - * pressed with the completed line. - * Line can be NULL. - **/ - input_keyboard_line_complete_t cb; - void *userdata; -}; - static bool input_driver_keyboard_linefeed_enable = false; static input_keyboard_line_t *g_keyboard_line = NULL; @@ -3746,52 +3793,7 @@ static void retroarch_autosave_deinit(void) /* COMMAND */ -#define DEFAULT_NETWORK_CMD_PORT 55355 -#define STDIN_BUF_SIZE 4096 - -enum cmd_source_t -{ - CMD_NONE = 0, - CMD_STDIN, - CMD_NETWORK -}; - -struct cmd_map -{ - const char *str; - unsigned id; -}; - -#ifdef HAVE_COMMAND -struct cmd_action_map -{ - const char *str; - bool (*action)(const char *arg); - const char *arg_desc; -}; -#endif - -struct command -{ - bool stdin_enable; - bool state[RARCH_BIND_LIST_END]; -#ifdef HAVE_STDIN_CMD - char stdin_buf[STDIN_BUF_SIZE]; - size_t stdin_buf_ptr; -#endif -#ifdef HAVE_NETWORK_CMD - int net_fd; -#endif -}; - #if defined(HAVE_COMMAND) -static enum cmd_source_t lastcmd_source; -#ifdef HAVE_NETWORK_CMD -static int lastcmd_net_fd; -static struct sockaddr_storage lastcmd_net_source; -static socklen_t lastcmd_net_source_len; -#endif - #if (defined(HAVE_STDIN_CMD) || defined(HAVE_NETWORK_CMD)) static void command_reply(const char * data, size_t len) { From cc2d70f0442eb605cec15e0af0c160cf7ac81e47 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 03:47:14 +0200 Subject: [PATCH 129/192] (retroarch.c) Turn some AI functions static --- retroarch.c | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/retroarch.c b/retroarch.c index 576867bdc1..32faf7470f 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1969,6 +1969,10 @@ static char *secondary_library_path = NULL; #endif #endif +#ifdef HAVE_TRANSLATE +static int g_ai_service_auto = 0; +#endif + /* Forward declarations */ static void retroarch_core_options_intl_init(const struct retro_core_options_intl *core_options_intl); @@ -4085,7 +4089,6 @@ static bool command_set_shader(const char *arg) } #if defined(HAVE_COMMAND) - #if defined(HAVE_CHEEVOS) #define SMY_CMD_STR "READ_CORE_RAM" static bool command_read_ram(const char *arg) @@ -4467,41 +4470,37 @@ error: /* TRANSLATION */ #ifdef HAVE_TRANSLATE -static int g_ai_service_auto = 0; - -int get_ai_service_auto(void) +static int get_ai_service_auto(void) { return g_ai_service_auto; } -bool set_ai_service_auto(int num) +static bool set_ai_service_auto(int num) { g_ai_service_auto = num; return true; } -bool task_auto_translate_callback() +static bool task_auto_translate_callback(void) { bool was_paused = runloop_paused; command_event(CMD_EVENT_AI_SERVICE_CALL, &was_paused); return true; } - -/* Doesn't currently work. Fix this. */ -bool is_ai_service_speech_running(void) +/* TODO/FIXME - Doesn't currently work. Fix this. */ +static bool is_ai_service_speech_running(void) { #ifdef HAVE_AUDIOMIXER enum audio_mixer_state res = audio_driver_mixer_get_stream_state(10); - if (res == AUDIO_STREAM_STATE_NONE || res == AUDIO_STREAM_STATE_STOPPED) - return false; - return true; -#else - return false; + bool ret = (res == AUDIO_STREAM_STATE_NONE) || (res == AUDIO_STREAM_STATE_STOPPED); + if (!ret) + return true; #endif + return false; } -bool ai_service_speech_stop(void) +static bool ai_service_speech_stop(void) { #ifdef HAVE_AUDIOMIXER audio_driver_mixer_stop_stream(10); @@ -4510,7 +4509,6 @@ bool ai_service_speech_stop(void) return false; } - static void task_auto_translate_handler(retro_task_t *task) { int* mode_ptr = (int*)task->user_data; @@ -4545,10 +4543,10 @@ task_finished: free(task->user_data); } -bool call_auto_translate_task(bool* was_paused) +static bool call_auto_translate_task(bool* was_paused) { - settings_t *settings = configuration_settings; - int ai_service_mode = settings->uints.ai_service_mode; + settings_t *settings = configuration_settings; + int ai_service_mode = settings->uints.ai_service_mode; /*Image Mode*/ if (ai_service_mode == 0) @@ -4576,8 +4574,6 @@ bool call_auto_translate_task(bool* was_paused) return true; } - - static void handle_translation_cb( retro_task_t *task, void *task_data, void *user_data, const char *error) { @@ -5095,10 +5091,8 @@ finish: if (string_is_equal(auto_string, "auto")) { - if (get_ai_service_auto() != 0 && settings->bools.ai_service_pause == false) - { + if (get_ai_service_auto() != 0 && !settings->bools.ai_service_pause) call_auto_translate_task(&was_paused); - } } if (auto_string) free(auto_string); @@ -8274,7 +8268,7 @@ bool command_event(enum event_command cmd, void *data) if (data!=NULL) paused = *((bool*)data); - if (get_ai_service_auto() == 0 && settings->bools.ai_service_pause == false) + if (get_ai_service_auto() == 0 && !settings->bools.ai_service_pause) set_ai_service_auto(1); if (get_ai_service_auto() != 2) RARCH_LOG("AI Service Called...\n"); From 24dd7409bcafdf8cca6060565f27284042839a59 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 03:58:36 +0200 Subject: [PATCH 130/192] Move more global variables and forward declarations up top --- retroarch.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/retroarch.c b/retroarch.c index 32faf7470f..2bce56b866 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1973,6 +1973,8 @@ static char *secondary_library_path = NULL; static int g_ai_service_auto = 0; #endif +static unsigned gamepad_input_override = 0; + /* Forward declarations */ static void retroarch_core_options_intl_init(const struct retro_core_options_intl *core_options_intl); @@ -2040,6 +2042,15 @@ static void retroarch_overlay_init(void); static void retroarch_overlay_deinit(void); #endif +#ifdef HAVE_AUDIOMIXER +static void audio_mixer_play_stop_sequential_cb( + audio_mixer_sound_t *sound, unsigned reason); +static void audio_mixer_play_stop_cb( + audio_mixer_sound_t *sound, unsigned reason); +static void audio_mixer_menu_stop_cb( + audio_mixer_sound_t *sound, unsigned reason); +#endif + static void video_driver_gpu_record_deinit(void); static retro_proc_address_t video_driver_get_proc_address(const char *sym); static uintptr_t video_driver_get_current_framebuffer(void); @@ -19046,15 +19057,6 @@ size_t midi_driver_get_event_size(uint8_t status) /* AUDIO */ -#ifdef HAVE_AUDIOMIXER -static void audio_mixer_play_stop_sequential_cb( - audio_mixer_sound_t *sound, unsigned reason); -static void audio_mixer_play_stop_cb( - audio_mixer_sound_t *sound, unsigned reason); -static void audio_mixer_menu_stop_cb( - audio_mixer_sound_t *sound, unsigned reason); -#endif - static enum resampler_quality audio_driver_get_resampler_quality(void) { settings_t *settings = configuration_settings; @@ -24596,7 +24598,6 @@ static void mylist_destroy(MyList **list_p) } } - static void mylist_create(MyList **list_p, int initial_capacity, constructor_t constructor, destructor_t destructor) { @@ -29676,9 +29677,6 @@ static bool accessibility_startup_message(void) return true; } - -static unsigned gamepad_input_override = 0; - unsigned get_gamepad_input_override(void) { return gamepad_input_override; From a188826a10dc9b8cfea02c44a0dc34378d4b78a0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 04:02:43 +0200 Subject: [PATCH 131/192] Cleanups --- retroarch.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/retroarch.c b/retroarch.c index 2bce56b866..ccc1b3a9b0 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2040,6 +2040,10 @@ static bool recording_deinit(void); #ifdef HAVE_OVERLAY static void retroarch_overlay_init(void); static void retroarch_overlay_deinit(void); +static void input_overlay_set_alpha_mod(input_overlay_t *ol, float mod); +static void input_overlay_set_scale_factor(input_overlay_t *ol, float scale); +static void input_overlay_load_active(input_overlay_t *ol, float opacity); +static void input_overlay_auto_rotate(input_overlay_t *ol); #endif #ifdef HAVE_AUDIOMIXER @@ -2059,13 +2063,6 @@ static bool video_driver_find_driver(void); static int16_t input_state(unsigned port, unsigned device, unsigned idx, unsigned id); -#ifdef HAVE_OVERLAY -static void input_overlay_set_alpha_mod(input_overlay_t *ol, float mod); -static void input_overlay_set_scale_factor(input_overlay_t *ol, float scale); -static void input_overlay_load_active(input_overlay_t *ol, float opacity); -static void input_overlay_auto_rotate(input_overlay_t *ol); -#endif - static void bsv_movie_deinit(void); static bool bsv_movie_init(void); static bool bsv_movie_check(void); From 51c10646092c867c7ba921ae3bd5b383e3e71da4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 04:18:57 +0200 Subject: [PATCH 132/192] retroarch_validate_per_core_options - cut down on code duplication --- retroarch.c | 70 ++++++++++++++++++----------------------------------- 1 file changed, 23 insertions(+), 47 deletions(-) diff --git a/retroarch.c b/retroarch.c index ccc1b3a9b0..ab546d8054 100644 --- a/retroarch.c +++ b/retroarch.c @@ -26149,15 +26149,12 @@ static void retroarch_parse_input_and_config(int argc, char *argv[]) dir_set(RARCH_DIR_SAVESTATE, global->name.savestate); } -static bool retroarch_validate_game_options(char *s, size_t len, bool mkdir) +static bool retroarch_validate_per_core_options(char *s, + size_t len, bool mkdir, + const char *core_name, const char *game_name) { char *config_directory = NULL; size_t str_size = PATH_MAX_LENGTH * sizeof(char); - const char *core_name = runloop_system.info.library_name; - const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME)); - - if (string_is_empty(core_name) || string_is_empty(game_name)) - return false; config_directory = (char*)malloc(str_size); config_directory[0] = '\0'; @@ -26165,7 +26162,6 @@ static bool retroarch_validate_game_options(char *s, size_t len, bool mkdir) fill_pathname_application_special(config_directory, str_size, APPLICATION_SPECIAL_DIRECTORY_CONFIG); - /* Concatenate strings into full paths for game_path */ fill_pathname_join_special_ext(s, config_directory, core_name, game_name, ".opt", len); @@ -26173,59 +26169,32 @@ static bool retroarch_validate_game_options(char *s, size_t len, bool mkdir) /* No need to make a directory if file already exists... */ if (mkdir && !path_is_valid(s)) { - char *core_path = (char*)malloc(str_size); - core_path[0] = '\0'; + char *new_path = (char*)malloc(str_size); + new_path[0] = '\0'; - fill_pathname_join(core_path, + fill_pathname_join(new_path, config_directory, core_name, str_size); - if (!path_is_directory(core_path)) - path_mkdir(core_path); + if (!path_is_directory(new_path)) + path_mkdir(new_path); - free(core_path); + free(new_path); } free(config_directory); return true; } -static bool retroarch_validate_per_core_options(char *s, size_t len, bool mkdir) +static bool retroarch_validate_game_options(char *s, size_t len, bool mkdir) { - char *config_directory = NULL; - size_t str_size = PATH_MAX_LENGTH * sizeof(char); const char *core_name = runloop_system.info.library_name; + const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME)); - if (string_is_empty(core_name)) + if (string_is_empty(core_name) || string_is_empty(game_name)) return false; - config_directory = (char*)malloc(str_size); - config_directory[0] = '\0'; - - fill_pathname_application_special(config_directory, - str_size, APPLICATION_SPECIAL_DIRECTORY_CONFIG); - - /* Concatenate strings into full paths for core options path */ - fill_pathname_join_special_ext(s, - config_directory, core_name, core_name, - ".opt", len); - - /* No need to make a directory if file already exists... */ - if (mkdir && !path_is_valid(s)) - { - char *core_options_dir = (char*)malloc(str_size); - core_options_dir[0] = '\0'; - - fill_pathname_join(core_options_dir, - config_directory, core_name, str_size); - - if (!path_is_directory(core_options_dir)) - path_mkdir(core_options_dir); - - free(core_options_dir); - } - - free(config_directory); - return true; + return retroarch_validate_per_core_options(s, len, mkdir, + core_name, game_name); } /* Validates CPU features for given processor architecture. @@ -26799,12 +26768,19 @@ static void rarch_init_core_options_path( if (per_core_options) { + const char *core_name = runloop_system.info.library_name; /* Get core-specific options path * > if retroarch_validate_per_core_options() returns * false, then per-core options are disabled (due to * unknown system errors...) */ - per_core_options = retroarch_validate_per_core_options( - per_core_options_path, sizeof(per_core_options_path), true); + + if (string_is_empty(core_name)) + per_core_options = false; + else + per_core_options = retroarch_validate_per_core_options( + per_core_options_path, sizeof(per_core_options_path), true, + core_name, core_name + ); /* If we can use per-core options, check whether an options * file already exists */ From 1e21bf5074a93577cb4cbd71e0387c7d3b3b1c1e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 04:39:27 +0200 Subject: [PATCH 133/192] Move defines to top --- retroarch.c | 133 +++++++++++++++++++++++++++------------------------- 1 file changed, 68 insertions(+), 65 deletions(-) diff --git a/retroarch.c b/retroarch.c index ab546d8054..25634e36e0 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1074,6 +1074,68 @@ static const camera_driver_t *camera_drivers[] = { #define DEFAULT_NETWORK_CMD_PORT 55355 #define STDIN_BUF_SIZE 4096 +#ifdef HAVE_THREADS +#define video_driver_is_threaded_internal() ((!video_driver_is_hw_context() && video_driver_threaded) ? true : false) +#else +#define video_driver_is_threaded_internal() (false) +#endif + +#ifdef HAVE_THREADS +#define video_driver_lock() \ + if (display_lock) \ + slock_lock(display_lock) + +#define video_driver_unlock() \ + if (display_lock) \ + slock_unlock(display_lock) + +#define video_driver_context_lock() \ + if (context_lock) \ + slock_lock(context_lock) + +#define video_driver_context_unlock() \ + if (context_lock) \ + slock_unlock(context_lock) + +#define video_driver_lock_free() \ + slock_free(display_lock); \ + slock_free(context_lock); \ + display_lock = NULL; \ + context_lock = NULL + +#define video_driver_threaded_lock(is_threaded) \ + if (is_threaded) \ + video_driver_lock() + +#define video_driver_threaded_unlock(is_threaded) \ + if (is_threaded) \ + video_driver_unlock() +#else +#define video_driver_lock() ((void)0) +#define video_driver_unlock() ((void)0) +#define video_driver_lock_free() ((void)0) +#define video_driver_threaded_lock(is_threaded) ((void)0) +#define video_driver_threaded_unlock(is_threaded) ((void)0) +#define video_driver_context_lock() ((void)0) +#define video_driver_context_unlock() ((void)0) +#endif + +#ifdef HAVE_THREADS +#define video_driver_get_ptr_internal(force) ((video_driver_is_threaded_internal() && !force) ? video_thread_get_ptr(NULL) : video_driver_data) +#else +#define video_driver_get_ptr_internal(force) (video_driver_data) +#endif + +#define video_driver_get_hw_context_internal() (&hw_render) + +#ifdef HAVE_THREADS +#define runloop_msg_queue_lock() slock_lock(_runloop_msg_queue_lock) +#define runloop_msg_queue_unlock() slock_unlock(_runloop_msg_queue_lock) +#else +#define runloop_msg_queue_lock() +#define runloop_msg_queue_unlock() +#endif + /* Descriptive names for options without short variant. * * Please keep the name in sync with the option name. @@ -3617,15 +3679,6 @@ void menu_driver_set_binding_state(bool on) { menu_driver_is_binding = on; } - -#endif - -#ifdef HAVE_THREADS -#define runloop_msg_queue_lock() slock_lock(_runloop_msg_queue_lock) -#define runloop_msg_queue_unlock() slock_unlock(_runloop_msg_queue_lock) -#else -#define runloop_msg_queue_lock() -#define runloop_msg_queue_unlock() #endif #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) @@ -3636,65 +3689,11 @@ static void retroarch_set_runtime_shader_preset(const char *arg) else runtime_shader_preset[0] = '\0'; } -#endif static void retroarch_unset_runtime_shader_preset(void) { -#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) runtime_shader_preset[0] = '\0'; -#endif } - -#ifdef HAVE_THREADS -#define video_driver_is_threaded_internal() ((!video_driver_is_hw_context() && video_driver_threaded) ? true : false) -#else -#define video_driver_is_threaded_internal() (false) -#endif - -#ifdef HAVE_THREADS -#define video_driver_lock() \ - if (display_lock) \ - slock_lock(display_lock) - -#define video_driver_unlock() \ - if (display_lock) \ - slock_unlock(display_lock) - -#define video_driver_context_lock() \ - if (context_lock) \ - slock_lock(context_lock) - -#define video_driver_context_unlock() \ - if (context_lock) \ - slock_unlock(context_lock) - -#define video_driver_lock_free() \ - slock_free(display_lock); \ - slock_free(context_lock); \ - display_lock = NULL; \ - context_lock = NULL - -#define video_driver_threaded_lock(is_threaded) \ - if (is_threaded) \ - video_driver_lock() - -#define video_driver_threaded_unlock(is_threaded) \ - if (is_threaded) \ - video_driver_unlock() -#else -#define video_driver_lock() ((void)0) -#define video_driver_unlock() ((void)0) -#define video_driver_lock_free() ((void)0) -#define video_driver_threaded_lock(is_threaded) ((void)0) -#define video_driver_threaded_unlock(is_threaded) ((void)0) -#define video_driver_context_lock() ((void)0) -#define video_driver_context_unlock() ((void)0) -#endif - -#ifdef HAVE_THREADS -#define video_driver_get_ptr_internal(force) ((video_driver_is_threaded_internal() && !force) ? video_thread_get_ptr(NULL) : video_driver_data) -#else -#define video_driver_get_ptr_internal(force) (video_driver_data) #endif #if defined(HAVE_RUNAHEAD) @@ -3724,8 +3723,6 @@ static char *strcpy_alloc_force(const char *src) #endif /* GLOBAL POINTER GETTERS */ -#define video_driver_get_hw_context_internal() (&hw_render) - struct retro_hw_render_callback *video_driver_get_hw_context(void) { return video_driver_get_hw_context_internal(); @@ -5916,7 +5913,9 @@ static void command_event_deinit_core(bool reinit) #ifdef HAVE_CONFIGFILE command_event_disable_overrides(); #endif +#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) retroarch_unset_runtime_shader_preset(); +#endif #ifdef HAVE_CONFIGFILE if ( runloop_remaps_core_active @@ -7168,7 +7167,9 @@ bool command_event(enum event_command cmd, void *data) #ifdef HAVE_CONFIGFILE command_event_disable_overrides(); #endif +#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) retroarch_unset_runtime_shader_preset(); +#endif if (cached_video_driver[0]) { @@ -27609,7 +27610,9 @@ bool retroarch_main_quit(void) #ifdef HAVE_CONFIGFILE command_event_disable_overrides(); #endif +#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) retroarch_unset_runtime_shader_preset(); +#endif #ifdef HAVE_CONFIGFILE if ( runloop_remaps_core_active From 9e5f00ba27e25cdfb4334a1a78ca14c953b9c25f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 04:43:35 +0200 Subject: [PATCH 134/192] Turn retroarch_fail static --- menu/menu_driver.c | 3 --- retroarch.c | 3 ++- retroarch.h | 9 --------- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index aa49b695b1..c1b13ef273 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -2771,10 +2771,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) menu_driver_find_handle(0); if (!menu_driver_ctx) - { - retroarch_fail(1, "find_menu_driver()"); return false; - } } } break; diff --git a/retroarch.c b/retroarch.c index 25634e36e0..90a955cf49 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2038,6 +2038,7 @@ static int g_ai_service_auto = 0; static unsigned gamepad_input_override = 0; /* Forward declarations */ +static void retroarch_fail(int error_code, const char *error); static void retroarch_core_options_intl_init(const struct retro_core_options_intl *core_options_intl); static void ui_companion_driver_toggle(bool force); @@ -27579,7 +27580,7 @@ void retroarch_set_current_core_type(enum rarch_core_type type, bool explicitly_ * * Sanely kills the program. **/ -void retroarch_fail(int error_code, const char *error) +static void retroarch_fail(int error_code, const char *error) { /* We cannot longjmp unless we're in retroarch_main_init(). * If not, something went very wrong, and we should diff --git a/retroarch.h b/retroarch.h index c7d78ceb7a..71e343b335 100644 --- a/retroarch.h +++ b/retroarch.h @@ -313,15 +313,6 @@ const char* retroarch_get_shader_preset(void); bool retroarch_is_switching_display_mode(void); -/** - * retroarch_fail: - * @error_code : Error code. - * @error : Error message to show. - * - * Sanely kills the program. - **/ -void retroarch_fail(int error_code, const char *error); - /** * retroarch_main_init: * @argc : Count of (commandline) arguments. From 13279eb0d43a626687f0a0beb3d47ea03ad1f20b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 04:54:14 +0200 Subject: [PATCH 135/192] Move defines to top --- retroarch.c | 288 ++++++++++++++++++++++++++-------------------------- 1 file changed, 146 insertions(+), 142 deletions(-) diff --git a/retroarch.c b/retroarch.c index 90a955cf49..f9c5ae6419 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1136,6 +1136,152 @@ static const camera_driver_t *camera_drivers[] = { #define runloop_msg_queue_unlock() #endif +#define BSV_MOVIE_IS_EOF() (bsv_movie_state.movie_end && bsv_movie_state.eof_exit) + +/* Time to exit out of the main loop? + * Reasons for exiting: + * a) Shutdown environment callback was invoked. + * b) Quit key was pressed. + * c) Frame count exceeds or equals maximum amount of frames to run. + * d) Video driver no longer alive. + * e) End of BSV movie and BSV EOF exit is true. (TODO/FIXME - explain better) + */ +#define TIME_TO_EXIT(quit_key_pressed) (runloop_shutdown_initiated || quit_key_pressed || !is_alive || BSV_MOVIE_IS_EOF() || ((runloop_max_frames != 0) && (frame_count >= runloop_max_frames)) || runloop_exec) + +/* Depends on ASCII character values */ +#define ISPRINT(c) (((int)(c) >= ' ' && (int)(c) <= '~') ? 1 : 0) + +#define input_config_bind_map_get(i) ((const struct input_bind_map*)&input_config_bind_map[(i)]) + +#define video_has_focus() ((current_video_context.has_focus) ? (current_video_context.has_focus && current_video_context.has_focus(video_context_data)) : (current_video->focus) ? (current_video && current_video->focus && current_video->focus(video_driver_data)) : true) + +#if HAVE_DYNAMIC +#define runahead_run_secondary() \ + if (!secondary_core_run_use_last_input()) \ + runahead_secondary_core_available = false + +#endif + +#define runahead_resume_video() \ + if (runahead_video_driver_is_active) \ + video_driver_active = true; \ + else \ + video_driver_active = false + +#define _PSUPP_BUF(buf, var, name, desc) \ + strlcat(buf, " ", sizeof(buf)); \ + strlcat(buf, name, sizeof(buf)); \ + strlcat(buf, ":\n\t\t", sizeof(buf)); \ + strlcat(buf, desc, sizeof(buf)); \ + strlcat(buf, ": ", sizeof(buf)); \ + strlcat(buf, var ? "yes\n" : "no\n", sizeof(buf)) + +#define HOTKEY_CHECK(cmd1, cmd2, cond, cond2) \ + { \ + static bool old_pressed = false; \ + bool pressed = BIT256_GET(current_bits, cmd1); \ + if (pressed && !old_pressed) \ + if (cond) \ + command_event(cmd2, cond2); \ + old_pressed = pressed; \ + } + +#define HOTKEY_CHECK3(cmd1, cmd2, cmd3, cmd4, cmd5, cmd6) \ + { \ + static bool old_pressed = false; \ + static bool old_pressed2 = false; \ + static bool old_pressed3 = false; \ + bool pressed = BIT256_GET(current_bits, cmd1); \ + bool pressed2 = BIT256_GET(current_bits, cmd3); \ + bool pressed3 = BIT256_GET(current_bits, cmd5); \ + if (pressed && !old_pressed) \ + command_event(cmd2, (void*)(intptr_t)0); \ + else if (pressed2 && !old_pressed2) \ + command_event(cmd4, (void*)(intptr_t)0); \ + else if (pressed3 && !old_pressed3) \ + command_event(cmd6, (void*)(intptr_t)0); \ + old_pressed = pressed; \ + old_pressed2 = pressed2; \ + old_pressed3 = pressed3; \ + } + +#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) +#define input_remote_key_pressed(key, port) (remote_st_ptr.buttons[(port)] & (UINT64_C(1) << (key))) +#endif + +/** + * check_input_driver_block_hotkey: + * + * Checks if 'hotkey enable' key is pressed. + * + * If we haven't bound anything to this, + * always allow hotkeys. + + * If we hold ENABLE_HOTKEY button, block all libretro input to allow + * hotkeys to be bound to same keys as RetroPad. + **/ +#define check_input_driver_block_hotkey(normal_bind, autoconf_bind) \ +( \ + (((normal_bind)->key != RETROK_UNKNOWN) \ + || ((normal_bind)->mbutton != NO_BTN) \ + || ((normal_bind)->joykey != NO_BTN) \ + || ((normal_bind)->joyaxis != AXIS_NONE) \ + || ((autoconf_bind)->key != RETROK_UNKNOWN) \ + || ((autoconf_bind)->joykey != NO_BTN) \ + || ((autoconf_bind)->joyaxis != AXIS_NONE)) \ +) + + +#define inherit_joyaxis(binds) (((binds)[x_plus].joyaxis == (binds)[x_minus].joyaxis) || ( (binds)[y_plus].joyaxis == (binds)[y_minus].joyaxis)) + +/** + * input_pop_analog_dpad: + * @binds : Binds to modify. + * + * Restores binds temporarily overridden by input_push_analog_dpad(). + **/ +#define input_pop_analog_dpad(binds) \ +{ \ + unsigned j; \ + for (j = RETRO_DEVICE_ID_JOYPAD_UP; j <= RETRO_DEVICE_ID_JOYPAD_RIGHT; j++) \ + (binds)[j].joyaxis = (binds)[j].orig_joyaxis; \ +} + +/** + * input_push_analog_dpad: + * @binds : Binds to modify. + * @mode : Which analog stick to bind D-Pad to. + * E.g: + * ANALOG_DPAD_LSTICK + * ANALOG_DPAD_RSTICK + * + * Push analog to D-Pad mappings to binds. + **/ +#define input_push_analog_dpad(binds, mode) \ +{ \ + unsigned k; \ + unsigned x_plus = RARCH_ANALOG_RIGHT_X_PLUS; \ + unsigned y_plus = RARCH_ANALOG_RIGHT_Y_PLUS; \ + unsigned x_minus = RARCH_ANALOG_RIGHT_X_MINUS; \ + unsigned y_minus = RARCH_ANALOG_RIGHT_Y_MINUS; \ + if ((mode) == ANALOG_DPAD_LSTICK) \ + { \ + x_plus = RARCH_ANALOG_LEFT_X_PLUS; \ + y_plus = RARCH_ANALOG_LEFT_Y_PLUS; \ + x_minus = RARCH_ANALOG_LEFT_X_MINUS; \ + y_minus = RARCH_ANALOG_LEFT_Y_MINUS; \ + } \ + for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) \ + (binds)[k].orig_joyaxis = (binds)[k].joyaxis; \ + if (!inherit_joyaxis(binds)) \ + { \ + unsigned j = x_plus + 3; \ + /* Inherit joyaxis from analogs. */ \ + for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) \ + (binds)[k].joyaxis = (binds)[j--].joyaxis; \ + } \ +} + /* Descriptive names for options without short variant. * * Please keep the name in sync with the option name. @@ -14034,8 +14180,6 @@ static void retroarch_overlay_init(void) /* INPUT REMOTE */ #if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) -#define input_remote_key_pressed(key, port) (remote_st_ptr.buttons[(port)] & (UINT64_C(1) << (key))) - static bool input_remote_init_network(input_remote_t *handle, uint16_t port, unsigned user) { @@ -14140,29 +14284,6 @@ static void fire_connection_listener(unsigned port, input_device_driver_t *drive pad_connection_listener->connected(port, driver); } - -/** - * check_input_driver_block_hotkey: - * - * Checks if 'hotkey enable' key is pressed. - * - * If we haven't bound anything to this, - * always allow hotkeys. - - * If we hold ENABLE_HOTKEY button, block all libretro input to allow - * hotkeys to be bound to same keys as RetroPad. - **/ -#define check_input_driver_block_hotkey(normal_bind, autoconf_bind) \ -( \ - (((normal_bind)->key != RETROK_UNKNOWN) \ - || ((normal_bind)->mbutton != NO_BTN) \ - || ((normal_bind)->joykey != NO_BTN) \ - || ((normal_bind)->joyaxis != AXIS_NONE) \ - || ((autoconf_bind)->key != RETROK_UNKNOWN) \ - || ((autoconf_bind)->joykey != NO_BTN) \ - || ((autoconf_bind)->joyaxis != AXIS_NONE)) \ -) - /** * input_driver_find_handle: * @idx : index of driver to get handle to. @@ -14944,56 +15065,6 @@ static int16_t input_joypad_axis(const input_device_driver_t *drv, return val; } -#define inherit_joyaxis(binds) (((binds)[x_plus].joyaxis == (binds)[x_minus].joyaxis) || ( (binds)[y_plus].joyaxis == (binds)[y_minus].joyaxis)) - -/** - * input_pop_analog_dpad: - * @binds : Binds to modify. - * - * Restores binds temporarily overridden by input_push_analog_dpad(). - **/ -#define input_pop_analog_dpad(binds) \ -{ \ - unsigned j; \ - for (j = RETRO_DEVICE_ID_JOYPAD_UP; j <= RETRO_DEVICE_ID_JOYPAD_RIGHT; j++) \ - (binds)[j].joyaxis = (binds)[j].orig_joyaxis; \ -} - -/** - * input_push_analog_dpad: - * @binds : Binds to modify. - * @mode : Which analog stick to bind D-Pad to. - * E.g: - * ANALOG_DPAD_LSTICK - * ANALOG_DPAD_RSTICK - * - * Push analog to D-Pad mappings to binds. - **/ -#define input_push_analog_dpad(binds, mode) \ -{ \ - unsigned k; \ - unsigned x_plus = RARCH_ANALOG_RIGHT_X_PLUS; \ - unsigned y_plus = RARCH_ANALOG_RIGHT_Y_PLUS; \ - unsigned x_minus = RARCH_ANALOG_RIGHT_X_MINUS; \ - unsigned y_minus = RARCH_ANALOG_RIGHT_Y_MINUS; \ - if ((mode) == ANALOG_DPAD_LSTICK) \ - { \ - x_plus = RARCH_ANALOG_LEFT_X_PLUS; \ - y_plus = RARCH_ANALOG_LEFT_Y_PLUS; \ - x_minus = RARCH_ANALOG_LEFT_X_MINUS; \ - y_minus = RARCH_ANALOG_LEFT_Y_MINUS; \ - } \ - for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) \ - (binds)[k].orig_joyaxis = (binds)[k].joyaxis; \ - if (!inherit_joyaxis(binds)) \ - { \ - unsigned j = x_plus + 3; \ - /* Inherit joyaxis from analogs. */ \ - for (k = RETRO_DEVICE_ID_JOYPAD_UP; k <= RETRO_DEVICE_ID_JOYPAD_RIGHT; k++) \ - (binds)[k].joyaxis = (binds)[j--].joyaxis; \ - } \ -} - /* MENU INPUT */ #ifdef HAVE_MENU /* Must be called inside menu_driver_toggle() @@ -17218,9 +17289,6 @@ static void osk_update_last_codepoint(const char *word) } } -/* Depends on ASCII character values */ -#define ISPRINT(c) (((int)(c) >= ' ' && (int)(c) <= '~') ? 1 : 0) - /** * input_keyboard_line_event: * @state : Input keyboard line handle. @@ -17578,8 +17646,6 @@ bool input_keyboard_ctl(enum rarch_input_keyboard_ctl_state state, void *data) return true; } -#define input_config_bind_map_get(i) ((const struct input_bind_map*)&input_config_bind_map[(i)]) - static bool input_config_bind_map_get_valid(unsigned i) { const struct input_bind_map *keybind = @@ -23089,8 +23155,6 @@ bool video_driver_translate_coord_viewport( return true; } -#define video_has_focus() ((current_video_context.has_focus) ? (current_video_context.has_focus && current_video_context.has_focus(video_context_data)) : (current_video->focus) ? (current_video && current_video->focus && current_video->focus(video_driver_data)) : true) - bool video_driver_has_focus(void) { return video_has_focus(); @@ -25029,19 +25093,8 @@ static bool runahead_load_state_secondary(void) return true; } - -#define runahead_run_secondary() \ - if (!secondary_core_run_use_last_input()) \ - runahead_secondary_core_available = false - #endif -#define runahead_resume_video() \ - if (runahead_video_driver_is_active) \ - video_driver_active = true; \ - else \ - video_driver_active = false - static bool runahead_core_run_use_last_input(void) { retro_input_poll_t old_poll_function = retro_ctx.poll_cb; @@ -25237,14 +25290,6 @@ static retro_time_t rarch_core_runtime_tick(retro_time_t current_time) return frame_time; } -#define _PSUPP_BUF(buf, var, name, desc) \ - strlcat(buf, " ", sizeof(buf)); \ - strlcat(buf, name, sizeof(buf)); \ - strlcat(buf, ":\n\t\t", sizeof(buf)); \ - strlcat(buf, desc, sizeof(buf)); \ - strlcat(buf, ": ", sizeof(buf)); \ - strlcat(buf, var ? "yes\n" : "no\n", sizeof(buf)) - static void retroarch_print_features(void) { char buf[2048]; @@ -27685,18 +27730,6 @@ void runloop_get_status(bool *is_paused, bool *is_idle, *is_perfcnt_enable = runloop_perfcnt_enable; } -#define BSV_MOVIE_IS_EOF() (bsv_movie_state.movie_end && bsv_movie_state.eof_exit) - -/* Time to exit out of the main loop? - * Reasons for exiting: - * a) Shutdown environment callback was invoked. - * b) Quit key was pressed. - * c) Frame count exceeds or equals maximum amount of frames to run. - * d) Video driver no longer alive. - * e) End of BSV movie and BSV EOF exit is true. (TODO/FIXME - explain better) - */ -#define TIME_TO_EXIT(quit_key_pressed) (runloop_shutdown_initiated || quit_key_pressed || !is_alive || BSV_MOVIE_IS_EOF() || ((runloop_max_frames != 0) && (frame_count >= runloop_max_frames)) || runloop_exec) - #ifdef HAVE_MENU static bool input_driver_toggle_button_combo( unsigned mode, @@ -27790,35 +27823,6 @@ static bool input_driver_toggle_button_combo( } #endif -#define HOTKEY_CHECK(cmd1, cmd2, cond, cond2) \ - { \ - static bool old_pressed = false; \ - bool pressed = BIT256_GET(current_bits, cmd1); \ - if (pressed && !old_pressed) \ - if (cond) \ - command_event(cmd2, cond2); \ - old_pressed = pressed; \ - } - -#define HOTKEY_CHECK3(cmd1, cmd2, cmd3, cmd4, cmd5, cmd6) \ - { \ - static bool old_pressed = false; \ - static bool old_pressed2 = false; \ - static bool old_pressed3 = false; \ - bool pressed = BIT256_GET(current_bits, cmd1); \ - bool pressed2 = BIT256_GET(current_bits, cmd3); \ - bool pressed3 = BIT256_GET(current_bits, cmd5); \ - if (pressed && !old_pressed) \ - command_event(cmd2, (void*)(intptr_t)0); \ - else if (pressed2 && !old_pressed2) \ - command_event(cmd4, (void*)(intptr_t)0); \ - else if (pressed3 && !old_pressed3) \ - command_event(cmd6, (void*)(intptr_t)0); \ - old_pressed = pressed; \ - old_pressed2 = pressed2; \ - old_pressed3 = pressed3; \ - } - #if defined(HAVE_MENU) static bool menu_display_libretro_running(void) { From 692f37b91a1df0b3b7648f0d556b96e678864522 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 06:04:51 +0200 Subject: [PATCH 136/192] Rearrange global variables --- retroarch.c | 670 +++++++++++++++++++++++++++++----------------------- 1 file changed, 371 insertions(+), 299 deletions(-) diff --git a/retroarch.c b/retroarch.c index f9c5ae6419..40ef9d7f1c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1436,14 +1436,14 @@ typedef struct input_list_element_t typedef void *(*constructor_t)(void); typedef void (*destructor_t )(void*); -typedef struct MyList_t +typedef struct my_list_t { void **data; int capacity; int size; constructor_t constructor; destructor_t destructor; -} MyList; +} my_list; #ifdef HAVE_OVERLAY typedef struct input_overlay_state @@ -1561,17 +1561,24 @@ static settings_t *configuration_settings = NULL; static enum rarch_core_type current_core_type = CORE_TYPE_PLAIN; static enum rarch_core_type explicit_current_core_type = CORE_TYPE_PLAIN; -/* - * Override poll type behavior, is set by the core. - * - * 0 - Don't Care - * 1 - Early - * 2 - Normal - * 3 - Late - */ -static unsigned core_poll_type_override = 0; +static enum rotation initial_screen_orientation = ORIENTATION_NORMAL; +static enum rotation current_screen_orientation = ORIENTATION_NORMAL; -static bool has_set_username = false; +static enum retro_pixel_format video_driver_pix_fmt = RETRO_PIXEL_FORMAT_0RGB1555; + +static enum rarch_display_type video_driver_display_type = RARCH_DISPLAY_NONE; + +#if defined(HAVE_COMMAND) +static enum cmd_source_t lastcmd_source; +#endif + +#if defined(HAVE_RUNAHEAD) +static enum rarch_core_type last_core_type; +#endif + +#ifdef HAVE_OVERLAY +static enum overlay_visibility *visibility = NULL; +#endif #ifdef HAVE_THREAD_STORAGE static sthread_tls_t rarch_tls; @@ -1586,22 +1593,14 @@ static retro_keyboard_event_t runloop_key_event = NULL; static retro_keyboard_event_t runloop_frontend_key_event = NULL; static core_option_manager_t *runloop_core_options = NULL; static msg_queue_t *runloop_msg_queue = NULL; -static size_t runloop_msg_queue_size = 0; - -static unsigned runloop_pending_windowed_scale = 0; -static unsigned runloop_max_frames = 0; -static unsigned fastforward_after_frames = 0; static retro_usec_t runloop_frame_time_last = 0; -static retro_time_t frame_limit_minimum_time = 0.0; -static retro_time_t frame_limit_last_time = 0.0; -static retro_time_t libretro_core_runtime_last = 0; -static retro_time_t libretro_core_runtime_usec = 0; static bool has_set_core = false; #ifdef HAVE_DISCORD bool discord_is_inited = false; #endif +static bool has_set_username = false; static bool rarch_is_inited = false; static bool rarch_error_on_init = false; static bool rarch_force_fullscreen = false; @@ -1645,85 +1644,310 @@ static bool runloop_max_frames_screenshot = false; #ifdef HAVE_RUNAHEAD static bool has_variable_update = false; #endif - #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) static bool shader_presets_need_reload = true; -static char cli_shader[PATH_MAX_LENGTH] = {0}; static bool cli_shader_disable = false; -static char runtime_shader_preset[PATH_MAX_LENGTH] = {0}; -static rarch_timer_t shader_delay_timer = {0}; #endif -static char runloop_max_frames_screenshot_path[PATH_MAX_LENGTH] = {0}; -static char runtime_content_path[PATH_MAX_LENGTH] = {0}; -static char runtime_core_path[PATH_MAX_LENGTH] = {0}; -static char launch_arguments[4096] = {0}; -static char current_library_name[1024] = {0}; -static char current_library_version[1024] = {0}; -static char current_valid_extensions[1024] = {0}; -static char error_string[255] = {0}; -static char cached_video_driver[32] = {0}; - -static struct string_list *subsystem_fullpaths = NULL; - -static char subsystem_path[PATH_MAX_LENGTH] = {0}; -static char path_default_shader_preset[PATH_MAX_LENGTH] = {0}; -static char path_main_basename[8192] = {0}; -static char path_content[PATH_MAX_LENGTH] = {0}; -static char path_libretro[PATH_MAX_LENGTH] = {0}; -static char path_config_file[PATH_MAX_LENGTH] = {0}; -static char path_config_append_file[PATH_MAX_LENGTH] = {0}; -static char path_core_options_file[PATH_MAX_LENGTH] = {0}; - -static struct rarch_dir_list dir_shader_list; - -static char dir_system[PATH_MAX_LENGTH] = {0}; -static char dir_savefile[PATH_MAX_LENGTH] = {0}; -static char current_savefile_dir[PATH_MAX_LENGTH] = {0}; -static char current_savestate_dir[PATH_MAX_LENGTH] = {0}; -static char dir_savestate[PATH_MAX_LENGTH] = {0}; - #ifdef HAVE_GFX_WIDGETS -static bool gfx_widgets_paused = false; -static bool gfx_widgets_fast_forward = false; -static bool gfx_widgets_rewinding = false; +static bool gfx_widgets_paused = false; +static bool gfx_widgets_fast_forward = false; +static bool gfx_widgets_rewinding = false; #endif - #ifdef HAVE_ACCESSIBILITY /* Is text-to-speech accessibility turned on? */ -static bool accessibility_enabled = false; +static bool accessibility_enabled = false; #endif +static bool location_driver_active = false; + +static bool wifi_driver_active = false; + +static bool video_driver_state_out_rgb32 = false; +static bool video_driver_crt_switching_active = false; +static bool video_driver_crt_dynamic_super_width = false; +static bool video_driver_threaded = false; +static bool video_driver_window_title_update = true; + +/* 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 bool video_driver_use_rgba = false; +static bool video_driver_active = false; + +/* 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 bool video_started_fullscreen = false; + +static bool audio_driver_control = false; +static bool audio_driver_mute_enable = false; +static bool audio_driver_use_float = false; +static bool audio_driver_active = false; + +static bool audio_suspended = false; +static bool audio_is_threaded = false; + +#ifdef HAVE_RUNAHEAD +static bool runahead_save_state_size_known = false; +static bool request_fast_savestate = false; +static bool hard_disable_audio = false; + +static bool input_is_dirty = false; + +static bool runahead_video_driver_is_active = true; +static bool runahead_available = true; +static bool runahead_secondary_core_available = true; +static bool runahead_force_input_dirty = true; +#endif + +#if defined(HAVE_NETWORKING) +static bool has_set_netplay_mode = false; +static bool has_set_netplay_ip_address = false; +static bool has_set_netplay_ip_port = false; +static bool has_set_netplay_stateless_mode = false; +static bool has_set_netplay_check_frames = false; +#endif + +static bool input_driver_keyboard_linefeed_enable = false; + +static bool input_driver_block_hotkey = false; +static bool input_driver_block_libretro_input = false; +static bool input_driver_nonblock_state = false; + #ifdef HAVE_MENU -static const char **menu_input_dialog_keyboard_buffer = {NULL}; -static unsigned menu_input_dialog_keyboard_type = 0; -static unsigned menu_input_dialog_keyboard_idx = 0; -static char menu_input_dialog_keyboard_label_setting[256] = {0}; -static char menu_input_dialog_keyboard_label[256] = {0}; -static bool menu_input_dialog_keyboard_display = false; -static unsigned char menu_keyboard_key_state[RETROK_LAST] = {0}; - -/* Since these are static/global, they are initialised to zero */ -static menu_input_pointer_hw_state_t menu_input_pointer_hw_state; -static menu_input_t menu_input_state; - +static bool menu_input_dialog_keyboard_display = false; /* Is the menu driver still running? */ static bool menu_driver_alive = false; /* Are we binding a button inside the menu? */ static bool menu_driver_is_binding = false; #endif -static unsigned recording_width = 0; -static unsigned recording_height = 0; -static size_t recording_gpu_width = 0; -static size_t recording_gpu_height = 0; static bool recording_enable = false; static bool streaming_enable = false; +static bool camera_driver_active = false; + +static bool midi_drv_input_enabled = false; +static bool midi_drv_output_enabled = false; + +static bool midi_drv_output_pending = false; + +static bool main_ui_companion_is_on_foreground = false; + +#ifdef HAVE_QT +static bool qt_is_inited = false; +#endif + +#ifdef HAVE_AUDIOMIXER +static bool audio_driver_mixer_mute_enable = false; +static bool audio_mixer_active = false; +#endif + +/** + * dynamic.c:dynamic_request_hw_context will try to set flag data when the context + * is in the middle of being rebuilt; in these cases we will save flag + * data and set this to true. + * When the context is reinit, it checks this, reads from + * deferred_flag_data and cleans it. + * + * TODO - Dirty hack, fix it better + */ +static bool deferred_video_context_driver_set_flags = false; + +static uint16_t input_config_vid[MAX_USERS] = {0}; +static uint16_t input_config_pid[MAX_USERS] = {0}; + +#if defined(HAVE_COMMAND) +#ifdef HAVE_NETWORK_CMD +static int lastcmd_net_fd = 0; +#endif +#endif + +#if defined(HAVE_RUNAHEAD) +#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB) +static int port_map[16] = {0}; +#endif +#endif + +#ifdef HAVE_TRANSLATE +static int g_ai_service_auto = 0; +#endif + +#if defined(HAVE_ACCESSIBILITY) && defined(HAVE_TRANSLATE) +static int ai_gamepad_state[16] = {0}; +#endif + +static size_t runloop_msg_queue_size = 0; +static size_t recording_gpu_width = 0; +static size_t recording_gpu_height = 0; + +static size_t frame_cache_pitch = 0; + +static size_t audio_driver_chunk_size = 0; +static size_t audio_driver_chunk_nonblock_size = 0; +static size_t audio_driver_chunk_block_size = 0; + +static size_t audio_driver_rewind_ptr = 0; +static size_t audio_driver_rewind_size = 0; +static size_t audio_driver_buffer_size = 0; +static size_t audio_driver_data_ptr = 0; + +#ifdef HAVE_RUNAHEAD +static size_t runahead_save_state_size = 0; +#endif + +/* + * Override poll type behavior, is set by the core. + * + * 0 - Don't Care + * 1 - Early + * 2 - Normal + * 3 - Late + */ +static unsigned core_poll_type_override = 0; + +static unsigned runloop_pending_windowed_scale = 0; +static unsigned runloop_max_frames = 0; +static unsigned fastforward_after_frames = 0; + +#ifdef HAVE_MENU +static unsigned menu_input_dialog_keyboard_type = 0; +static unsigned menu_input_dialog_keyboard_idx = 0; +#endif + +static unsigned recording_width = 0; +static unsigned recording_height = 0; + +static unsigned video_driver_state_scale = 0; +static unsigned video_driver_state_out_bpp = 0; +static unsigned frame_cache_width = 0; +static unsigned frame_cache_height = 0; +static unsigned video_driver_width = 0; +static unsigned video_driver_height = 0; +static unsigned osk_last_codepoint = 0; +static unsigned osk_last_codepoint_len = 0; +static unsigned input_driver_flushing_input = 0; +static unsigned input_driver_max_users = 0; +static unsigned gamepad_input_override = 0; + +#ifdef HAVE_MENU +static unsigned char menu_keyboard_key_state[RETROK_LAST] = {0}; +#endif +static unsigned audio_driver_free_samples_buf[ + AUDIO_BUFFER_FREE_SAMPLES_COUNT] = {0}; + +/* Opaque handles to currently running window. + * Used by e.g. input drivers which bind to a window. + * Drivers are responsible for setting these if an input driver + * could potentially make use of this. */ +static uintptr_t video_driver_display_userdata = 0; +static uintptr_t video_driver_display = 0; +static uintptr_t video_driver_window = 0; + +static float video_driver_core_hz = 0.0f; +static float video_driver_aspect_ratio = 0.0f; + +#ifdef HAVE_AUDIOMIXER +static float audio_driver_mixer_volume_gain = 0.0f; +#endif + +static float audio_driver_rate_control_delta = 0.0f; +static float audio_driver_input = 0.0f; +static float audio_driver_volume_gain = 0.0f; + +static float input_driver_axis_threshold = 0.0f; + +static float *audio_driver_input_data = NULL; +static float *audio_driver_output_samples_buf = NULL; + +static retro_time_t frame_limit_minimum_time = 0; +static retro_time_t frame_limit_last_time = 0; +static retro_time_t libretro_core_runtime_last = 0; +static retro_time_t libretro_core_runtime_usec = 0; +static retro_time_t video_driver_frame_time_samples[ + MEASURE_FRAME_TIME_SAMPLES_COUNT] = {0}; + +static uint64_t audio_driver_free_samples_count = 0; + +#ifdef HAVE_RUNAHEAD +static uint64_t runahead_last_frame_count = 0; +#endif + +static uint64_t video_driver_frame_time_count = 0; +static uint64_t video_driver_frame_count = 0; + +uint64_t lifecycle_state = 0; + +static double audio_source_ratio_original = 0.0f; +static double audio_source_ratio_current = 0.0f; + +static char cached_video_driver[32] = {0}; +static char video_driver_title_buf[64] = {0}; +static char video_driver_gpu_device_string[128] = {0}; +static char video_driver_gpu_api_version_string[128] = {0}; +static char error_string[255] = {0}; +#ifdef HAVE_MENU +static char menu_input_dialog_keyboard_label_setting[256] = {0}; +static char menu_input_dialog_keyboard_label[256] = {0}; +#endif +static char video_driver_window_title[512] = {0}; +static char current_library_name[1024] = {0}; +static char current_library_version[1024] = {0}; +static char current_valid_extensions[1024] = {0}; +static char launch_arguments[4096] = {0}; +static char path_main_basename[8192] = {0}; + +#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) +static char cli_shader[PATH_MAX_LENGTH] = {0}; +static char runtime_shader_preset[PATH_MAX_LENGTH] = {0}; +#endif +static char runloop_max_frames_screenshot_path[PATH_MAX_LENGTH] = {0}; +static char runtime_content_path[PATH_MAX_LENGTH] = {0}; +static char runtime_core_path[PATH_MAX_LENGTH] = {0}; +static char subsystem_path[PATH_MAX_LENGTH] = {0}; +static char path_default_shader_preset[PATH_MAX_LENGTH] = {0}; +static char path_content[PATH_MAX_LENGTH] = {0}; +static char path_libretro[PATH_MAX_LENGTH] = {0}; +static char path_config_file[PATH_MAX_LENGTH] = {0}; +static char path_config_append_file[PATH_MAX_LENGTH] = {0}; +static char path_core_options_file[PATH_MAX_LENGTH] = {0}; +static char dir_system[PATH_MAX_LENGTH] = {0}; +static char dir_savefile[PATH_MAX_LENGTH] = {0}; +static char current_savefile_dir[PATH_MAX_LENGTH] = {0}; +static char current_savestate_dir[PATH_MAX_LENGTH] = {0}; +static char dir_savestate[PATH_MAX_LENGTH] = {0}; + +static char input_device_display_names[MAX_INPUT_DEVICES][64]; +static char input_device_config_names [MAX_INPUT_DEVICES][64]; +static char input_device_config_paths [MAX_INPUT_DEVICES][64]; + +#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) +static rarch_timer_t shader_delay_timer = {0}; +#endif + +static struct string_list *subsystem_fullpaths = NULL; + +static struct rarch_dir_list dir_shader_list; + +#ifdef HAVE_MENU +static const char **menu_input_dialog_keyboard_buffer = {NULL}; + +/* Since these are static/global, they are initialised to zero */ +static menu_input_pointer_hw_state_t menu_input_pointer_hw_state; +static menu_input_t menu_input_state; +#endif + static const record_driver_t *recording_driver = NULL; static void *recording_data = NULL; -static uint8_t *video_driver_record_gpu_buffer = NULL; - #ifdef HAVE_THREADS static slock_t *_runloop_msg_queue_lock = NULL; #endif @@ -1731,19 +1955,13 @@ static slock_t *_runloop_msg_queue_lock = NULL; static struct retro_camera_callback camera_cb; static const camera_driver_t *camera_driver = NULL; static void *camera_data = NULL; -static bool camera_driver_active = false; -static midi_driver_t *midi_drv = &midi_null; -static void *midi_drv_data = NULL; -static struct string_list *midi_drv_inputs = NULL; -static struct string_list *midi_drv_outputs = NULL; -static bool midi_drv_input_enabled = false; -static bool midi_drv_output_enabled = false; -static uint8_t *midi_drv_input_buffer = NULL; -static uint8_t *midi_drv_output_buffer = NULL; +static midi_driver_t *midi_drv = &midi_null; +static void *midi_drv_data = NULL; +static struct string_list *midi_drv_inputs = NULL; +static struct string_list *midi_drv_outputs = NULL; static midi_event_t midi_drv_input_event; static midi_event_t midi_drv_output_event; -static bool midi_drv_output_pending = false; static const uint8_t midi_drv_ev_sizes[128] = { @@ -1757,33 +1975,30 @@ static const uint8_t midi_drv_ev_sizes[128] = 0, 2, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; -static bool main_ui_companion_is_on_foreground = false; -static const ui_companion_driver_t *ui_companion = NULL; -static void *ui_companion_data = NULL; +static uint8_t *video_driver_record_gpu_buffer = NULL; +static uint8_t *midi_drv_input_buffer = NULL; +static uint8_t *midi_drv_output_buffer = NULL; + +static const ui_companion_driver_t *ui_companion = NULL; +static void *ui_companion_data = NULL; #ifdef HAVE_QT -static void *ui_companion_qt_data = NULL; -static bool qt_is_inited = false; +static void *ui_companion_qt_data = NULL; #endif -static const location_driver_t *location_driver = NULL; -static void *location_data = NULL; +static const location_driver_t *location_driver = NULL; +static void *location_data = NULL; -static bool location_driver_active = false; +static const wifi_driver_t *wifi_driver = NULL; +static void *wifi_data = NULL; -static const wifi_driver_t *wifi_driver = NULL; -static void *wifi_data = NULL; -static bool wifi_driver_active = false; +static const video_display_server_t *current_display_server = &dispserv_null; +static void *current_display_server_data = NULL; -static const video_display_server_t *current_display_server = &dispserv_null; -static void *current_display_server_data = NULL; -static enum rotation initial_screen_orientation = ORIENTATION_NORMAL; -static enum rotation current_screen_orientation = ORIENTATION_NORMAL; - -static bsv_movie_t *bsv_movie_state_handle = NULL; +static bsv_movie_t *bsv_movie_state_handle = NULL; static struct bsv_state bsv_movie_state; -struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { +struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { { "4:3", 1.3333f }, { "16:9", 1.7778f }, { "16:10", 1.6f }, @@ -1811,93 +2026,43 @@ struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { }; static gfx_api_gpu_map gpu_map[] = { - { GFX_CTX_VULKAN_API, NULL }, + { GFX_CTX_VULKAN_API, NULL }, { GFX_CTX_DIRECT3D10_API, NULL }, { GFX_CTX_DIRECT3D11_API, NULL }, { GFX_CTX_DIRECT3D12_API, NULL } }; -/* Opaque handles to currently running window. - * Used by e.g. input drivers which bind to a window. - * Drivers are responsible for setting these if an input driver - * could potentially make use of this. */ -static uintptr_t video_driver_display_userdata = 0; -static uintptr_t video_driver_display = 0; -static uintptr_t video_driver_window = 0; - static rarch_softfilter_t *video_driver_state_filter = NULL; static void *video_driver_state_buffer = NULL; -static unsigned video_driver_state_scale = 0; -static unsigned video_driver_state_out_bpp = 0; -static bool video_driver_state_out_rgb32 = false; -static bool video_driver_crt_switching_active = false; -static bool video_driver_crt_dynamic_super_width = false; -static enum retro_pixel_format video_driver_pix_fmt = RETRO_PIXEL_FORMAT_0RGB1555; +static const void *frame_cache_data = NULL; -static const void *frame_cache_data = NULL; -static unsigned frame_cache_width = 0; -static unsigned frame_cache_height = 0; -static size_t frame_cache_pitch = 0; -static bool video_driver_threaded = false; - -static float video_driver_core_hz = 0.0f; -static float video_driver_aspect_ratio = 0.0f; -static unsigned video_driver_width = 0; -static unsigned video_driver_height = 0; - -static enum rarch_display_type video_driver_display_type = RARCH_DISPLAY_NONE; -static char video_driver_title_buf[64] = {0}; -static char video_driver_window_title[512] = {0}; -static bool video_driver_window_title_update = true; - -static retro_time_t video_driver_frame_time_samples[MEASURE_FRAME_TIME_SAMPLES_COUNT]; -static uint64_t video_driver_frame_time_count = 0; -static uint64_t video_driver_frame_count = 0; - -static void *video_driver_data = NULL; -static video_driver_t *current_video = NULL; +static void *video_driver_data = NULL; +static video_driver_t *current_video = NULL; /* Interface for "poking". */ -static const video_poke_interface_t *video_driver_poke = NULL; +static const video_poke_interface_t *video_driver_poke = NULL; /* Used for 15-bit -> 16-bit conversions that take place before * being passed to video driver. */ -static video_pixel_scaler_t *video_driver_scaler_ptr = NULL; +static video_pixel_scaler_t *video_driver_scaler_ptr = NULL; static struct retro_hw_render_callback hw_render; static const struct retro_hw_render_context_negotiation_interface * -hw_render_context_negotiation = NULL; +hw_render_context_negotiation = NULL; -/* 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 bool video_driver_use_rgba = 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 video_driver_frame_t frame_bak = NULL; #ifdef HAVE_THREADS -static slock_t *display_lock = NULL; -static slock_t *context_lock = NULL; +static slock_t *display_lock = NULL; +static slock_t *context_lock = NULL; #endif -static gfx_ctx_driver_t current_video_context; +static void *video_context_data = NULL; -static void *video_context_data = NULL; +static gfx_ctx_driver_t current_video_context; /** * dynamic.c:dynamic_request_hw_context will try to set flag data when the context @@ -1908,110 +2073,46 @@ static void *video_context_data = NULL; * * TODO - Dirty hack, fix it better */ -static bool deferred_video_context_driver_set_flags = false; -static gfx_ctx_flags_t deferred_flag_data = {0}; - -static bool video_started_fullscreen = false; - -static char video_driver_gpu_device_string[128] = {0}; -static char video_driver_gpu_api_version_string[128] = {0}; +static gfx_ctx_flags_t deferred_flag_data = {0}; static struct retro_system_av_info video_driver_av_info; #ifdef HAVE_AUDIOMIXER static struct audio_mixer_stream -audio_mixer_streams[AUDIO_MIXER_MAX_SYSTEM_STREAMS] = {{0}}; - -static bool audio_driver_mixer_mute_enable = false; -static bool audio_mixer_active = false; -static float audio_driver_mixer_volume_gain = 0.0f; +audio_mixer_streams[AUDIO_MIXER_MAX_SYSTEM_STREAMS] = {{0}}; #endif -static size_t audio_driver_chunk_size = 0; -static size_t audio_driver_chunk_nonblock_size = 0; -static size_t audio_driver_chunk_block_size = 0; +static int16_t *audio_driver_rewind_buf = NULL; +static int16_t *audio_driver_output_samples_conv_buf = NULL; -static size_t audio_driver_rewind_ptr = 0; -static size_t audio_driver_rewind_size = 0; +static struct retro_audio_callback audio_callback = {0}; -static int16_t *audio_driver_rewind_buf = NULL; -static int16_t *audio_driver_output_samples_conv_buf = NULL; +static retro_dsp_filter_t *audio_driver_dsp = NULL; +static struct string_list *audio_driver_devices_list = NULL; +static const retro_resampler_t *audio_driver_resampler = NULL; -static unsigned audio_driver_free_samples_buf[AUDIO_BUFFER_FREE_SAMPLES_COUNT]; -static uint64_t audio_driver_free_samples_count = 0; - -static size_t audio_driver_buffer_size = 0; -static size_t audio_driver_data_ptr = 0; - -static bool audio_driver_control = false; -static bool audio_driver_mute_enable = false; -static bool audio_driver_use_float = false; -static bool audio_driver_active = false; - -static float audio_driver_rate_control_delta = 0.0f; -static float audio_driver_input = 0.0f; -static float audio_driver_volume_gain = 0.0f; - -static float *audio_driver_input_data = NULL; -static float *audio_driver_output_samples_buf = NULL; - -static double audio_source_ratio_original = 0.0f; -static double audio_source_ratio_current = 0.0f; - -static struct retro_audio_callback audio_callback = {0}; - -static retro_dsp_filter_t *audio_driver_dsp = NULL; -static struct string_list *audio_driver_devices_list = NULL; -static const retro_resampler_t *audio_driver_resampler = NULL; - -static void *audio_driver_resampler_data = NULL; -static const audio_driver_t *current_audio = NULL; -static void *audio_driver_context_audio_data = NULL; - -static bool audio_suspended = false; -static bool audio_is_threaded = false; +static void *audio_driver_resampler_data = NULL; +static const audio_driver_t *current_audio = NULL; +static void *audio_driver_context_audio_data = NULL; #ifdef HAVE_RUNAHEAD -static size_t runahead_save_state_size = 0; - -static bool runahead_save_state_size_known = false; -static bool request_fast_savestate = false; -static bool hard_disable_audio = false; - -static MyList *runahead_save_state_list = NULL; -static MyList *input_state_list = NULL; - -static bool input_is_dirty = false; +static my_list *runahead_save_state_list = NULL; +static my_list *input_state_list = NULL; typedef bool(*runahead_load_state_function)(const void*, size_t); static retro_input_state_t input_state_callback_original; -static function_t retro_reset_callback_original = NULL; +static function_t retro_reset_callback_original = NULL; static runahead_load_state_function -retro_unserialize_callback_original = NULL; +retro_unserialize_callback_original = NULL; -static function_t original_retro_deinit = NULL; -static function_t original_retro_unload = NULL; +static function_t original_retro_deinit = NULL; +static function_t original_retro_unload = NULL; -static bool runahead_video_driver_is_active = true; -static bool runahead_available = true; -static bool runahead_secondary_core_available = true; -static bool runahead_force_input_dirty = true; -static uint64_t runahead_last_frame_count = 0; -#endif - -#if defined(HAVE_NETWORKING) -static bool has_set_netplay_mode = false; -static bool has_set_netplay_ip_address = false; -static bool has_set_netplay_ip_port = false; -static bool has_set_netplay_stateless_mode = false; -static bool has_set_netplay_check_frames = false; #endif #if defined(HAVE_COMMAND) -static enum cmd_source_t lastcmd_source; #ifdef HAVE_NETWORK_CMD -static int lastcmd_net_fd; static struct sockaddr_storage lastcmd_net_source; static socklen_t lastcmd_net_source_len; #endif @@ -2023,22 +2124,13 @@ static input_remote_state_t remote_st_ptr; #endif #ifdef HAVE_OVERLAY -static enum overlay_visibility* visibility = NULL; - -static input_overlay_t *overlay_ptr = NULL; +static input_overlay_t *overlay_ptr = NULL; #endif -static pad_connection_listener_t *pad_connection_listener = NULL; +static pad_connection_listener_t *pad_connection_listener = NULL; -static uint16_t input_config_vid[MAX_USERS]; -static uint16_t input_config_pid[MAX_USERS]; - -static char input_device_display_names[MAX_INPUT_DEVICES][64]; -static char input_device_config_names [MAX_INPUT_DEVICES][64]; -static char input_device_config_paths [MAX_INPUT_DEVICES][64]; char input_device_names [MAX_INPUT_DEVICES][64]; -uint64_t lifecycle_state; struct retro_keybind input_config_binds[MAX_USERS][RARCH_BIND_LIST_END]; struct retro_keybind input_autoconf_binds[MAX_USERS][RARCH_BIND_LIST_END]; static const struct retro_keybind *libretro_input_binds[MAX_USERS]; @@ -2132,13 +2224,10 @@ const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = { DECLARE_META_BIND(2, ai_service, RARCH_AI_SERVICE, MENU_ENUM_LABEL_VALUE_INPUT_META_AI_SERVICE), }; -static bool input_driver_keyboard_linefeed_enable = false; static input_keyboard_line_t *g_keyboard_line = NULL; static void *g_keyboard_press_data = NULL; -static unsigned osk_last_codepoint = 0; -static unsigned osk_last_codepoint_len = 0; static input_keyboard_press_t g_keyboard_press_cb; @@ -2152,24 +2241,16 @@ static input_remote_t *input_driver_remote = NULL; static input_mapper_t *input_driver_mapper = NULL; static 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_nonblock_state = false; -static unsigned input_driver_flushing_input = 0; -static float input_driver_axis_threshold = 0.0f; -static unsigned input_driver_max_users = 0; #ifdef HAVE_HID static const void *hid_data = NULL; #endif + #if defined(HAVE_RUNAHEAD) -static enum rarch_core_type last_core_type; static retro_ctx_load_content_info_t *load_content_info; #if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB) -static int port_map[16]; - static dylib_t secondary_module; static struct retro_core_t secondary_core; static struct retro_callbacks secondary_callbacks; @@ -2177,12 +2258,6 @@ static char *secondary_library_path = NULL; #endif #endif -#ifdef HAVE_TRANSLATE -static int g_ai_service_auto = 0; -#endif - -static unsigned gamepad_input_override = 0; - /* Forward declarations */ static void retroarch_fail(int error_code, const char *error); static void retroarch_core_options_intl_init(const struct @@ -2203,7 +2278,6 @@ static const void *hid_driver_find_handle(int idx); #ifdef HAVE_ACCESSIBILITY #ifdef HAVE_TRANSLATE static bool is_narrator_running(void); -int ai_gamepad_state[16]; #endif static bool accessibility_startup_message(void); #endif @@ -2227,6 +2301,8 @@ static void rarch_init_core_options( static bool secondary_core_create(void); static int16_t input_state_get_last(unsigned port, unsigned device, unsigned index, unsigned id); +static int16_t input_state(unsigned port, unsigned device, + unsigned idx, unsigned id); static void video_driver_frame(const void *data, unsigned width, unsigned height, size_t pitch); static void retro_frame_null(const void *data, unsigned width, @@ -2269,9 +2345,6 @@ static retro_proc_address_t video_driver_get_proc_address(const char *sym); static uintptr_t video_driver_get_current_framebuffer(void); static bool video_driver_find_driver(void); -static int16_t input_state(unsigned port, unsigned device, - unsigned idx, unsigned id); - static void bsv_movie_deinit(void); static bool bsv_movie_init(void); static bool bsv_movie_check(void); @@ -2296,7 +2369,6 @@ static bool driver_location_start(void); static void driver_camera_stop(void); static bool driver_camera_start(void); - struct string_list *dir_list_new_special(const char *input_dir, enum dir_list_type type, const char *filter, bool show_hidden_files) @@ -24575,7 +24647,7 @@ bool driver_ctl(enum driver_ctl_state state, void *data) /* RUNAHEAD */ #ifdef HAVE_RUNAHEAD -static void mylist_resize(MyList *list, int new_size, bool run_constructor) +static void mylist_resize(my_list *list, int new_size, bool run_constructor) { int i; int new_capacity; @@ -24632,7 +24704,7 @@ static void mylist_resize(MyList *list, int new_size, bool run_constructor) list->size = new_size; } -static void *mylist_add_element(MyList *list) +static void *mylist_add_element(my_list *list) { int old_size; @@ -24644,9 +24716,9 @@ static void *mylist_add_element(MyList *list) return list->data[old_size]; } -static void mylist_destroy(MyList **list_p) +static void mylist_destroy(my_list **list_p) { - MyList *list = NULL; + my_list *list = NULL; if (!list_p) return; @@ -24661,10 +24733,10 @@ static void mylist_destroy(MyList **list_p) } } -static void mylist_create(MyList **list_p, int initial_capacity, +static void mylist_create(my_list **list_p, int initial_capacity, constructor_t constructor, destructor_t destructor) { - MyList *list = NULL; + my_list *list = NULL; if (!list_p) return; @@ -24676,7 +24748,7 @@ static void mylist_create(MyList **list_p, int initial_capacity, if (list) mylist_destroy(list_p); - list = (MyList*)malloc(sizeof(MyList)); + list = (my_list*)malloc(sizeof(my_list)); *list_p = list; list->size = 0; list->constructor = constructor; @@ -28532,18 +28604,18 @@ static enum runloop_state runloop_check_state(retro_time_t current_time) to send off if it's run. */ if (settings->bools.ai_service_enable) { - ai_gamepad_state[0] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_B); - ai_gamepad_state[1] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_Y); - ai_gamepad_state[2] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_SELECT); - ai_gamepad_state[3] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_START); + ai_gamepad_state[0] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_B); + ai_gamepad_state[1] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_Y); + ai_gamepad_state[2] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_SELECT); + ai_gamepad_state[3] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_START); - ai_gamepad_state[4] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_UP); - ai_gamepad_state[5] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_DOWN); - ai_gamepad_state[6] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_LEFT); - ai_gamepad_state[7] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_RIGHT); + ai_gamepad_state[4] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_UP); + ai_gamepad_state[5] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_DOWN); + ai_gamepad_state[6] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_LEFT); + ai_gamepad_state[7] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_RIGHT); - ai_gamepad_state[8] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_A); - ai_gamepad_state[9] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_X); + ai_gamepad_state[8] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_A); + ai_gamepad_state[9] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_X); ai_gamepad_state[10] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_L); ai_gamepad_state[11] = BIT256_GET(current_bits, RETRO_DEVICE_ID_JOYPAD_R); From d1c130d60a61266d7e0973468952cd731a2cb00d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 06:29:58 +0200 Subject: [PATCH 137/192] Global variable cleanups --- retroarch.c | 174 +++++++++++++++++++++++++++------------------------- 1 file changed, 91 insertions(+), 83 deletions(-) diff --git a/retroarch.c b/retroarch.c index 40ef9d7f1c..300a19544a 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1762,6 +1762,22 @@ static bool audio_mixer_active = false; */ static bool deferred_video_context_driver_set_flags = false; +static const uint8_t midi_drv_ev_sizes[128] = +{ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 0, 2, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +}; + +static uint8_t *video_driver_record_gpu_buffer = NULL; +static uint8_t *midi_drv_input_buffer = NULL; +static uint8_t *midi_drv_output_buffer = NULL; + static uint16_t input_config_vid[MAX_USERS] = {0}; static uint16_t input_config_pid[MAX_USERS] = {0}; @@ -1771,16 +1787,15 @@ static int lastcmd_net_fd = 0; #endif #endif +#ifdef HAVE_TRANSLATE +static int g_ai_service_auto = 0; +#endif + #if defined(HAVE_RUNAHEAD) #if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB) static int port_map[16] = {0}; #endif #endif - -#ifdef HAVE_TRANSLATE -static int g_ai_service_auto = 0; -#endif - #if defined(HAVE_ACCESSIBILITY) && defined(HAVE_TRANSLATE) static int ai_gamepad_state[16] = {0}; #endif @@ -1933,18 +1948,49 @@ static char input_device_config_paths [MAX_INPUT_DEVICES][64]; static rarch_timer_t shader_delay_timer = {0}; #endif -static struct string_list *subsystem_fullpaths = NULL; - static struct rarch_dir_list dir_shader_list; #ifdef HAVE_MENU -static const char **menu_input_dialog_keyboard_buffer = {NULL}; - /* Since these are static/global, they are initialised to zero */ static menu_input_pointer_hw_state_t menu_input_pointer_hw_state; static menu_input_t menu_input_state; #endif +static struct retro_camera_callback camera_cb; + +static midi_event_t midi_drv_input_event; +static midi_event_t midi_drv_output_event; + +static gfx_ctx_driver_t current_video_context; + +/** + * dynamic.c:dynamic_request_hw_context will try to set flag data when the context + * is in the middle of being rebuilt; in these cases we will save flag + * data and set this to true. + * When the context is reinit, it checks this, reads from + * deferred_flag_data and cleans it. + * + * TODO - Dirty hack, fix it better + */ +static gfx_ctx_flags_t deferred_flag_data = {0}; + +static struct retro_system_av_info video_driver_av_info; + +static struct bsv_state bsv_movie_state; + +static struct retro_hw_render_callback hw_render; + +typedef bool(*runahead_load_state_function)(const void*, size_t); + +static retro_input_state_t input_state_callback_original; + +#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) +static input_remote_state_t remote_st_ptr; +#endif + + +static struct string_list *subsystem_fullpaths = NULL; + static const record_driver_t *recording_driver = NULL; static void *recording_data = NULL; @@ -1952,7 +1998,10 @@ static void *recording_data = NULL; static slock_t *_runloop_msg_queue_lock = NULL; #endif -static struct retro_camera_callback camera_cb; +#ifdef HAVE_MENU +static const char **menu_input_dialog_keyboard_buffer = {NULL}; +#endif + static const camera_driver_t *camera_driver = NULL; static void *camera_data = NULL; @@ -1960,24 +2009,6 @@ static midi_driver_t *midi_drv = &midi_null; static void *midi_drv_data = NULL; static struct string_list *midi_drv_inputs = NULL; static struct string_list *midi_drv_outputs = NULL; -static midi_event_t midi_drv_input_event; -static midi_event_t midi_drv_output_event; - -static const uint8_t midi_drv_ev_sizes[128] = -{ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 0, 2, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 -}; - -static uint8_t *video_driver_record_gpu_buffer = NULL; -static uint8_t *midi_drv_input_buffer = NULL; -static uint8_t *midi_drv_output_buffer = NULL; static const ui_companion_driver_t *ui_companion = NULL; static void *ui_companion_data = NULL; @@ -1996,7 +2027,6 @@ static const video_display_server_t *current_display_server = &dispserv_null static void *current_display_server_data = NULL; static bsv_movie_t *bsv_movie_state_handle = NULL; -static struct bsv_state bsv_movie_state; struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { { "4:3", 1.3333f }, @@ -2047,8 +2077,6 @@ static const video_poke_interface_t *video_driver_poke = NULL; * being passed to video driver. */ static video_pixel_scaler_t *video_driver_scaler_ptr = NULL; -static struct retro_hw_render_callback hw_render; - static const struct retro_hw_render_context_negotiation_interface * hw_render_context_negotiation = NULL; @@ -2062,21 +2090,6 @@ static slock_t *context_lock = NULL; static void *video_context_data = NULL; -static gfx_ctx_driver_t current_video_context; - -/** - * dynamic.c:dynamic_request_hw_context will try to set flag data when the context - * is in the middle of being rebuilt; in these cases we will save flag - * data and set this to true. - * When the context is reinit, it checks this, reads from - * deferred_flag_data and cleans it. - * - * TODO - Dirty hack, fix it better - */ -static gfx_ctx_flags_t deferred_flag_data = {0}; - -static struct retro_system_av_info video_driver_av_info; - #ifdef HAVE_AUDIOMIXER static struct audio_mixer_stream audio_mixer_streams[AUDIO_MIXER_MAX_SYSTEM_STREAMS] = {{0}}; @@ -2099,16 +2112,42 @@ static void *audio_driver_context_audio_data = NULL; static my_list *runahead_save_state_list = NULL; static my_list *input_state_list = NULL; -typedef bool(*runahead_load_state_function)(const void*, size_t); - -static retro_input_state_t input_state_callback_original; static function_t retro_reset_callback_original = NULL; static runahead_load_state_function retro_unserialize_callback_original = NULL; static function_t original_retro_deinit = NULL; static function_t original_retro_unload = NULL; +#endif +#ifdef HAVE_OVERLAY +static input_overlay_t *overlay_ptr = NULL; +#endif + +static pad_connection_listener_t *pad_connection_listener = NULL; + +static input_keyboard_line_t *g_keyboard_line = NULL; + +static void *g_keyboard_press_data = NULL; + +#ifdef HAVE_COMMAND +static command_t *input_driver_command = NULL; +#endif +#ifdef HAVE_NETWORKGAMEPAD +static input_remote_t *input_driver_remote = NULL; +#endif +static input_mapper_t *input_driver_mapper = NULL; +static input_driver_t *current_input = NULL; +static void *current_input_data = NULL; + +#ifdef HAVE_HID +static const void *hid_data = NULL; +#endif + +#if defined(HAVE_RUNAHEAD) +#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB) +static char *secondary_library_path = NULL; +#endif #endif #if defined(HAVE_COMMAND) @@ -2118,19 +2157,8 @@ static socklen_t lastcmd_net_source_len; #endif #endif - -#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) -static input_remote_state_t remote_st_ptr; -#endif - -#ifdef HAVE_OVERLAY -static input_overlay_t *overlay_ptr = NULL; -#endif - -static pad_connection_listener_t *pad_connection_listener = NULL; - +/* TODO/FIXME - turn these into static global variable */ char input_device_names [MAX_INPUT_DEVICES][64]; - struct retro_keybind input_config_binds[MAX_USERS][RARCH_BIND_LIST_END]; struct retro_keybind input_autoconf_binds[MAX_USERS][RARCH_BIND_LIST_END]; static const struct retro_keybind *libretro_input_binds[MAX_USERS]; @@ -2162,7 +2190,7 @@ const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = { DECLARE_BIND(r_y_minus, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS), DECLARE_BIND( gun_trigger, RARCH_LIGHTGUN_TRIGGER, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER ), - DECLARE_BIND( gun_offscreen_shot, RARCH_LIGHTGUN_RELOAD, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD ), + DECLARE_BIND( gun_offscreen_shot,RARCH_LIGHTGUN_RELOAD, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD ), DECLARE_BIND( gun_aux_a, RARCH_LIGHTGUN_AUX_A, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A ), DECLARE_BIND( gun_aux_b, RARCH_LIGHTGUN_AUX_B, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B ), DECLARE_BIND( gun_aux_c, RARCH_LIGHTGUN_AUX_C, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C ), @@ -2173,7 +2201,7 @@ const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = { DECLARE_BIND( gun_dpad_left, RARCH_LIGHTGUN_DPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT ), DECLARE_BIND( gun_dpad_right, RARCH_LIGHTGUN_DPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT ), - DECLARE_BIND(turbo, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE), + DECLARE_BIND( turbo, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE), DECLARE_META_BIND(1, toggle_fast_forward, RARCH_FAST_FORWARD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY), DECLARE_META_BIND(2, hold_fast_forward, RARCH_FAST_FORWARD_HOLD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_HOLD_KEY), @@ -2224,28 +2252,9 @@ const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = { DECLARE_META_BIND(2, ai_service, RARCH_AI_SERVICE, MENU_ENUM_LABEL_VALUE_INPUT_META_AI_SERVICE), }; -static input_keyboard_line_t *g_keyboard_line = NULL; - -static void *g_keyboard_press_data = NULL; - - static input_keyboard_press_t g_keyboard_press_cb; static turbo_buttons_t input_driver_turbo_btns; -#ifdef HAVE_COMMAND -static command_t *input_driver_command = NULL; -#endif -#ifdef HAVE_NETWORKGAMEPAD -static input_remote_t *input_driver_remote = NULL; -#endif -static input_mapper_t *input_driver_mapper = NULL; -static input_driver_t *current_input = NULL; -static void *current_input_data = NULL; - -#ifdef HAVE_HID -static const void *hid_data = NULL; -#endif - #if defined(HAVE_RUNAHEAD) static retro_ctx_load_content_info_t *load_content_info; @@ -2254,7 +2263,6 @@ static retro_ctx_load_content_info_t *load_content_info; static dylib_t secondary_module; static struct retro_core_t secondary_core; static struct retro_callbacks secondary_callbacks; -static char *secondary_library_path = NULL; #endif #endif From 0bbd5b7a45d1e38babe363d25079b14aa0a88007 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Wed, 20 May 2020 11:48:09 +0100 Subject: [PATCH 138/192] (Input Remapping) Fix 'reset to default' action for analog sticks and undefined core inputs --- menu/cbs/menu_cbs_start.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index cc62e57dfd..d7fce732cb 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -145,22 +145,30 @@ static int action_start_input_desc( const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - settings_t *settings = config_get_ptr(); - unsigned inp_desc_index_offset = type - MENU_SETTINGS_INPUT_DESC_BEGIN; - unsigned inp_desc_user = inp_desc_index_offset / (RARCH_FIRST_CUSTOM_BIND + 4); - unsigned inp_desc_button_index_offset = inp_desc_index_offset - (inp_desc_user * (RARCH_FIRST_CUSTOM_BIND + 4)); + settings_t *settings = config_get_ptr(); + rarch_system_info_t *system = runloop_get_system_info(); + unsigned user_idx; + unsigned btn_idx; (void)label; - if (inp_desc_button_index_offset < RARCH_FIRST_CUSTOM_BIND) + if (!settings || !system) + return 0; + + user_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8); + btn_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) - (RARCH_FIRST_CUSTOM_BIND + 8) * user_idx; + + if ((user_idx >= MAX_USERS) || (btn_idx >= RARCH_CUSTOM_BIND_LIST_END)) + return 0; + + /* Check whether core has defined this input */ + if (!string_is_empty(system->input_desc_btn[user_idx][btn_idx])) { - const struct retro_keybind *keyptr = &input_config_binds[inp_desc_user] - [inp_desc_button_index_offset]; - settings->uints.input_remap_ids[inp_desc_user][inp_desc_button_index_offset] = keyptr->id; + const struct retro_keybind *keyptr = &input_config_binds[user_idx][btn_idx]; + settings->uints.input_remap_ids[user_idx][btn_idx] = keyptr->id; } else - settings->uints.input_remap_ids[inp_desc_user][inp_desc_button_index_offset] = - inp_desc_button_index_offset - RARCH_FIRST_CUSTOM_BIND; + settings->uints.input_remap_ids[user_idx][btn_idx] = RARCH_UNMAPPED; return 0; } From 5874bb8b27207f9b8a5d50bb773756d7c6f8a7fe Mon Sep 17 00:00:00 2001 From: Autechre Date: Wed, 20 May 2020 14:02:41 +0200 Subject: [PATCH 139/192] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 6f18509806..8529756edd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ - CHEEVOS: Disable hardcore when cheats are enabled - CHD: Return false when special track cannot be found - INPUT MAPPING/REMAPPING: Restore broken 'reset to default' functionality with RetroPad 'start' button +- INPUT MAPPING/REMAPPING: Fix 'reset to default' action for analog sticks and undefined core inputs - MENU/THUMBNAILS/BUGFIX: Fix heap-use-after-free error - OVERLAYS: Fix memory leak when loading overlays - WIIU: Gamepad hotplugging support From d9ccd3a7378b68cedbd1c58aa593ba80bd70d495 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 14:23:05 +0200 Subject: [PATCH 140/192] Turn core_poll_type_override into enum variable --- retroarch.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/retroarch.c b/retroarch.c index 300a19544a..dff3534108 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1335,6 +1335,14 @@ enum cmd_source_t CMD_NETWORK }; +enum poll_type_t +{ + POLL_TYPE_OVERRIDE_DONTCARE = 0, + POLL_TYPE_OVERRIDE_EARLY, + POLL_TYPE_OVERRIDE_NORMAL, + POLL_TYPE_OVERRIDE_LATE +}; + typedef struct runloop_ctx_msg_info { const char *msg; @@ -1580,6 +1588,8 @@ static enum rarch_core_type last_core_type; static enum overlay_visibility *visibility = NULL; #endif +static enum poll_type_t core_poll_type_override = POLL_TYPE_OVERRIDE_DONTCARE; + #ifdef HAVE_THREAD_STORAGE static sthread_tls_t rarch_tls; const void *MAGIC_POINTER = (void*)(uintptr_t)0x0DEFACED; @@ -1819,16 +1829,6 @@ static size_t audio_driver_data_ptr = 0; static size_t runahead_save_state_size = 0; #endif -/* - * Override poll type behavior, is set by the core. - * - * 0 - Don't Care - * 1 - Early - * 2 - Normal - * 3 - Late - */ -static unsigned core_poll_type_override = 0; - static unsigned runloop_pending_windowed_scale = 0; static unsigned runloop_max_frames = 0; static unsigned fastforward_after_frames = 0; @@ -11207,7 +11207,7 @@ static bool rarch_environment_cb(unsigned cmd, void *data) const unsigned *poll_type_data = (const unsigned*)data; if (poll_type_data) - core_poll_type_override = *poll_type_data; + core_poll_type_override = (enum poll_type_t)*poll_type_data; } break; @@ -11700,7 +11700,7 @@ static void secondary_core_destroy(void) /* unload game from core */ if (secondary_core.retro_unload_game) secondary_core.retro_unload_game(); - core_poll_type_override = 0; + core_poll_type_override = POLL_TYPE_OVERRIDE_DONTCARE; /* deinit */ if (secondary_core.retro_deinit) @@ -25045,7 +25045,7 @@ static void unload_hook(void) secondary_core_destroy(); if (current_core.retro_unload_game) current_core.retro_unload_game(); - core_poll_type_override = 0; + core_poll_type_override = POLL_TYPE_OVERRIDE_DONTCARE; } static void runahead_deinit_hook(void) @@ -29313,7 +29313,7 @@ static int16_t core_input_state_poll_late(unsigned port, static retro_input_state_t core_input_state_poll_return_cb(void) { - unsigned new_poll_type = (core_poll_type_override > 0) + unsigned new_poll_type = (core_poll_type_override > POLL_TYPE_OVERRIDE_DONTCARE) ? (core_poll_type_override - 1) : current_core.poll_type; if (new_poll_type == POLL_TYPE_LATE) @@ -29323,7 +29323,7 @@ static retro_input_state_t core_input_state_poll_return_cb(void) static void core_input_state_poll_maybe(void) { - unsigned new_poll_type = (core_poll_type_override > 0) + unsigned new_poll_type = (core_poll_type_override > POLL_TYPE_OVERRIDE_DONTCARE) ? (core_poll_type_override - 1) : current_core.poll_type; if (new_poll_type == POLL_TYPE_NORMAL) @@ -29566,7 +29566,7 @@ static bool core_unload_game(void) if (current_core.game_loaded) { current_core.retro_unload_game(); - core_poll_type_override = 0; + core_poll_type_override = POLL_TYPE_OVERRIDE_DONTCARE; current_core.game_loaded = false; } @@ -29577,7 +29577,7 @@ static bool core_unload_game(void) bool core_run(void) { - unsigned new_poll_type = (core_poll_type_override != 0) + unsigned new_poll_type = (core_poll_type_override != POLL_TYPE_OVERRIDE_DONTCARE) ? (core_poll_type_override - 1) : current_core.poll_type; bool early_polling = new_poll_type == POLL_TYPE_EARLY; From cb5de276318506572b04d01444ba697aca1cc20f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 14:48:22 +0200 Subject: [PATCH 141/192] Cleanup --- retroarch.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/retroarch.c b/retroarch.c index dff3534108..32e62c7a09 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1335,7 +1335,7 @@ enum cmd_source_t CMD_NETWORK }; -enum poll_type_t +enum poll_type_override_t { POLL_TYPE_OVERRIDE_DONTCARE = 0, POLL_TYPE_OVERRIDE_EARLY, @@ -1588,7 +1588,8 @@ static enum rarch_core_type last_core_type; static enum overlay_visibility *visibility = NULL; #endif -static enum poll_type_t core_poll_type_override = POLL_TYPE_OVERRIDE_DONTCARE; +/* Override poll type behavior, is set by the core */ +static enum poll_type_override_t core_poll_type_override = POLL_TYPE_OVERRIDE_DONTCARE; #ifdef HAVE_THREAD_STORAGE static sthread_tls_t rarch_tls; @@ -11207,7 +11208,7 @@ static bool rarch_environment_cb(unsigned cmd, void *data) const unsigned *poll_type_data = (const unsigned*)data; if (poll_type_data) - core_poll_type_override = (enum poll_type_t)*poll_type_data; + core_poll_type_override = (enum poll_type_override_t)*poll_type_data; } break; From a8fdfd77ce8eaa7b64ae6ef9aa6d3d2a54dfe100 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 15:04:16 +0200 Subject: [PATCH 142/192] Make gamma correction 'int' type across the board --- gfx/drivers/d3d9.c | 4 ++-- retroarch.c | 10 ---------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/gfx/drivers/d3d9.c b/gfx/drivers/d3d9.c index 044bcacf32..f3ec05f997 100644 --- a/gfx/drivers/d3d9.c +++ b/gfx/drivers/d3d9.c @@ -645,8 +645,8 @@ void d3d9_make_d3dpp(void *data, #ifdef _XBOX /* TODO/FIXME - get rid of global state dependencies. */ global_t *global = global_get_ptr(); - bool gamma_enable = global ? - global->console.screen.gamma_correction : false; + int gamma_enable = global ? + global->console.screen.gamma_correction : 0; #endif bool windowed_enable = d3d9_is_windowed_enable(info->fullscreen); diff --git a/retroarch.c b/retroarch.c index 32e62c7a09..1e23d0137f 100644 --- a/retroarch.c +++ b/retroarch.c @@ -22411,13 +22411,8 @@ void video_driver_load_settings(config_file_t *conf) if (!conf) return; -#ifdef _XBOX - CONFIG_GET_BOOL_BASE(conf, global, - console.screen.gamma_correction, "gamma_correction"); -#else CONFIG_GET_INT_BASE(conf, global, console.screen.gamma_correction, "gamma_correction"); -#endif if (config_get_bool(conf, "flicker_filter_enable", &tmp_bool)) @@ -22444,13 +22439,8 @@ void video_driver_save_settings(config_file_t *conf) if (!conf) return; -#ifdef _XBOX - config_set_bool(conf, "gamma_correction", - global->console.screen.gamma_correction); -#else config_set_int(conf, "gamma_correction", global->console.screen.gamma_correction); -#endif config_set_bool(conf, "flicker_filter_enable", global->console.flickerfilter_enable); config_set_bool(conf, "soft_filter_enable", From 03ea12d33401901440587107c9bba58d02eae9ef Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 15:27:27 +0200 Subject: [PATCH 143/192] Move discord files to network/ --- Makefile.common | 5 +++-- cheevos-new/cheevos.c | 2 +- griffin/griffin.c | 2 +- menu/cbs/menu_cbs_ok.c | 2 +- {discord => network}/discord.c | 10 +++++----- {discord => network}/discord.h | 0 network/netplay/netplay_frontend.c | 2 +- network/netplay/netplay_io.c | 4 +++- retroarch.c | 2 +- tasks/task_content.c | 3 ++- 10 files changed, 18 insertions(+), 14 deletions(-) rename {discord => network}/discord.c (98%) rename {discord => network}/discord.h (100%) diff --git a/Makefile.common b/Makefile.common index 981d5134d9..89f07121c3 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1914,7 +1914,8 @@ ifeq ($(HAVE_NETWORKING), 1) ifeq ($(HAVE_DISCORD), 1) NEED_CXX_LINKER = 1 DEFINES += -DHAVE_DISCORD - INCLUDE_DIRS += -Ideps/discord-rpc/include/ -Ideps/discord-rpc/thirdparty/rapidjson-1.1.0/include/ + INCLUDE_DIRS += -Ideps/discord-rpc/include \ + -Ideps/discord-rpc/thirdparty/rapidjson-1.1.0/include/ ifneq ($(HAVE_THREADS), 1) DEFINES += -DDISCORD_DISABLE_IO_THREAD @@ -1923,7 +1924,7 @@ ifeq ($(HAVE_NETWORKING), 1) OBJ += deps/discord-rpc/src/discord_rpc.o \ deps/discord-rpc/src/rpc_connection.o \ deps/discord-rpc/src/serialization.o \ - discord/discord.o + network/discord.o ifneq ($(findstring Win32,$(OS)),) OBJ += deps/discord-rpc/src/discord_register_win.o \ diff --git a/cheevos-new/cheevos.c b/cheevos-new/cheevos.c index 0b5d7d836f..7c5f0c9982 100644 --- a/cheevos-new/cheevos.c +++ b/cheevos-new/cheevos.c @@ -47,7 +47,7 @@ #endif #ifdef HAVE_DISCORD -#include "../discord/discord.h" +#include "../network/discord.h" #endif #include "badges.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index 2464aa23ad..b7e28112a1 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -1495,7 +1495,7 @@ XML HTTP SERVER ============================================================ */ #if defined(HAVE_DISCORD) -#include "../discord/discord.c" +#include "../network/discord.c" #if defined(_WIN32) #include "../deps/discord-rpc/src/discord_register_win.c" diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 180ceeace8..8ddc5b1713 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -32,7 +32,7 @@ #endif #ifdef HAVE_DISCORD -#include "../../discord/discord.h" +#include "../../network/discord.h" #endif #include "../../config.def.h" diff --git a/discord/discord.c b/network/discord.c similarity index 98% rename from discord/discord.c rename to network/discord.c index 45e387370a..66a839f7ef 100644 --- a/discord/discord.c +++ b/network/discord.c @@ -38,9 +38,9 @@ #include "../tasks/task_file_transfer.h" #ifdef HAVE_NETWORKING -#include "../../network/netplay/netplay.h" -#include "../../network/netplay/netplay_discovery.h" -#include "../../tasks/tasks_internal.h" +#include "netplay/netplay.h" +#include "netplay/netplay_discovery.h" +#include "../tasks/tasks_internal.h" #endif #ifdef HAVE_CHEEVOS @@ -48,10 +48,10 @@ #endif #ifdef HAVE_MENU -#include "../../menu/menu_cbs.h" +#include "../menu/menu_cbs.h" #endif -#include "../network/net_http_special.h" +#include "net_http_special.h" #include "../tasks/tasks_internal.h" #include "../file_path_special.h" diff --git a/discord/discord.h b/network/discord.h similarity index 100% rename from discord/discord.h rename to network/discord.h diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c index 9ece3fb050..a9aa3d6537 100644 --- a/network/netplay/netplay_frontend.c +++ b/network/netplay/netplay_frontend.c @@ -27,7 +27,7 @@ #include #ifdef HAVE_DISCORD -#include +#include "../discord.h" #endif #include diff --git a/network/netplay/netplay_io.c b/network/netplay/netplay_io.c index 526d5cd4e6..cfa847c1bc 100644 --- a/network/netplay/netplay_io.c +++ b/network/netplay/netplay_io.c @@ -29,10 +29,12 @@ #include "../../command.h" #include "../../tasks/tasks_internal.h" -#include "../../discord/discord.h" +#ifdef HAVE_DISCORD +#include "../discord.h" /* TODO/FIXME - global */ extern bool discord_is_inited; +#endif static void handle_play_spectate(netplay_t *netplay, uint32_t client_num, struct netplay_connection *connection, uint32_t cmd, uint32_t cmd_size, diff --git a/retroarch.c b/retroarch.c index 1e23d0137f..c2fc88a21e 100644 --- a/retroarch.c +++ b/retroarch.c @@ -167,7 +167,7 @@ #endif #ifdef HAVE_DISCORD -#include "discord/discord.h" +#include "network/discord.h" #endif #ifdef HAVE_NETWORKING diff --git a/tasks/task_content.c b/tasks/task_content.c index 077de9aa74..13ef8d75fc 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -108,8 +108,9 @@ #include "../paths.h" #include "../verbosity.h" -#include "../discord/discord.h" +#include "../network/discord.h" +/* TODO/FIXME - get rid of this public global */ extern bool discord_is_inited; #define MAX_ARGS 32 From 3387170d6281f97fedc467555bdeb0e5d0408592 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 15:43:01 +0200 Subject: [PATCH 144/192] (Discord) Cleanups - get rid of discord_register.h header --- deps/discord-rpc/include/discord_register.h | 14 -- deps/discord-rpc/include/discord_rpc.h | 6 +- deps/discord-rpc/src/backoff.h | 55 +++---- deps/discord-rpc/src/connection.h | 19 +-- deps/discord-rpc/src/discord_register_linux.c | 10 +- deps/discord-rpc/src/discord_register_osx.m | 76 +++++---- deps/discord-rpc/src/discord_register_win.c | 150 +++++++++--------- deps/discord-rpc/src/discord_rpc.cpp | 13 +- network/discord.c | 13 +- 9 files changed, 180 insertions(+), 176 deletions(-) delete mode 100644 deps/discord-rpc/include/discord_register.h diff --git a/deps/discord-rpc/include/discord_register.h b/deps/discord-rpc/include/discord_register.h deleted file mode 100644 index 3bd96b1f48..0000000000 --- a/deps/discord-rpc/include/discord_register.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#define DISCORD_EXPORT - -#ifdef __cplusplus -extern "C" { -#endif - -DISCORD_EXPORT void Discord_Register(const char* applicationId, const char* command); -DISCORD_EXPORT void Discord_RegisterSteamGame(const char* applicationId, const char* steamId); - -#ifdef __cplusplus -} -#endif diff --git a/deps/discord-rpc/include/discord_rpc.h b/deps/discord-rpc/include/discord_rpc.h index 05c562911f..f66eca87f1 100644 --- a/deps/discord-rpc/include/discord_rpc.h +++ b/deps/discord-rpc/include/discord_rpc.h @@ -53,9 +53,9 @@ typedef struct DiscordEventHandlers #define DISCORD_REPLY_IGNORE 2 DISCORD_EXPORT void Discord_Initialize(const char* applicationId, - DiscordEventHandlers* handlers, - int autoRegister, - const char* optionalSteamId); + DiscordEventHandlers* handlers, + int autoRegister, + const char* optionalSteamId); DISCORD_EXPORT void Discord_Shutdown(void); /* checks for incoming messages, dispatches callbacks */ diff --git a/deps/discord-rpc/src/backoff.h b/deps/discord-rpc/src/backoff.h index a3e736fb7b..db89a50893 100644 --- a/deps/discord-rpc/src/backoff.h +++ b/deps/discord-rpc/src/backoff.h @@ -5,36 +5,37 @@ #include #include -struct Backoff { - int64_t minAmount; - int64_t maxAmount; - int64_t current; - int fails; - std::mt19937_64 randGenerator; - std::uniform_real_distribution<> randDistribution; +struct Backoff +{ + int64_t minAmount; + int64_t maxAmount; + int64_t current; + int fails; + std::mt19937_64 randGenerator; + std::uniform_real_distribution<> randDistribution; - double rand01() { return randDistribution(randGenerator); } + double rand01() { return randDistribution(randGenerator); } - Backoff(int64_t min, int64_t max) + Backoff(int64_t min, int64_t max) : minAmount(min) - , maxAmount(max) - , current(min) - , fails(0) - , randGenerator((uint64_t)time(0)) - { - } + , maxAmount(max) + , current(min) + , fails(0) + , randGenerator((uint64_t)time(0)) + { + } - void reset() - { - fails = 0; - current = minAmount; - } + void reset() + { + fails = 0; + current = minAmount; + } - int64_t nextDelay() - { - ++fails; - int64_t delay = (int64_t)((double)current * 2.0 * rand01()); - current = std::min(current + delay, maxAmount); - return current; - } + int64_t nextDelay() + { + ++fails; + int64_t delay = (int64_t)((double)current * 2.0 * rand01()); + current = std::min(current + delay, maxAmount); + return current; + } }; diff --git a/deps/discord-rpc/src/connection.h b/deps/discord-rpc/src/connection.h index d3fa231d5e..4502fa2dd4 100644 --- a/deps/discord-rpc/src/connection.h +++ b/deps/discord-rpc/src/connection.h @@ -6,14 +6,15 @@ #include /* not really connectiony, but need per-platform */ -int GetProcessId(); +int GetProcessId(void); -struct BaseConnection { - static BaseConnection* Create(); - static void Destroy(BaseConnection*&); - bool isOpen{false}; - bool Open(); - bool Close(); - bool Write(const void* data, size_t length); - bool Read(void* data, size_t length); +struct BaseConnection +{ + static BaseConnection* Create(); + static void Destroy(BaseConnection*&); + bool isOpen{false}; + bool Open(); + bool Close(); + bool Write(const void* data, size_t length); + bool Read(void* data, size_t length); }; diff --git a/deps/discord-rpc/src/discord_register_linux.c b/deps/discord-rpc/src/discord_register_linux.c index 8eec618cb3..7fc42ebd0d 100644 --- a/deps/discord-rpc/src/discord_register_linux.c +++ b/deps/discord-rpc/src/discord_register_linux.c @@ -1,5 +1,3 @@ -#include "discord_rpc.h" -#include "discord_register.h" #include #include @@ -13,9 +11,11 @@ #include #include +#include + /* we want to register games so we can run them from * Discord client as discord-:// */ -void Discord_Register(const char* applicationId, const char* command) +void Discord_Register(const char *applicationId, const char *command) { FILE* fp; int fileLen; @@ -82,9 +82,7 @@ void Discord_Register(const char* applicationId, const char* command) fprintf(stderr, "Failed to register mime handler\n"); } -void Discord_RegisterSteamGame( - const char* applicationId, - const char* steamId) +void Discord_RegisterSteamGame(const char *applicationId, const char *steamId) { char command[256]; snprintf(command, sizeof(command), "xdg-open steam://rungameid/%s", steamId); diff --git a/deps/discord-rpc/src/discord_register_osx.m b/deps/discord-rpc/src/discord_register_osx.m index 4975565296..0973e15108 100644 --- a/deps/discord-rpc/src/discord_register_osx.m +++ b/deps/discord-rpc/src/discord_register_osx.m @@ -3,8 +3,6 @@ #import -#include "../include/discord_register.h" - static void RegisterCommand(const char* applicationId, const char* command) { /* There does not appear to be a way to register arbitrary commands on OSX, so instead we'll save the command @@ -31,54 +29,52 @@ static void RegisterCommand(const char* applicationId, const char* command) static void RegisterURL(const char* applicationId) { - char url[256]; - snprintf(url, sizeof(url), "discord-%s", applicationId); - CFStringRef cfURL = CFStringCreateWithCString(NULL, url, kCFStringEncodingUTF8); - NSString* myBundleId = [[NSBundle mainBundle] bundleIdentifier]; + char url[256]; + snprintf(url, sizeof(url), "discord-%s", applicationId); + CFStringRef cfURL = CFStringCreateWithCString(NULL, url, kCFStringEncodingUTF8); + NSString* myBundleId = [[NSBundle mainBundle] bundleIdentifier]; - if (!myBundleId) - { - fprintf(stderr, "No bundle id found\n"); - return; - } + if (!myBundleId) + { + fprintf(stderr, "No bundle id found\n"); + return; + } - NSURL* myURL = [[NSBundle mainBundle] bundleURL]; - if (!myURL) - { - fprintf(stderr, "No bundle url found\n"); - return; - } + NSURL* myURL = [[NSBundle mainBundle] bundleURL]; + if (!myURL) + { + fprintf(stderr, "No bundle url found\n"); + return; + } - OSStatus status = LSSetDefaultHandlerForURLScheme(cfURL, (__bridge CFStringRef)myBundleId); - if (status != noErr) - { - fprintf(stderr, "Error in LSSetDefaultHandlerForURLScheme: %d\n", (int)status); - return; - } + OSStatus status = LSSetDefaultHandlerForURLScheme(cfURL, (__bridge CFStringRef)myBundleId); + if (status != noErr) + { + fprintf(stderr, "Error in LSSetDefaultHandlerForURLScheme: %d\n", (int)status); + return; + } - status = LSRegisterURL((__bridge CFURLRef)myURL, true); - if (status != noErr) - { - fprintf(stderr, "Error in LSRegisterURL: %d\n", (int)status); - } + status = LSRegisterURL((__bridge CFURLRef)myURL, true); + if (status != noErr) + fprintf(stderr, "Error in LSRegisterURL: %d\n", (int)status); } void Discord_Register(const char* applicationId, const char* command) { - if (command) - RegisterCommand(applicationId, command); - else - { - /* RAII Lite */ - @autoreleasepool { - RegisterURL(applicationId); - } - } + if (command) + RegisterCommand(applicationId, command); + else + { + /* RAII Lite */ + @autoreleasepool { + RegisterURL(applicationId); + } + } } void Discord_RegisterSteamGame(const char* applicationId, const char* steamId) { - char command[256]; - snprintf(command, sizeof(command), "steam://rungameid/%s", steamId); - Discord_Register(applicationId, command); + char command[256]; + snprintf(command, sizeof(command), "steam://rungameid/%s", steamId); + Discord_Register(applicationId, command); } diff --git a/deps/discord-rpc/src/discord_register_win.c b/deps/discord-rpc/src/discord_register_win.c index 1a03603b80..992ff58ce3 100644 --- a/deps/discord-rpc/src/discord_register_win.c +++ b/deps/discord-rpc/src/discord_register_win.c @@ -1,5 +1,4 @@ #include "discord_rpc.h" -#include "discord_register.h" #define WIN32_LEAN_AND_MEAN #define NOMCX @@ -53,99 +52,99 @@ static LSTATUS regset(HKEY hkey, const void* data, DWORD len) { - HKEY htkey = hkey, hsubkey = NULL; - LSTATUS ret; - if (subkey && subkey[0]) - { - if ((ret = RegCreateKeyExW(hkey, subkey, 0, 0, 0, KEY_ALL_ACCESS, 0, &hsubkey, 0)) != + LSTATUS ret; + HKEY htkey = hkey, hsubkey = NULL; + if (subkey && subkey[0]) + { + if ((ret = RegCreateKeyExW(hkey, subkey, 0, 0, 0, KEY_ALL_ACCESS, 0, &hsubkey, 0)) != ERROR_SUCCESS) - return ret; - htkey = hsubkey; - } - ret = RegSetValueExW(htkey, name, 0, type, (const BYTE*)data, len); - if (hsubkey && hsubkey != hkey) - RegCloseKey(hsubkey); - return ret; + return ret; + htkey = hsubkey; + } + ret = RegSetValueExW(htkey, name, 0, type, (const BYTE*)data, len); + if (hsubkey && hsubkey != hkey) + RegCloseKey(hsubkey); + return ret; } static void Discord_RegisterW( const wchar_t* applicationId, const wchar_t* command) { - /* https://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx - * we want to register games so we can run them as discord-:// - * Update the HKEY_CURRENT_USER, because it doesn't seem to require special permissions. */ + /* https://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx + * we want to register games so we can run them as discord-:// + * Update the HKEY_CURRENT_USER, because it doesn't seem to require special permissions. */ - DWORD len; - LSTATUS result; - wchar_t urlProtocol = 0; - wchar_t keyName[256]; - wchar_t protocolName[64]; - wchar_t protocolDescription[128]; - wchar_t exeFilePath[MAX_PATH]; - DWORD exeLen = GetModuleFileNameW(NULL, exeFilePath, MAX_PATH); - wchar_t openCommand[1024]; + DWORD len; + LSTATUS result; + wchar_t urlProtocol = 0; + wchar_t keyName[256]; + wchar_t protocolName[64]; + wchar_t protocolDescription[128]; + wchar_t exeFilePath[MAX_PATH]; + DWORD exeLen = GetModuleFileNameW(NULL, exeFilePath, MAX_PATH); + wchar_t openCommand[1024]; - if (command && command[0]) - StringCbPrintfW(openCommand, sizeof(openCommand), L"%S", command); - else - StringCbPrintfW(openCommand, sizeof(openCommand), L"%S", exeFilePath); + if (command && command[0]) + StringCbPrintfW(openCommand, sizeof(openCommand), L"%S", command); + else + StringCbPrintfW(openCommand, sizeof(openCommand), L"%S", exeFilePath); - StringCbPrintfW(protocolName, sizeof(protocolName), - L"discord-%S", applicationId); - StringCbPrintfW( - protocolDescription, sizeof(protocolDescription), - L"URL:Run game %S protocol", applicationId); - StringCbPrintfW(keyName, sizeof(keyName), L"Software\\Classes\\%S", protocolName); - HKEY key; - LSTATUS status = + StringCbPrintfW(protocolName, sizeof(protocolName), + L"discord-%S", applicationId); + StringCbPrintfW( + protocolDescription, sizeof(protocolDescription), + L"URL:Run game %S protocol", applicationId); + StringCbPrintfW(keyName, sizeof(keyName), L"Software\\Classes\\%S", protocolName); + HKEY key; + LSTATUS status = RegCreateKeyExW(HKEY_CURRENT_USER, keyName, 0, NULL, 0, KEY_WRITE, NULL, &key, NULL); - if (status != ERROR_SUCCESS) - { - fprintf(stderr, "Error creating key\n"); - return; - } - len = (DWORD)lstrlenW(protocolDescription) + 1; - result = + if (status != ERROR_SUCCESS) + { + fprintf(stderr, "Error creating key\n"); + return; + } + len = (DWORD)lstrlenW(protocolDescription) + 1; + result = RegSetKeyValueW(key, NULL, NULL, REG_SZ, protocolDescription, len * sizeof(wchar_t)); - if (FAILED(result)) { - fprintf(stderr, "Error writing description\n"); - } + if (FAILED(result)) + fprintf(stderr, "Error writing description\n"); - len = (DWORD)lstrlenW(protocolDescription) + 1; - result = RegSetKeyValueW(key, NULL, L"URL Protocol", REG_SZ, &urlProtocol, sizeof(wchar_t)); - if (FAILED(result)) - fprintf(stderr, "Error writing description\n"); + len = (DWORD)lstrlenW(protocolDescription) + 1; + result = RegSetKeyValueW(key, NULL, L"URL Protocol", REG_SZ, &urlProtocol, sizeof(wchar_t)); + if (FAILED(result)) + fprintf(stderr, "Error writing description\n"); - result = RegSetKeyValueW( - key, L"DefaultIcon", NULL, REG_SZ, exeFilePath, (exeLen + 1) * sizeof(wchar_t)); - if (FAILED(result)) - fprintf(stderr, "Error writing icon\n"); + result = RegSetKeyValueW( + key, L"DefaultIcon", NULL, REG_SZ, exeFilePath, (exeLen + 1) * sizeof(wchar_t)); + if (FAILED(result)) + fprintf(stderr, "Error writing icon\n"); - len = (DWORD)lstrlenW(openCommand) + 1; - result = RegSetKeyValueW( - key, L"shell\\open\\command", NULL, REG_SZ, openCommand, len * sizeof(wchar_t)); - if (FAILED(result)) - fprintf(stderr, "Error writing command\n"); - RegCloseKey(key); + len = (DWORD)lstrlenW(openCommand) + 1; + result = RegSetKeyValueW( + key, L"shell\\open\\command", NULL, REG_SZ, openCommand, len * sizeof(wchar_t)); + if (FAILED(result)) + fprintf(stderr, "Error writing command\n"); + RegCloseKey(key); } void Discord_Register(const char* applicationId, const char* command) { - wchar_t openCommand[1024]; - const wchar_t* wcommand = NULL; - wchar_t appId[32]; + wchar_t appId[32]; + wchar_t openCommand[1024]; + const wchar_t* wcommand = NULL; - MultiByteToWideChar(CP_UTF8, 0, applicationId, -1, appId, 32); - if (command && command[0]) - { - const int commandBufferLen = - sizeof(openCommand) / sizeof(*openCommand); - MultiByteToWideChar(CP_UTF8, 0, command, -1, - openCommand, commandBufferLen); - wcommand = openCommand; - } + MultiByteToWideChar(CP_UTF8, 0, applicationId, -1, appId, 32); - Discord_RegisterW(appId, wcommand); + if (command && command[0]) + { + const int commandBufferLen = + sizeof(openCommand) / sizeof(*openCommand); + MultiByteToWideChar(CP_UTF8, 0, command, -1, + openCommand, commandBufferLen); + wcommand = openCommand; + } + + Discord_RegisterW(appId, wcommand); } void Discord_RegisterSteamGame( @@ -172,7 +171,8 @@ void Discord_RegisterSteamGame( status = RegQueryValueExW(key, L"SteamExe", NULL, NULL, (BYTE*)steamPath, &pathBytes); RegCloseKey(key); - if (status != ERROR_SUCCESS || pathBytes < 1) { + if (status != ERROR_SUCCESS || pathBytes < 1) + { fprintf(stderr, "Error reading SteamExe key\n"); return; } diff --git a/deps/discord-rpc/src/discord_rpc.cpp b/deps/discord-rpc/src/discord_rpc.cpp index f430746e83..41a9161db4 100644 --- a/deps/discord-rpc/src/discord_rpc.cpp +++ b/deps/discord-rpc/src/discord_rpc.cpp @@ -1,7 +1,6 @@ #include "discord_rpc.h" #include "backoff.h" -#include "discord_register.h" #include "msg_queue.h" #include "rpc_connection.h" #include "serialization.h" @@ -15,6 +14,18 @@ #include #endif +/* Forward declarations */ +#ifdef __cplusplus +extern "C" { +#endif + +void Discord_Register(const char *a, const char *b); +void Discord_RegisterSteamGame(const char *a, const char *b); + +#ifdef __cplusplus +} +#endif + constexpr size_t MaxMessageSize{16 * 1024}; constexpr size_t MessageQueueSize{8}; constexpr size_t JoinQueueSize{8}; diff --git a/network/discord.c b/network/discord.c index 66a839f7ef..480efd1f7c 100644 --- a/network/discord.c +++ b/network/discord.c @@ -23,7 +23,6 @@ #include #include "discord.h" -#include "discord_register.h" #include "../deps/discord-rpc/include/discord_rpc.h" @@ -90,6 +89,18 @@ static discord_state_t discord_st; #define CDN_URL "https://cdn.discordapp.com/avatars" +/* Forward declarations */ +#ifdef __cplusplus +extern "C" { +#endif + +void Discord_Register(const char *a, const char *b); +void Discord_RegisterSteamGame(const char *a, const char *b); + +#ifdef __cplusplus +} +#endif + static discord_state_t *discord_get_ptr(void) { return &discord_st; From 115e779cf03f1144768a863d80ba6e8ca2399ac0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 16:03:46 +0200 Subject: [PATCH 145/192] (Discord) Comment out code that isn't being used --- network/discord.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/network/discord.c b/network/discord.c index 480efd1f7c..cd16e09fb5 100644 --- a/network/discord.c +++ b/network/discord.c @@ -22,15 +22,14 @@ #include #include -#include "discord.h" +#include -#include "../deps/discord-rpc/include/discord_rpc.h" +#include "discord.h" #include "../retroarch.h" #include "../core.h" #include "../core_info.h" #include "../paths.h" -#include "../playlist.h" #include "../verbosity.h" #include "../msg_hash.h" @@ -317,22 +316,26 @@ static void handle_discord_join_request(const DiscordUser* request) #ifdef HAVE_MENU discord_download_avatar(request->userId, request->avatar); - /* To-Do: needs in-game widgets - retroarch_menu_running(); - */ + +#if 0 + /* TODO/FIXME: Needs in-game widgets */ + retroarch_menu_running(); memset(&line, 0, sizeof(line)); - snprintf(buf, sizeof(buf), "%s %s?", msg_hash_to_str(MSG_DISCORD_CONNECTION_REQUEST), request->username); + snprintf(buf, sizeof(buf), "%s %s?", + msg_hash_to_str(MSG_DISCORD_CONNECTION_REQUEST), request->username); line.label = buf; line.label_setting = "no_setting"; line.cb = handle_discord_join_response; - /* To-Do: needs in-game widgets - To-Do: bespoke dialog, should show while in-game and have a hotkey to accept - To-Do: show avatar of the user connecting - if (!menu_input_dialog_start(&line)) + /* TODO/FIXME: needs in-game widgets + * TODO/FIXME: bespoke dialog, should show while in-game + * and have a hotkey to accept + * TODO/FIXME: show avatar of the user connecting + */ + if (!menu_input_dialog_start(&line)) return; - */ +#endif #endif } From 647bdc5cbdde93e499f4f2b63a7b8b99e250e203 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 16:10:46 +0200 Subject: [PATCH 146/192] (Discord RPC) Cleanups --- deps/discord-rpc/src/discord_rpc.cpp | 101 +++++++++++++------------- deps/discord-rpc/src/rpc_connection.h | 4 +- 2 files changed, 54 insertions(+), 51 deletions(-) diff --git a/deps/discord-rpc/src/discord_rpc.cpp b/deps/discord-rpc/src/discord_rpc.cpp index 41a9161db4..f3f9e92c5f 100644 --- a/deps/discord-rpc/src/discord_rpc.cpp +++ b/deps/discord-rpc/src/discord_rpc.cpp @@ -26,14 +26,10 @@ void Discord_RegisterSteamGame(const char *a, const char *b); } #endif -constexpr size_t MaxMessageSize{16 * 1024}; -constexpr size_t MessageQueueSize{8}; -constexpr size_t JoinQueueSize{8}; - struct QueuedMessage { size_t length; - char buffer[MaxMessageSize]; + char buffer[16384]; void Copy(const QueuedMessage& other) { @@ -61,25 +57,32 @@ struct User * from future changes in these sizes */ }; +static int Pid{0}; +static int Nonce{1}; +static int LastErrorCode{0}; +static int LastDisconnectErrorCode{0}; + +static char JoinGameSecret[256]; +static char SpectateGameSecret[256]; +static char LastErrorMessage[256]; +static char LastDisconnectErrorMessage[256]; + static RpcConnection* Connection{nullptr}; + static DiscordEventHandlers QueuedHandlers{}; static DiscordEventHandlers Handlers{}; + static std::atomic_bool WasJustConnected{false}; static std::atomic_bool WasJustDisconnected{false}; static std::atomic_bool GotErrorMessage{false}; static std::atomic_bool WasJoinGame{false}; static std::atomic_bool WasSpectateGame{false}; -static char JoinGameSecret[256]; -static char SpectateGameSecret[256]; -static int LastErrorCode{0}; -static char LastErrorMessage[256]; -static int LastDisconnectErrorCode{0}; -static char LastDisconnectErrorMessage[256]; + static std::mutex PresenceMutex; static std::mutex HandlerMutex; static QueuedMessage QueuedPresence{}; -static MsgQueue SendQueue; -static MsgQueue JoinAskQueue; +static MsgQueue SendQueue; +static MsgQueue JoinAskQueue; static User connectedUser; /* We want to auto connect, and retry on failure, @@ -87,57 +90,57 @@ static User connectedUser; * backoff from 0.5 seconds to 1 minute */ static Backoff ReconnectTimeMs(500, 60 * 1000); static auto NextConnect = std::chrono::system_clock::now(); -static int Pid{0}; -static int Nonce{1}; #ifndef DISCORD_DISABLE_IO_THREAD static void Discord_UpdateConnection(void); -class IoThreadHolder { -private: - std::atomic_bool keepRunning{true}; - std::mutex waitForIOMutex; - std::condition_variable waitForIOActivity; - std::thread ioThread; +class IoThreadHolder +{ + private: + std::atomic_bool keepRunning{true}; + std::mutex waitForIOMutex; + std::condition_variable waitForIOActivity; + std::thread ioThread; -public: - void Start() - { - keepRunning.store(true); - ioThread = std::thread([&]() { - const std::chrono::duration maxWait{500LL}; - Discord_UpdateConnection(); - while (keepRunning.load()) { - std::unique_lock lock(waitForIOMutex); - waitForIOActivity.wait_for(lock, maxWait); - Discord_UpdateConnection(); - } - }); - } + public: + void Start() + { + keepRunning.store(true); + ioThread = std::thread([&]() { + const std::chrono::duration maxWait{500LL}; + Discord_UpdateConnection(); + while (keepRunning.load()) { + std::unique_lock lock(waitForIOMutex); + waitForIOActivity.wait_for(lock, maxWait); + Discord_UpdateConnection(); + } + }); + } - void Notify() { waitForIOActivity.notify_all(); } + void Notify() { waitForIOActivity.notify_all(); } - void Stop() - { - keepRunning.exchange(false); - Notify(); - if (ioThread.joinable()) + void Stop() + { + keepRunning.exchange(false); + Notify(); + if (ioThread.joinable()) ioThread.join(); - } + } - ~IoThreadHolder() { Stop(); } + ~IoThreadHolder() { Stop(); } }; #else -class IoThreadHolder { -public: - void Start() {} - void Stop() {} - void Notify() {} +class IoThreadHolder +{ + public: + void Start() {} + void Stop() {} + void Notify() {} }; #endif /* DISCORD_DISABLE_IO_THREAD */ static IoThreadHolder* IoThread{nullptr}; -static void UpdateReconnectTime() +static void UpdateReconnectTime(void) { NextConnect = std::chrono::system_clock::now() + std::chrono::duration{ReconnectTimeMs.nextDelay()}; diff --git a/deps/discord-rpc/src/rpc_connection.h b/deps/discord-rpc/src/rpc_connection.h index a4ccb82638..6fb69c9ee0 100644 --- a/deps/discord-rpc/src/rpc_connection.h +++ b/deps/discord-rpc/src/rpc_connection.h @@ -5,7 +5,7 @@ /* I took this from the buffer size libuv uses for named pipes; * I suspect ours would usually be much smaller. */ -constexpr size_t MaxRpcFrameSize = 64 * 1024; +#define MAX_RPC_FRAMESIZE 65536 struct RpcConnection { @@ -33,7 +33,7 @@ struct RpcConnection struct MessageFrame : public MessageFrameHeader { - char message[MaxRpcFrameSize - sizeof(MessageFrameHeader)]; + char message[MAX_RPC_FRAMESIZE - sizeof(MessageFrameHeader)]; }; enum class State : uint32_t From 4a207096451b3f66bc12755300bec55aba65adba Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 16:26:39 +0200 Subject: [PATCH 147/192] (Win32) Cleanup accessibility_speak_windows --- frontend/drivers/platform_win32.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index ebb7a6ed28..4b5178a882 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -956,8 +956,6 @@ static bool accessibility_speak_windows(int speed, bool res = false; const char* speeds[10] = {"-10", "-7.5", "-5", "-2.5", "0", "2", "4", "6", "8", "10"}; - HRESULT hr; - if (speed < 1) speed = 1; else if (speed > 10) @@ -973,7 +971,7 @@ static bool accessibility_speak_windows(int speed, { if (strlen(language) > 0) snprintf(cmd, sizeof(cmd), - "powershell.exe -NoProfile -WindowStyle Hidden -Command \"Add-Type -AssemblyName System.Speech; $synth = New-Object System.Speech.Synthesis.SpeechSynthesizer; $synth.SelectVoice(\\\"%s\\\"); $synth.Rate = %s; $synth.Speak(\\\"%s\\\");\"", language, speeds[speed-1], (char*) speak_text); + "powershell.exe -NoProfile -WindowStyle Hidden -Command \"Add-Type -AssemblyName System.Speech; $synth = New-Object System.Speech.Synthesis.SpeechSynthesizer; $synth.SelectVoice(\\\"%s\\\"); $synth.Rate = %s; $synth.Speak(\\\"%s\\\");\"", language, speeds[speed-1], (char*) speak_text); else snprintf(cmd, sizeof(cmd), "powershell.exe -NoProfile -WindowStyle Hidden -Command \"Add-Type -AssemblyName System.Speech; $synth = New-Object System.Speech.Synthesis.SpeechSynthesizer; $synth.Rate = %s; $synth.Speak(\\\"%s\\\");\"", speeds[speed-1], (char*) speak_text); @@ -986,7 +984,6 @@ static bool accessibility_speak_windows(int speed, return true; } pi_set = true; - return true; } #ifdef HAVE_NVDA else if (USE_NVDA) @@ -1002,23 +999,19 @@ static bool accessibility_speak_windows(int speed, RARCH_LOG("Error communicating with NVDA\n"); return false; } - else - { - nvdaController_cancelSpeech(); - } + + nvdaController_cancelSpeech(); if (USE_NVDA_BRAILLE) nvdaController_brailleMessage(wc); else - { nvdaController_speakText(wc); - } - return true; } #endif #ifdef HAVE_SAPI else { + HRESULT hr; /* stop the old voice if running */ if (pVoice) { @@ -1038,14 +1031,14 @@ static bool accessibility_speak_windows(int speed, { wchar_t wtext[1200]; snprintf(cmd, sizeof(cmd), - "%s", speeds[speed], langid, speak_text); + "%s", speeds[speed], langid, speak_text); mbstowcs(wtext, speak_text, sizeof(wtext)); - + hr = ISpVoice_Speak(pVoice, wtext, SPF_ASYNC /*SVSFlagsAsync*/, NULL); } - return true; } #endif + return true; } #endif From d9ab59cb4a6b3ef836321497a40abf2aea707638 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 16:29:57 +0200 Subject: [PATCH 148/192] Comment out function that isn't used --- frontend/drivers/platform_unix.c | 6 +++--- network/discord.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c index e7ac2bc24b..6cb3af8588 100644 --- a/frontend/drivers/platform_unix.c +++ b/frontend/drivers/platform_unix.c @@ -2432,8 +2432,8 @@ static bool accessibility_speak_unix(int speed, { int pid; const char *language = get_user_language_iso639_1(true); - char* voice_out = (char *)malloc(3+strlen(language)); - char* speed_out = (char *)malloc(3+3); + char* voice_out = (char*)malloc(3+strlen(language)); + char* speed_out = (char*)malloc(3+3); const char* speeds[10] = {"80", "100", "125", "150", "170", "210", "260", "310", "380", "450"}; if (speed < 1) @@ -2482,7 +2482,7 @@ static bool accessibility_speak_unix(int speed, char* cmd[] = { (char*) "espeak", NULL, NULL, NULL, NULL}; cmd[1] = voice_out; cmd[2] = speed_out; - cmd[3] = (char *) speak_text; + cmd[3] = (char*)speak_text; execvp("espeak", cmd); } return true; diff --git a/network/discord.c b/network/discord.c index cd16e09fb5..89ac517c53 100644 --- a/network/discord.c +++ b/network/discord.c @@ -283,9 +283,9 @@ static void handle_discord_spectate(const char* secret) } #ifdef HAVE_MENU +#if 0 static void handle_discord_join_response(void *ignore, const char *line) { -#if 0 /* TODO/FIXME: needs in-game widgets */ if (strstr(line, "yes")) Discord_Respond(user_id, DISCORD_REPLY_YES); @@ -294,9 +294,9 @@ static void handle_discord_join_response(void *ignore, const char *line) menu_input_dialog_end(); retroarch_menu_running_finished(false); #endif -#endif } #endif +#endif static void handle_discord_join_request(const DiscordUser* request) { From af01b97a11414cc114c0c7a2069beccca2199296 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 16:32:20 +0200 Subject: [PATCH 149/192] Add TODO/FIXME --- retroarch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/retroarch.c b/retroarch.c index c2fc88a21e..0c6375334b 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1609,6 +1609,7 @@ static retro_usec_t runloop_frame_time_last = 0; static bool has_set_core = false; #ifdef HAVE_DISCORD +/* TODO/FIXME - static public global variable */ bool discord_is_inited = false; #endif static bool has_set_username = false; From aeb3f692d5793026d9d360c5d321d597890b3573 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 16:35:53 +0200 Subject: [PATCH 150/192] Get rid of superfluous get_ai_service_auto/set_ai_service_auto get/set wrapper functions --- retroarch.c | 56 +++++++++++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/retroarch.c b/retroarch.c index 0c6375334b..1f75f4aef4 100644 --- a/retroarch.c +++ b/retroarch.c @@ -4704,17 +4704,6 @@ error: /* TRANSLATION */ #ifdef HAVE_TRANSLATE -static int get_ai_service_auto(void) -{ - return g_ai_service_auto; -} - -static bool set_ai_service_auto(int num) -{ - g_ai_service_auto = num; - return true; -} - static bool task_auto_translate_callback(void) { bool was_paused = runloop_paused; @@ -4766,11 +4755,13 @@ static void task_auto_translate_handler(retro_task_t *task) #endif } return; + task_finished: - if (get_ai_service_auto() == 1) - set_ai_service_auto(2); + if (g_ai_service_auto == 1) + g_ai_service_auto = 2; task_set_finished(task, true); + if (*mode_ptr == 1 || *mode_ptr == 2) task_auto_translate_callback(); if (task->user_data) @@ -4785,8 +4776,8 @@ static bool call_auto_translate_task(bool* was_paused) /*Image Mode*/ if (ai_service_mode == 0) { - if (get_ai_service_auto() == 1) - set_ai_service_auto(2); + if (g_ai_service_auto == 1) + g_ai_service_auto = 2; command_event(CMD_EVENT_AI_SERVICE_CALL, was_paused); return true; @@ -4794,7 +4785,7 @@ static bool call_auto_translate_task(bool* was_paused) else /* Speech or Narrator Mode */ { retro_task_t *t = NULL; - int* mode = (int*) malloc(sizeof(int)); + int* mode = (int*)malloc(sizeof(int)); *mode = ai_service_mode; t = task_init(); if (!t) @@ -4843,7 +4834,7 @@ static void handle_translation_cb( #ifdef GFX_MENU_WIDGETS if (gfx_widgets_ai_service_overlay_get_state() != 0 - && get_ai_service_auto() == 2) + && g_ai_service_auto == 2) { /* When auto mode is on, we turn off the overlay * once we have the result for the next call.*/ @@ -4852,7 +4843,7 @@ static void handle_translation_cb( #endif #ifdef DEBUG - if (get_ai_service_auto() != 2) + if (g_ai_service_auto != 2) RARCH_LOG("RESULT FROM AI SERVICE...\n"); #endif @@ -4980,7 +4971,7 @@ static void handle_translation_cb( #endif } - if (!raw_image_file_data && !raw_sound_data && !text_string && get_ai_service_auto() != 2 && !key_string) + if (!raw_image_file_data && !raw_sound_data && !text_string && g_ai_service_auto != 2 && !key_string) { error = "Invalid JSON body."; goto finish; @@ -5325,7 +5316,7 @@ finish: if (string_is_equal(auto_string, "auto")) { - if (get_ai_service_auto() != 0 && !settings->bools.ai_service_pause) + if (g_ai_service_auto != 0 && !settings->bools.ai_service_pause) call_auto_translate_task(&was_paused); } if (auto_string) @@ -5546,7 +5537,7 @@ static bool run_translation_service(bool paused) core_info_t *core_info = NULL; #ifdef HAVE_GFX_WIDGETS - if (gfx_widgets_ai_service_overlay_get_state() != 0 && get_ai_service_auto() == 1) + if (gfx_widgets_ai_service_overlay_get_state() != 0 && g_ai_service_auto == 1) { /* For the case when ai service pause is disabled. */ gfx_widgets_ai_service_overlay_unload(); @@ -5583,7 +5574,7 @@ static bool run_translation_service(bool paused) if (!label) label = path_basename(path_get(RARCH_PATH_BASENAME)); - system_label = (char *) malloc(strlen(label)+strlen(system_id)+3); + system_label = (char*)malloc(strlen(label)+strlen(system_id)+3); memcpy(system_label, system_id, strlen(system_id)); memcpy(system_label+strlen(system_id), "__", 2); memcpy(system_label+2+strlen(system_id), label, strlen(label)); @@ -5723,7 +5714,7 @@ static bool run_translation_service(bool paused) { state_son_length = 177; - state_son = (char *) malloc(state_son_length); + state_son = (char*)malloc(state_son_length); memcpy(state_son, ", \"state\": {\"paused\": 0, \"a\": 0, \"b\": 0, \"select\": 0, \"start\": 0, \"up\": 0, \"down\": 0, \"left\": 0, \"right\": 0, \"x\": 0, \"y\": 0, \"l\": 0, \"r\":0, \"l2\": 0, \"r2\": 0, \"l3\":0, \"r3\": 0}}\0", state_son_length*sizeof(uint8_t)); @@ -5799,7 +5790,7 @@ static bool run_translation_service(bool paused) } #ifdef DEBUG - if (get_ai_service_auto()!=2) + if (g_ai_service_auto != 2) RARCH_LOG("Request size: %d\n", out_length); #endif { @@ -5894,7 +5885,7 @@ static bool run_translation_service(bool paused) sizeof(new_ai_service_url)); } #ifdef DEBUG - if (get_ai_service_auto() != 2) + if (g_ai_service_auto != 2) RARCH_LOG("SENDING... %s\n", new_ai_service_url); #endif task_push_http_post_transfer(new_ai_service_url, @@ -7178,11 +7169,11 @@ bool command_event(enum event_command cmd, void *data) * Also, this mode is required for "auto" translation * packages, since you don't want to pause for that. */ - if (get_ai_service_auto() == 2) + if (g_ai_service_auto == 2) { /* Auto mode was turned on, but we pressed the * toggle button, so turn it off now. */ - set_ai_service_auto(0); + g_ai_service_auto = 0; #ifdef HAVE_MENU_WIDGETS gfx_widgets_ai_service_overlay_unload(); #endif @@ -8506,9 +8497,9 @@ bool command_event(enum event_command cmd, void *data) if (data!=NULL) paused = *((bool*)data); - if (get_ai_service_auto() == 0 && !settings->bools.ai_service_pause) - set_ai_service_auto(1); - if (get_ai_service_auto() != 2) + if (g_ai_service_auto == 0 && !settings->bools.ai_service_pause) + g_ai_service_auto = 1; + if (g_ai_service_auto != 2) RARCH_LOG("AI Service Called...\n"); run_translation_service(paused); } @@ -17547,10 +17538,11 @@ void input_keyboard_event(bool down, unsigned code, { if (code != 303 && code != 0) { - char* say_char = (char*) malloc(sizeof(char)+1); + char* say_char = (char*)malloc(sizeof(char)+1); + if (say_char) { - char c = (char) character; + char c = (char) character; *say_char = c; if (character == 127) From e64b4c1d2447b1b134f9660cec6db4beda83ccea Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 17:34:39 +0200 Subject: [PATCH 151/192] For gamepad-like console/Android TV devices - default to Ozone --- frontend/drivers/platform_unix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c index 6cb3af8588..b0c5240f8f 100644 --- a/frontend/drivers/platform_unix.c +++ b/frontend/drivers/platform_unix.c @@ -1679,7 +1679,7 @@ static void frontend_unix_get_env(int *argc, /* For gamepad-like/console devices: * * - Explicitly disable input overlay by default - * - Use XMB menu driver by default + * - Use Ozone menu driver by default * * */ @@ -1687,7 +1687,7 @@ static void frontend_unix_get_env(int *argc, { g_defaults.overlay.set = true; g_defaults.overlay.enable = false; - strlcpy(g_defaults.settings.menu, "xmb", + strlcpy(g_defaults.settings.menu, "ozone", sizeof(g_defaults.settings.menu)); } #else From 057ae3c134c8c87c300a721d2c64961f024db3fd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 17:35:52 +0200 Subject: [PATCH 152/192] Update CHANGES.md --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 8529756edd..9639562b76 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,8 @@ - INPUT MAPPING/REMAPPING: Restore broken 'reset to default' functionality with RetroPad 'start' button - INPUT MAPPING/REMAPPING: Fix 'reset to default' action for analog sticks and undefined core inputs - MENU/THUMBNAILS/BUGFIX: Fix heap-use-after-free error +- MENU/OZONE/ANDROIDTV: Default to Ozone menu driver +- MENU/OZONE/ANDROID: Gamepad-like devices default to Ozone now (Shield Portable) - OVERLAYS: Fix memory leak when loading overlays - WIIU: Gamepad hotplugging support - WIIU: Theoretical multi-gamepad support From 2768655267fda1b6c2f7f696bef7eeedad2a3950 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Coll=20Cerd=C3=A1n?= Date: Mon, 18 May 2020 23:40:32 +0200 Subject: [PATCH 153/192] Cleaner structure for auto shader presets. Additional changes: * Restore the previous storage path for user-presets until a better solution is agreed upon. * Stop using the Video Shaders directory as fallback directory to store autopresets. Will be used only when autoloading as last resort to ensure compatibility with old setups. --- menu/menu_shader.c | 142 ++++++++++++++++++++++----------------------- retroarch.c | 48 +++++++-------- 2 files changed, 95 insertions(+), 95 deletions(-) diff --git a/menu/menu_shader.c b/menu/menu_shader.c index 45eb76cfcd..1aafd41b93 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -220,8 +220,9 @@ clear: static bool menu_shader_manager_save_preset_internal( const struct video_shader *shader, const char *basename, const char *dir_video_shader, - const char *dir_menu_config, - bool apply, bool save_reference) + bool apply, bool save_reference, + const char **target_dirs, + size_t num_target_dirs) { bool ret = false; enum rarch_shader_type type = RARCH_SHADER_NONE; @@ -278,28 +279,14 @@ static bool menu_shader_manager_save_preset_internal( } else { - const char *dirs[3] = {0}; - char config_directory[PATH_MAX_LENGTH]; char basedir[PATH_MAX_LENGTH]; - config_directory[0] = '\0'; - - if (!path_is_empty(RARCH_PATH_CONFIG)) - fill_pathname_basedir( - config_directory, - path_get(RARCH_PATH_CONFIG), - sizeof(config_directory)); - - dirs[0] = dir_menu_config; - dirs[1] = dir_video_shader; - dirs[2] = config_directory; - - for (i = 0; i < ARRAY_SIZE(dirs); i++) + for (i = 0; i < num_target_dirs; i++) { - if (string_is_empty(dirs[i])) + if (string_is_empty(target_dirs[i])) continue; - fill_pathname_join(buffer, dirs[i], + fill_pathname_join(buffer, target_dirs[i], fullname, sizeof(buffer)); strlcpy(basedir, buffer, sizeof(basedir)); @@ -348,31 +335,50 @@ static bool menu_shader_manager_operate_auto_preset( const char *dir_menu_config, enum auto_shader_type type, bool apply) { + char old_presets_directory[PATH_MAX_LENGTH]; + char config_directory[PATH_MAX_LENGTH]; char tmp[PATH_MAX_LENGTH]; - char directory[PATH_MAX_LENGTH]; char file[PATH_MAX_LENGTH]; - struct retro_system_info *system = runloop_get_libretro_system_info(); - const char *core_name = system ? system->library_name : NULL; + struct retro_system_info *system = runloop_get_libretro_system_info(); + const char *core_name = system ? system->library_name : NULL; + const char *auto_preset_dirs[3] = {0}; - tmp[0] = directory[0] = file[0] = '\0'; + old_presets_directory[0] = config_directory[0] = tmp[0] = file[0] = '\0'; if (type != SHADER_PRESET_GLOBAL && string_is_empty(core_name)) return false; + if (!path_is_empty(RARCH_PATH_CONFIG)) + fill_pathname_basedir( + config_directory, + path_get(RARCH_PATH_CONFIG), + sizeof(config_directory)); + + /* We are only including this directory for compatibility purposes with + * versions 1.8.7 and older. */ + if (op != AUTO_SHADER_OP_SAVE && !string_is_empty(dir_video_shader)) + fill_pathname_join( + old_presets_directory, + dir_video_shader, + "presets", + sizeof(old_presets_directory)); + + auto_preset_dirs[0] = dir_menu_config; + auto_preset_dirs[1] = config_directory; + auto_preset_dirs[2] = old_presets_directory; + switch (type) { case SHADER_PRESET_GLOBAL: - fill_pathname_join(file, "presets", "global", sizeof(file)); + strlcpy(file, "global", sizeof(file)); break; case SHADER_PRESET_CORE: - fill_pathname_join(directory, "presets", core_name, sizeof(directory)); - fill_pathname_join(file, directory, core_name, sizeof(file)); + fill_pathname_join(file, core_name, core_name, sizeof(file)); break; case SHADER_PRESET_PARENT: - fill_pathname_join(directory, "presets", core_name, sizeof(directory)); fill_pathname_parent_dir_name(tmp, path_get(RARCH_PATH_BASENAME), sizeof(tmp)); - fill_pathname_join(file, directory, tmp, sizeof(file)); + fill_pathname_join(file, core_name, tmp, sizeof(file)); break; case SHADER_PRESET_GAME: { @@ -380,8 +386,7 @@ static bool menu_shader_manager_operate_auto_preset( path_basename(path_get(RARCH_PATH_BASENAME)); if (string_is_empty(game_name)) return false; - fill_pathname_join(directory, "presets", core_name, sizeof(directory)); - fill_pathname_join(file, directory, game_name, sizeof(file)); + fill_pathname_join(file, core_name, game_name, sizeof(file)); break; } default: @@ -394,38 +399,28 @@ static bool menu_shader_manager_operate_auto_preset( return menu_shader_manager_save_preset_internal( shader, file, dir_video_shader, - dir_menu_config, - apply, true); + apply, true, + auto_preset_dirs, + ARRAY_SIZE(auto_preset_dirs)); case AUTO_SHADER_OP_REMOVE: { /* remove all supported auto-shaders of given type */ char *end; size_t i, j, n, m; - const char *dirs[3] = {0}; - char config_directory[PATH_MAX_LENGTH]; char preset_path[PATH_MAX_LENGTH]; + /* n = amount of relevant shader presets found + * m = amount of successfully deleted shader presets */ n = m = 0; - config_directory[0] = '\0'; - - if (!path_is_empty(RARCH_PATH_CONFIG)) - fill_pathname_basedir( - config_directory, - path_get(RARCH_PATH_CONFIG), - sizeof(config_directory)); - - dirs[0] = dir_menu_config; - dirs[1] = dir_video_shader; - dirs[2] = config_directory; - - for (i = 0; i < ARRAY_SIZE(dirs); i++) + for (i = 0; i < ARRAY_SIZE(auto_preset_dirs); i++) { - if (string_is_empty(dirs[i])) + if (string_is_empty(auto_preset_dirs[i])) continue; - fill_pathname_join(preset_path, dirs[i], file, sizeof(preset_path)); + fill_pathname_join(preset_path, + auto_preset_dirs[i], file, sizeof(preset_path)); end = preset_path + strlen(preset_path); for (j = 0; j < ARRAY_SIZE(shader_types); j++) @@ -461,28 +456,15 @@ static bool menu_shader_manager_operate_auto_preset( char *end; size_t i, j; - const char *dirs[3] = {0}; - char config_directory[PATH_MAX_LENGTH]; char preset_path[PATH_MAX_LENGTH]; - config_directory[0] = '\0'; - - if (!path_is_empty(RARCH_PATH_CONFIG)) - fill_pathname_basedir( - config_directory, - path_get(RARCH_PATH_CONFIG), - sizeof(config_directory)); - - dirs[0] = dir_menu_config; - dirs[1] = dir_video_shader; - dirs[2] = config_directory; - - for (i = 0; i < ARRAY_SIZE(dirs); i++) + for (i = 0; i < ARRAY_SIZE(auto_preset_dirs); i++) { - if (string_is_empty(dirs[i])) + if (string_is_empty(auto_preset_dirs[i])) continue; - fill_pathname_join(preset_path, dirs[i], file, sizeof(preset_path)); + fill_pathname_join(preset_path, + auto_preset_dirs[i], file, sizeof(preset_path)); end = preset_path + strlen(preset_path); for (j = 0; j < ARRAY_SIZE(shader_types); j++) @@ -513,10 +495,10 @@ static bool menu_shader_manager_operate_auto_preset( * @apply : immediately set preset after saving * * Save a shader as an auto-shader to it's appropriate path: - * SHADER_PRESET_GLOBAL: /presets/global - * SHADER_PRESET_CORE: /presets// - * SHADER_PRESET_PARENT: /presets// - * SHADER_PRESET_GAME: /presets// + * SHADER_PRESET_GLOBAL: /global + * SHADER_PRESET_CORE: // + * SHADER_PRESET_PARENT: // + * SHADER_PRESET_GAME: // * Needs to be consistent with retroarch_load_shader_preset() * Auto-shaders will be saved as a reference if possible **/ @@ -549,11 +531,27 @@ bool menu_shader_manager_save_preset(const struct video_shader *shader, const char *dir_menu_config, bool apply) { + char config_directory[PATH_MAX_LENGTH]; + const char *preset_dirs[3] = {0}; + + config_directory[0] = '\0'; + + if (!path_is_empty(RARCH_PATH_CONFIG)) + fill_pathname_basedir( + config_directory, + path_get(RARCH_PATH_CONFIG), + sizeof(config_directory)); + + preset_dirs[0] = dir_video_shader; + preset_dirs[1] = dir_menu_config; + preset_dirs[2] = config_directory; + return menu_shader_manager_save_preset_internal( shader, basename, dir_video_shader, - dir_menu_config, - apply, false); + apply, false, + preset_dirs, + ARRAY_SIZE(preset_dirs)); } /** diff --git a/retroarch.c b/retroarch.c index 1f75f4aef4..26ade82b5a 100644 --- a/retroarch.c +++ b/retroarch.c @@ -27372,17 +27372,16 @@ static bool retroarch_load_shader_preset_internal( * Tries to load a supported core-, game-, folder-specific or global * shader preset from its respective location: * - * global: $SHADER_DIR/presets/global.$PRESET_EXT - * core-specific: $SHADER_DIR/presets/$CORE_NAME/$CORE_NAME.$PRESET_EXT - * folder-specific: $SHADER_DIR/presets/$CORE_NAME/$FOLDER_NAME.$PRESET_EXT - * game-specific: $SHADER_DIR/presets/$CORE_NAME/$GAME_NAME.$PRESET_EXT + * global: $CONFIG_DIR/global.$PRESET_EXT + * core-specific: $CONFIG_DIR/$CORE_NAME/$CORE_NAME.$PRESET_EXT + * folder-specific: $CONFIG_DIR/$CORE_NAME/$FOLDER_NAME.$PRESET_EXT + * game-specific: $CONFIG_DIR/$CORE_NAME/$GAME_NAME.$PRESET_EXT * - * $SHADER_DIR is composed by three different locations which will be searched - * in the following order (search will stop on first match): + * $CONFIG_DIR is expected to be Menu Config directory, or failing that, the + * directory where retroarch.cfg is stored. * - * 1. The Menu Config directory - * 2. The Video Shader directory - * 3. The directory where the configuration file is stored + * For compatibility purposes with versions 1.8.7 and older, the presets + * subdirectory on the Video Shader path is used as a fallback directory. * * Note: Uses video_shader_is_supported() which only works after * context driver initialization. @@ -27400,7 +27399,7 @@ static bool retroarch_load_shader_preset(void) const char *game_name = path_basename(rarch_path_basename); char *content_dir_name = NULL; char *config_file_directory = NULL; - char *shader_directory = NULL; + char *old_presets_directory = NULL; bool auto_shaders_enable = settings->bools.auto_shaders_enable; const char *dirs[3] = {0}; @@ -27419,8 +27418,8 @@ static bool retroarch_load_shader_preset(void) if (!config_file_directory) goto end; - shader_directory = (char*)malloc(PATH_MAX_LENGTH); - if (!shader_directory) + old_presets_directory = (char*)malloc(PATH_MAX_LENGTH); + if (!old_presets_directory) goto end; content_dir_name[0] = '\0'; @@ -27435,21 +27434,24 @@ static bool retroarch_load_shader_preset(void) fill_pathname_basedir(config_file_directory, path_get(RARCH_PATH_CONFIG), PATH_MAX_LENGTH); + old_presets_directory[0] = '\0'; + + if (!string_is_empty(video_shader_directory)) + fill_pathname_join(old_presets_directory, + video_shader_directory, "presets", PATH_MAX_LENGTH); + dirs[0] = menu_config_directory; - dirs[1] = video_shader_directory; - dirs[2] = config_file_directory; + dirs[1] = config_file_directory; + dirs[2] = old_presets_directory; for (i = 0; i < ARRAY_SIZE(dirs); i++) { if (string_is_empty(dirs[i])) continue; - fill_pathname_join(shader_directory, - dirs[i], "presets", PATH_MAX_LENGTH); + RARCH_LOG("[Shaders]: preset directory: %s\n", dirs[i]); - RARCH_LOG("[Shaders]: preset directory: %s\n", shader_directory); - - ret = retroarch_load_shader_preset_internal(shader_directory, core_name, + ret = retroarch_load_shader_preset_internal(dirs[i], core_name, game_name); if (ret) @@ -27458,7 +27460,7 @@ static bool retroarch_load_shader_preset(void) break; } - ret = retroarch_load_shader_preset_internal(shader_directory, core_name, + ret = retroarch_load_shader_preset_internal(dirs[i], core_name, content_dir_name); if (ret) @@ -27467,7 +27469,7 @@ static bool retroarch_load_shader_preset(void) break; } - ret = retroarch_load_shader_preset_internal(shader_directory, core_name, + ret = retroarch_load_shader_preset_internal(dirs[i], core_name, core_name); if (ret) @@ -27476,7 +27478,7 @@ static bool retroarch_load_shader_preset(void) break; } - ret = retroarch_load_shader_preset_internal(shader_directory, NULL, + ret = retroarch_load_shader_preset_internal(dirs[i], NULL, "global"); if (ret) @@ -27489,7 +27491,7 @@ static bool retroarch_load_shader_preset(void) end: free(content_dir_name); free(config_file_directory); - free(shader_directory); + free(old_presets_directory); return ret; } #endif From e43111d9cbbc18dbd332938a6b91e2f930fd280b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Coll=20Cerd=C3=A1n?= Date: Wed, 20 May 2020 17:35:04 +0200 Subject: [PATCH 154/192] Support fallback dirs to cycle user shader presets When a user shader preset was saved, if the Video Shader directory wasn't writable, it would fall back to the Menu Config directory, and failing that, it would fall back to the directory where retroarch.cfg is stored. This change allows the shader cycling feature to use those directories if no shader presets are found on the Video Shader directory. --- retroarch.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/retroarch.c b/retroarch.c index 26ade82b5a..419e45c8de 100644 --- a/retroarch.c +++ b/retroarch.c @@ -21465,6 +21465,8 @@ static bool video_driver_init_internal(bool *video_is_threaded) settings_t *settings = configuration_settings; struct retro_game_geometry *geom = &video_driver_av_info.geometry; const char *path_softfilter_plugin = settings->paths.path_softfilter_plugin; + char *config_file_directory = NULL; + bool dir_list_is_free = true; if (!string_is_empty(path_softfilter_plugin)) video_driver_init_filter(video_driver_pix_fmt); @@ -21667,9 +21669,30 @@ static bool video_driver_init_internal(bool *video_is_threaded) dir_free_shader(); if (!string_is_empty(settings->paths.directory_video_shader)) - dir_init_shader(settings->paths.directory_video_shader, + dir_list_is_free = !dir_init_shader( + settings->paths.directory_video_shader, settings->bools.show_hidden_files); + if (dir_list_is_free && !string_is_empty(settings->paths.directory_menu_config)) + dir_list_is_free = !dir_init_shader( + settings->paths.directory_menu_config, + settings->bools.show_hidden_files); + + if (dir_list_is_free && !path_is_empty(RARCH_PATH_CONFIG)) + { + config_file_directory = (char*)malloc(PATH_MAX_LENGTH); + + fill_pathname_basedir(config_file_directory, + path_get(RARCH_PATH_CONFIG), PATH_MAX_LENGTH); + + if (config_file_directory) + { + dir_list_is_free = !dir_init_shader( + config_file_directory, + settings->bools.show_hidden_files); + } + } + return true; error: From 3d677ee90c6a075f753c1dfad6430602c080860e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 17:59:42 +0200 Subject: [PATCH 155/192] (Discord RPC) Simplify - use string_is_equal - de-auto type certain variables where possible --- deps/discord-rpc/src/discord_rpc.cpp | 49 +++++++++++++------------ deps/discord-rpc/src/rpc_connection.cpp | 10 +++-- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/deps/discord-rpc/src/discord_rpc.cpp b/deps/discord-rpc/src/discord_rpc.cpp index f3f9e92c5f..ddbdd12ef9 100644 --- a/deps/discord-rpc/src/discord_rpc.cpp +++ b/deps/discord-rpc/src/discord_rpc.cpp @@ -14,6 +14,8 @@ #include #endif +#include + /* Forward declarations */ #ifdef __cplusplus extern "C" { @@ -174,18 +176,18 @@ static void Discord_UpdateConnection(void) if (!Connection->Read(message)) break; - const char* evtName = GetStrMember(&message, "evt"); - const char* nonce = GetStrMember(&message, "nonce"); + const char *evtName = GetStrMember(&message, "evt"); + const char *nonce = GetStrMember(&message, "nonce"); if (nonce) { /* in responses only -- * should use to match up response when needed. */ - if (evtName && strcmp(evtName, "ERROR") == 0) + if (evtName && string_is_equal(evtName, "ERROR")) { - auto data = GetObjMember(&message, "data"); - LastErrorCode = GetIntMember(data, "code"); + JsonValue *data = GetObjMember(&message, "data"); + LastErrorCode = GetIntMember(data, "code"); StringCopy(LastErrorMessage, GetStrMember(data, "message", "")); GotErrorMessage.store(true); } @@ -196,39 +198,40 @@ static void Discord_UpdateConnection(void) if (!evtName) continue; - auto data = GetObjMember(&message, "data"); + JsonValue *data = GetObjMember(&message, "data"); - if (strcmp(evtName, "ACTIVITY_JOIN") == 0) + if (string_is_equal(evtName, "ACTIVITY_JOIN")) { - auto secret = GetStrMember(data, "secret"); + const char *secret = GetStrMember(data, "secret"); if (secret) { StringCopy(JoinGameSecret, secret); WasJoinGame.store(true); } } - else if (strcmp(evtName, "ACTIVITY_SPECTATE") == 0) + else if (string_is_equal(evtName, "ACTIVITY_SPECTATE")) { - auto secret = GetStrMember(data, "secret"); + const char *secret = GetStrMember(data, "secret"); if (secret) { StringCopy(SpectateGameSecret, secret); WasSpectateGame.store(true); } } - else if (strcmp(evtName, "ACTIVITY_JOIN_REQUEST") == 0) + else if (string_is_equal(evtName, "ACTIVITY_JOIN_REQUEST")) { - auto user = GetObjMember(data, "user"); - auto userId = GetStrMember(user, "id"); - auto username = GetStrMember(user, "username"); - auto avatar = GetStrMember(user, "avatar"); - auto joinReq = JoinAskQueue.GetNextAddMessage(); + JsonValue *user = GetObjMember(data, "user"); + const char *userId = GetStrMember(user, "id"); + const char *username = GetStrMember(user, "username"); + const char *avatar = GetStrMember(user, "avatar"); + auto joinReq = JoinAskQueue.GetNextAddMessage(); if (userId && username && joinReq) { StringCopy(joinReq->userId, userId); StringCopy(joinReq->username, username); - auto discriminator = GetStrMember(user, "discriminator"); + const char *discriminator = GetStrMember(user, + "discriminator"); if (discriminator) StringCopy(joinReq->discriminator, discriminator); if (avatar) @@ -335,16 +338,16 @@ extern "C" DISCORD_EXPORT void Discord_Initialize( Connection->onConnect = [](JsonDocument& readyMessage) { Discord_UpdateHandlers(&QueuedHandlers); - auto data = GetObjMember(&readyMessage, "data"); - auto user = GetObjMember(data, "user"); - auto userId = GetStrMember(user, "id"); - auto username = GetStrMember(user, "username"); - auto avatar = GetStrMember(user, "avatar"); + JsonValue *data = GetObjMember(&readyMessage, "data"); + JsonValue *user = GetObjMember(data, "user"); + const char *userId = GetStrMember(user, "id"); + const char *username = GetStrMember(user, "username"); + const char *avatar = GetStrMember(user, "avatar"); if (userId && username) { StringCopy(connectedUser.userId, userId); StringCopy(connectedUser.username, username); - auto discriminator = GetStrMember(user, "discriminator"); + const char *discriminator = GetStrMember(user, "discriminator"); if (discriminator) StringCopy(connectedUser.discriminator, discriminator); if (avatar) diff --git a/deps/discord-rpc/src/rpc_connection.cpp b/deps/discord-rpc/src/rpc_connection.cpp index f93cb66278..0afeda85fa 100644 --- a/deps/discord-rpc/src/rpc_connection.cpp +++ b/deps/discord-rpc/src/rpc_connection.cpp @@ -3,6 +3,8 @@ #include +#include + static const int RpcVersion = 1; static RpcConnection Instance; @@ -36,11 +38,11 @@ void RpcConnection::Open() JsonDocument message; if (Read(message)) { - auto cmd = GetStrMember(&message, "cmd"); - auto evt = GetStrMember(&message, "evt"); + const char *cmd = GetStrMember(&message, "cmd"); + const char *evt = GetStrMember(&message, "evt"); if (cmd && evt - && !strcmp(cmd, "DISPATCH") - && !strcmp(evt, "READY")) + && string_is_equal(cmd, "DISPATCH") + && string_is_equal(evt, "READY")) { state = State::Connected; if (onConnect) From c346e1f8167f0e0af3770c816e7d4e7367aed8ab Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Wed, 20 May 2020 17:03:01 +0100 Subject: [PATCH 156/192] Various file path handling optimisations --- libretro-common/file/file_path.c | 73 ++++++++++++++-------- libretro-common/include/string/stdstring.h | 5 ++ retroarch.c | 14 ++--- 3 files changed, 58 insertions(+), 34 deletions(-) diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 5d9189a5dc..e8cd688308 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -44,7 +44,6 @@ #include #include #endif -#include #include #include @@ -124,26 +123,48 @@ */ const char *path_get_archive_delim(const char *path) { - const char *last = find_last_slash(path); - const char *delim = NULL; + const char *last_slash = find_last_slash(path); + const char *delim = NULL; + char buf[5]; - if (!last) + buf[0] = '\0'; + + if (!last_slash) return NULL; - /* Test if it's .zip */ - delim = strcasestr(last, ".zip#"); + /* Find delimiter position */ + delim = strrchr(last_slash, '#'); - if (!delim) /* If it's not a .zip, test if it's .apk */ - delim = strcasestr(last, ".apk#"); + if (!delim) + return NULL; - if (delim) - return delim + 4; + /* Check whether this is a known archive type + * > Note: The code duplication here is + * deliberate, to maximise performance */ + if (delim - last_slash > 4) + { + strlcpy(buf, delim - 4, sizeof(buf)); + buf[4] = '\0'; - /* If it's not a .zip or .apk file, test if it's .7z */ - delim = strcasestr(last, ".7z#"); + string_to_lower(buf); - if (delim) - return delim + 3; + /* Check if this is a '.zip', '.apk' or '.7z' file */ + if (string_is_equal(buf, ".zip") || + string_is_equal(buf, ".apk") || + string_is_equal(buf + 1, ".7z")) + return delim; + } + else if (delim - last_slash > 3) + { + strlcpy(buf, delim - 3, sizeof(buf)); + buf[3] = '\0'; + + string_to_lower(buf); + + /* Check if this is a '.7z' file */ + if (string_is_equal(buf, ".7z")) + return delim; + } return NULL; } @@ -202,9 +223,12 @@ bool path_is_compressed_file(const char* path) { const char *ext = path_get_extension(path); - if ( strcasestr(ext, "zip") - || strcasestr(ext, "apk") - || strcasestr(ext, "7z")) + if (string_is_empty(ext)) + return false; + + if (string_is_equal_noncase(ext, "zip") || + string_is_equal_noncase(ext, "apk") || + string_is_equal_noncase(ext, "7z")) return true; return false; @@ -1029,10 +1053,11 @@ void fill_pathname_abbreviate_special(char *out_path, unsigned i; const char *candidates[3]; const char *notations[3]; - char *application_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - char *home_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + char application_dir[PATH_MAX_LENGTH]; + char home_dir[PATH_MAX_LENGTH]; application_dir[0] = '\0'; + home_dir[0] = '\0'; /* application_dir could be zero-string. Safeguard against this. * @@ -1049,15 +1074,13 @@ void fill_pathname_abbreviate_special(char *out_path, notations [1] = "~"; notations [2] = NULL; - fill_pathname_application_dir(application_dir, - PATH_MAX_LENGTH * sizeof(char)); - fill_pathname_home_dir(home_dir, - PATH_MAX_LENGTH * sizeof(char)); + fill_pathname_application_dir(application_dir, sizeof(application_dir)); + fill_pathname_home_dir(home_dir, sizeof(home_dir)); for (i = 0; candidates[i]; i++) { if (!string_is_empty(candidates[i]) && - strstr(in_path, candidates[i]) == in_path) + string_starts_with(in_path, candidates[i])) { size_t src_size = strlcpy(out_path, notations[i], size); @@ -1079,8 +1102,6 @@ void fill_pathname_abbreviate_special(char *out_path, } } - free(application_dir); - free(home_dir); #endif retro_assert(strlcpy(out_path, in_path, size) < size); diff --git a/libretro-common/include/string/stdstring.h b/libretro-common/include/string/stdstring.h index 08a947d4b4..18668e98db 100644 --- a/libretro-common/include/string/stdstring.h +++ b/libretro-common/include/string/stdstring.h @@ -45,6 +45,11 @@ static INLINE bool string_is_equal(const char *a, const char *b) return (a && b) ? !strcmp(a, b) : false; } +static INLINE bool string_starts_with(const char *str, const char *prefix) +{ + return (str && prefix) ? !strncmp(prefix, str, strlen(prefix)) : false; +} + #define STRLEN_CONST(x) ((sizeof((x))-1)) #define string_is_not_equal(a, b) !string_is_equal((a), (b)) diff --git a/retroarch.c b/retroarch.c index 1f75f4aef4..e30684d0a8 100644 --- a/retroarch.c +++ b/retroarch.c @@ -3335,14 +3335,12 @@ enum rarch_content_type path_is_media_type(const char *path) string_to_lower(ext_lower); /* hack, to detect livestreams so the ffmpeg core can be started */ - if ( - strstr(path, "udp://") || - strstr(path, "http://") || - strstr(path, "https://")|| - strstr(path, "tcp://") || - strstr(path, "rtmp://") || - strstr(path, "rtp://") - ) + if (string_starts_with(path, "udp://") || + string_starts_with(path, "http://") || + string_starts_with(path, "https://") || + string_starts_with(path, "tcp://") || + string_starts_with(path, "rtmp://") || + string_starts_with(path, "rtp://")) return RARCH_CONTENT_MOVIE; switch (msg_hash_to_file_type(msg_hash_calculate(ext_lower))) From 41cee583e325ca8ac09a0d7a88065e4964e7fa06 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Wed, 20 May 2020 17:51:20 +0100 Subject: [PATCH 157/192] NUL terminate 'fps_text' string --- retroarch.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/retroarch.c b/retroarch.c index e30684d0a8..cd5c188acd 100644 --- a/retroarch.c +++ b/retroarch.c @@ -22636,6 +22636,9 @@ static void video_driver_frame(const void *data, unsigned width, bool widgets_active = gfx_widgets_active(); #endif + fps_text[0] = '\0'; + video_driver_msg[0] = '\0'; + if (!video_driver_active) return; @@ -22787,8 +22790,6 @@ static void video_driver_frame(const void *data, unsigned width, pitch = output_pitch; } - video_driver_msg[0] = '\0'; - if (runloop_msg_queue_size > 0) { /* If widgets are currently enabled, then From a3d3e1836986b332bd073de61043ee78ead5140d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 19:54:37 +0200 Subject: [PATCH 158/192] Update --- deps/discord-rpc/src/discord_rpc.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/deps/discord-rpc/src/discord_rpc.cpp b/deps/discord-rpc/src/discord_rpc.cpp index ddbdd12ef9..23b885f08e 100644 --- a/deps/discord-rpc/src/discord_rpc.cpp +++ b/deps/discord-rpc/src/discord_rpc.cpp @@ -14,8 +14,6 @@ #include #endif -#include - /* Forward declarations */ #ifdef __cplusplus extern "C" { @@ -184,7 +182,7 @@ static void Discord_UpdateConnection(void) /* in responses only -- * should use to match up response when needed. */ - if (evtName && string_is_equal(evtName, "ERROR")) + if (evtName && !strcmp(evtName, "ERROR")) { JsonValue *data = GetObjMember(&message, "data"); LastErrorCode = GetIntMember(data, "code"); @@ -200,7 +198,7 @@ static void Discord_UpdateConnection(void) JsonValue *data = GetObjMember(&message, "data"); - if (string_is_equal(evtName, "ACTIVITY_JOIN")) + if (!strcmp(evtName, "ACTIVITY_JOIN")) { const char *secret = GetStrMember(data, "secret"); if (secret) @@ -209,7 +207,7 @@ static void Discord_UpdateConnection(void) WasJoinGame.store(true); } } - else if (string_is_equal(evtName, "ACTIVITY_SPECTATE")) + else if (!strcmp(evtName, "ACTIVITY_SPECTATE")) { const char *secret = GetStrMember(data, "secret"); if (secret) @@ -218,7 +216,7 @@ static void Discord_UpdateConnection(void) WasSpectateGame.store(true); } } - else if (string_is_equal(evtName, "ACTIVITY_JOIN_REQUEST")) + else if (!strcmp(evtName, "ACTIVITY_JOIN_REQUEST")) { JsonValue *user = GetObjMember(data, "user"); const char *userId = GetStrMember(user, "id"); From 1eeb3dcf30c638c03e94822858e577285f1564e3 Mon Sep 17 00:00:00 2001 From: Francisco Javier Trujillo Mata Date: Mon, 7 Oct 2019 23:45:54 +0200 Subject: [PATCH 159/192] Adapt PS2 port to new SDK with newlib support (CDVDFS support is missing) --- Makefile.ps2 | 27 +- core_info.c | 2 +- frontend/drivers/platform_ps2.c | 25 - gfx/drivers/ps2_gfx.c | 136 +- gfx/drivers_font/ps2_font.c | 110 +- libretro-common/features/features_cpu.c | 8 +- libretro-common/file/config_file.c | 2 +- libretro-common/file/file_path.c | 7 +- libretro-common/file/file_path_io.c | 5 - libretro-common/include/compat/intrinsics.h | 2 +- libretro-common/include/compat/posix_string.h | 4 - libretro-common/include/compat/strcasestr.h | 4 - libretro-common/include/libretro_gskit_ps2.h | 4 +- libretro-common/include/retro_timers.h | 4 - libretro-common/rthreads/rthreads.c | 2 +- libretro-common/vfs/vfs_implementation.c | 93 +- menu/menu_driver.c | 2 - ps2/compat_files/compat_ctype.c | 476 ----- ps2/compat_files/fileXio_cdvd.c | 205 -- ps2/compat_files/ps2_descriptor.c | 145 -- ps2/compat_files/ps2_devices.c | 20 +- ps2/compat_files/time.c | 138 -- ps2/include/compat_ctype.h | 27 - ps2/include/fileXio_cdvd.h | 37 - ps2/include/inttypes.h | 22 - ps2/include/math.h | 38 - ps2/include/ps2_descriptor.h | 44 - ps2/include/ps2_irx_variables.h | 3 - ps2/include/pte_types.h | 38 - ps2/include/stdint.h | 44 - ps2/irx/Makefile | 13 +- ps2/libcdvd/Makefile | 19 - ps2/libcdvd/common/cdvd.h | 45 - ps2/libcdvd/ee/Makefile | 10 - ps2/libcdvd/ee/cdvd_rpc.c | 135 -- ps2/libcdvd/ee/cdvd_rpc.h | 28 - ps2/libcdvd/iop/Makefile | 12 - ps2/libcdvd/iop/Rules.make | 54 - ps2/libcdvd/iop/cdvd_iop.c | 1852 ----------------- ps2/libcdvd/iop/cdvd_iop.h | 84 - ps2/libcdvd/iop/imports.lst | 62 - ps2/libcdvd/iop/irx_imports.h | 9 - ps2/libcdvd/license.txt | 45 - verbosity.c | 2 - 44 files changed, 70 insertions(+), 3974 deletions(-) delete mode 100644 ps2/compat_files/compat_ctype.c delete mode 100644 ps2/compat_files/fileXio_cdvd.c delete mode 100644 ps2/compat_files/ps2_descriptor.c delete mode 100644 ps2/compat_files/time.c delete mode 100644 ps2/include/compat_ctype.h delete mode 100644 ps2/include/fileXio_cdvd.h delete mode 100644 ps2/include/inttypes.h delete mode 100644 ps2/include/math.h delete mode 100644 ps2/include/ps2_descriptor.h delete mode 100644 ps2/include/pte_types.h delete mode 100644 ps2/include/stdint.h delete mode 100644 ps2/libcdvd/Makefile delete mode 100644 ps2/libcdvd/common/cdvd.h delete mode 100644 ps2/libcdvd/ee/Makefile delete mode 100644 ps2/libcdvd/ee/cdvd_rpc.c delete mode 100644 ps2/libcdvd/ee/cdvd_rpc.h delete mode 100644 ps2/libcdvd/iop/Makefile delete mode 100644 ps2/libcdvd/iop/Rules.make delete mode 100644 ps2/libcdvd/iop/cdvd_iop.c delete mode 100644 ps2/libcdvd/iop/cdvd_iop.h delete mode 100644 ps2/libcdvd/iop/imports.lst delete mode 100644 ps2/libcdvd/iop/irx_imports.h delete mode 100644 ps2/libcdvd/license.txt diff --git a/Makefile.ps2 b/Makefile.ps2 index 05cadc6ab9..a1376e4ff3 100644 --- a/Makefile.ps2 +++ b/Makefile.ps2 @@ -11,8 +11,6 @@ PS2_IP = 192.168.1.150 TARGET = retroarchps2.elf TARGET_RELEASE = retroarchps2-release.elf -# Lib CDVD -CDVD_DIR = ps2/libcdvd # Compile the IRXs first IRX_DIR = ps2/irx @@ -30,7 +28,7 @@ ifeq ($(MUTE_WARNINGS), 1) DISABLE_WARNINGS := -Wno-sign-compare -Wno-unused -Wno-parentheses endif -INCDIR = -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ports/include -I$(CDVD_DIR)/ee +INCDIR = -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ports/include INCDIR += -Ips2 -Ips2/include -Ilibretro-common/include -Ideps -Ideps/stb -Ideps/7zip INCDIR += -Ideps/pthreads -Ideps/pthreads/platform/ps2 -Ideps/pthreads/platform/helper GPVAL = -G0 @@ -41,9 +39,9 @@ RARCH_DEFINES += -DPS2 -DUSE_IOP_CTYPE_MACRO -D_MIPS_ARCH_R5900 -DHAVE_ZLIB -DHA RARCH_DEFINES += -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DRARCH_CONSOLE -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_RGUI -DHAVE_FILTERS_BUILTIN -DHAVE_7ZIP -DHAVE_CC_RESAMPLER LIBDIR = -LDFLAGS += -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ee/lib -L$(CDVD_DIR)/lib -L. -LIBS += -lretro_ps2 -lgskit -ldmakit -lgskit_toolkit -laudsrv -lmf -lpadx -lmtap -lmc -lhdd -lsdl -lfileXio -lz -LIBS += -lcdvdfs -lpatches -lpoweroff +LDFLAGS += -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ee/lib -L. +LIBS += -lretro_ps2 -lgskit -ldmakit -lgskit_toolkit -laudsrv -lpadx -lmtap -lmc -lhdd -lsdl -lfileXio -lz +LIBS += -lpatches -lpoweroff ifeq ($(BUILD_FOR_PCSX2), 1) RARCH_DEFINES += -DBUILD_FOR_PCSX2 @@ -71,13 +69,10 @@ CFLAGS += $(RARCH_DEFINES) EE_OBJS += $(IRX_DIR)/freemtap_irx.o $(IRX_DIR)/freepad_irx.o $(IRX_DIR)/freesio2_irx.o $(IRX_DIR)/iomanX_irx.o EE_OBJS += $(IRX_DIR)/fileXio_irx.o $(IRX_DIR)/mcman_irx.o $(IRX_DIR)/mcserv_irx.o $(IRX_DIR)/usbd_irx.o EE_OBJS += $(IRX_DIR)/usbhdfsd_irx.o $(IRX_DIR)/freesd_irx.o $(IRX_DIR)/audsrv_irx.o $(IRX_DIR)/poweroff_irx.o -EE_OBJS += $(IRX_DIR)/cdvd_irx.o # Missing objecst on the PS2SDK -EE_OBJS += ps2/compat_files/compat_ctype.o ps2/compat_files/time.o ps2/compat_files/ps2_devices.o -EE_OBJS += ps2/compat_files/fileXio_cdvd.o ps2/compat_files/ps2_descriptor.o +EE_OBJS += ps2/compat_files/ps2_devices.o -#EE_OBJS = griffin/griffin.o bootstrap/ps2/kernel_functions.o EE_OBJS += griffin/griffin.o EE_CFLAGS = $(CFLAGS) @@ -106,7 +101,10 @@ prepare: run: ps2client -h $(PS2_IP) execee host:$(EE_BIN) -debug: clean prepare all run +sim: + PCSX2 --elf=$(PWD)/$(EE_BIN) --nogui + +debug: clean all run package: ps2-packer $(EE_BIN) $(TARGET_RELEASE) @@ -115,9 +113,4 @@ release: clean all package #Include preferences include $(PS2SDK)/samples/Makefile.pref -include $(PS2SDK)/samples/Makefile.eeglobal - -#Linking with C++ -$(EE_BIN): $(EE_OBJS) $(PS2SDK)/ee/startup/crt0.o - $(EE_CXX) $(EE_NO_CRT) -T$(PS2SDK)/ee/startup/linkfile $(EE_CXXFLAGS) \ - -o $(EE_BIN) $(PS2SDK)/ee/startup/crt0.o $(CRTI_OBJ) $(CRTBEGIN_OBJ) $(EE_OBJS) $(CRTEND_OBJ) $(CRTN_OBJ) $(EE_LDFLAGS) $(EE_LIBS) +include $(PS2SDK)/samples/Makefile.eeglobal_cpp diff --git a/core_info.c b/core_info.c index 9d82943909..e198ed782f 100644 --- a/core_info.c +++ b/core_info.c @@ -232,7 +232,7 @@ static config_file_t *core_info_list_iterate( current_path, info_path_base_size); -#if defined(RARCH_MOBILE) || (defined(RARCH_CONSOLE) && !defined(PSP) && !defined(_3DS) && !defined(VITA) && !defined(PS2) && !defined(HW_WUP)) +#if defined(RARCH_MOBILE) || (defined(RARCH_CONSOLE) && !defined(PSP) && !defined(_3DS) && !defined(VITA) && !defined(HW_WUP)) { char *substr = strrchr(info_path_base, '_'); if (substr) diff --git a/frontend/drivers/platform_ps2.c b/frontend/drivers/platform_ps2.c index e45f0b1953..f815fa1d33 100644 --- a/frontend/drivers/platform_ps2.c +++ b/frontend/drivers/platform_ps2.c @@ -16,7 +16,6 @@ #include "../frontend_driver.h" -#include #include #include #include @@ -27,12 +26,8 @@ #include #include #include -#include -#include -#include #include #include -#include char eboot_path[512]; char user_path[512]; @@ -186,9 +181,6 @@ static void frontend_ps2_init(void *data) SifExecModuleBuffer(&freesd_irx, size_freesd_irx, 0, NULL, NULL); SifExecModuleBuffer(&audsrv_irx, size_audsrv_irx, 0, NULL, NULL); - /* CDVD */ - SifExecModuleBuffer(&cdvd_irx, size_cdvd_irx, 0, NULL, NULL); - if (mcInit(MC_TYPE_XMC)) { RARCH_ERR("mcInit library not initalizated\n"); } @@ -210,20 +202,6 @@ static void frontend_ps2_init(void *data) RARCH_ERR("mtapPortOpen library not initalizated\n"); } - /* Initializes CDVD library */ - /* SCECdINoD init without check for a disc. Reduces risk of a lockup if the drive is in a erroneous state. */ - sceCdInit(SCECdINoD); - if (CDVD_Init() != 1) { - RARCH_ERR("CDVD_Init library not initalizated\n"); - } - - _init_ps2_io(); - - /* Prepare device */ - getcwd(cwd, sizeof(cwd)); - bootDeviceID=getBootDeviceID(cwd); - waitUntilDeviceIsReady(bootDeviceID); - #if defined(HAVE_FILE_LOGGER) retro_main_log_file_init("retroarch.log", false); verbosity_enable(); @@ -237,11 +215,8 @@ static void frontend_ps2_deinit(void *data) verbosity_disable(); command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL); #endif - _free_ps2_io(); - CDVD_Stop(); padEnd(); audsrv_quit(); - fileXioExit(); Exit(0); } diff --git a/gfx/drivers/ps2_gfx.c b/gfx/drivers/ps2_gfx.c index 5d6f86146b..6b7a977b2f 100644 --- a/gfx/drivers/ps2_gfx.c +++ b/gfx/drivers/ps2_gfx.c @@ -33,7 +33,6 @@ typedef struct ps2_video { - bool clearVRAM; /* I need to create this additional field * to be used in the font driver*/ bool clearVRAM_font; @@ -93,6 +92,8 @@ static GSTEXTURE *prepare_new_texture(void) static void init_ps2_video(ps2_video_t *ps2) { ps2->gsGlobal = init_GSGlobal(); + gsKit_TexManager_init(ps2->gsGlobal); + ps2->menuTexture = prepare_new_texture(); ps2->coreTexture = prepare_new_texture(); @@ -108,16 +109,8 @@ static void ps2_gfx_deinit_texture(GSTEXTURE *texture) texture->Clut = NULL; } -static bool texture_need_prepare(GSTEXTURE *texture, - int width, int height, int PSM) -{ - return texture->Width != width || - texture->Height != height || - texture->PSM != PSM; -} - -static void transfer_texture(GSTEXTURE *texture, const void *frame, - int width, int height, int PSM, int filter, bool color_correction) +static void set_texture(GSTEXTURE *texture, const void *frame, + int width, int height, int PSM, int filter) { texture->Width = width; texture->Height = height; @@ -126,25 +119,6 @@ static void transfer_texture(GSTEXTURE *texture, const void *frame, texture->Mem = (void *)frame; } -static void vram_alloc(GSGLOBAL *gsGlobal, GSTEXTURE *texture) -{ - uint32_t size = gsKit_texture_size(texture->Width, - texture->Height, texture->PSM); - texture->Vram = gsKit_vram_alloc(gsGlobal, size, GSKIT_ALLOC_USERBUFFER); - - if(texture->Vram == GSKIT_ALLOC_ERROR) - { - printf("VRAM Allocation Failed. Will not upload texture.\n"); - } - - if (texture->Clut) - { - /* Right now just supporting 16 x 16 = 256 colours */ - size = gsKit_texture_size(16, 16, texture->ClutPSM); - texture->VramClut = gsKit_vram_alloc(gsGlobal, size , GSKIT_ALLOC_USERBUFFER); - } -} - static void prim_texture(GSGLOBAL *gsGlobal, GSTEXTURE *texture, int zPosition, bool force_aspect, struct retro_hw_ps2_insets padding) { float x1, y1, x2, y2; @@ -185,65 +159,13 @@ static void prim_texture(GSGLOBAL *gsGlobal, GSTEXTURE *texture, int zPosition, GS_TEXT); } -static void clearVRAMIfNeeded(ps2_video_t *ps2, - const void *frame, int width, int height) -{ - if (!ps2->clearVRAM) - { - if(frame && frame != RETRO_HW_FRAME_BUFFER_VALID) - { - bool coreVRAMClear = texture_need_prepare( - ps2->coreTexture, width, height, ps2->PSM); - ps2->clearVRAM = ps2->clearVRAM || coreVRAMClear; - } - } - - if (ps2->clearVRAM) - { - gsKit_vram_clear(ps2->gsGlobal); - ps2->iface.updatedPalette = true; - /* we need to upload also palette in the font driver */ - ps2->clearVRAM_font = true; - } -} - static void refreshScreen(ps2_video_t *ps2) { if (ps2->vsync) gsKit_sync_flip(ps2->gsGlobal); gsKit_queue_exec(ps2->gsGlobal); + gsKit_TexManager_nextFrame(ps2->gsGlobal); - /* Here we are just puting in false the ps2->clearVRAM field - however, the ps2->clearVRAM_font should be done in the ps2_font driver */ - ps2->clearVRAM = false; -} - -static void ps2_texture_upload(GSGLOBAL *gsGlobal, GSTEXTURE *Texture, - bool sendPalette) -{ - gsKit_setup_tbw(Texture); - - if (Texture->PSM == GS_PSM_T8) - { - gsKit_texture_send(Texture->Mem, Texture->Width, Texture->Height, Texture->Vram, Texture->PSM, Texture->TBW, GS_CLUT_TEXTURE); - if (sendPalette) - { - gsKit_texture_send(Texture->Clut, 16, 16, Texture->VramClut, Texture->ClutPSM, 1, GS_CLUT_PALLETE); - } - - } - else if (Texture->PSM == GS_PSM_T4) - { - gsKit_texture_send(Texture->Mem, Texture->Width, Texture->Height, Texture->Vram, Texture->PSM, Texture->TBW, GS_CLUT_TEXTURE); - if (sendPalette) - { - gsKit_texture_send(Texture->Clut, 8, 2, Texture->VramClut, Texture->ClutPSM, 1, GS_CLUT_PALLETE); - } - } - else - { - gsKit_texture_send(Texture->Mem, Texture->Width, Texture->Height, Texture->Vram, Texture->PSM, Texture->TBW, GS_CLUT_NONE); - } } static void *ps2_gfx_init(const video_info_t *video, @@ -270,7 +192,6 @@ static void *ps2_gfx_init(const video_info_t *video, ps2->core_filter = video->smooth ? GS_FILTER_LINEAR : GS_FILTER_NEAREST; ps2->force_aspect = video->force_aspect; ps2->vsync = video->vsync; - ps2->clearVRAM = true; if (input && input_data) { @@ -294,43 +215,30 @@ static bool ps2_gfx_frame(void *data, const void *frame, return false; #if defined(DEBUG) - if (frame_count%60==0) - { + if (frame_count%180==0) printf("ps2_gfx_frame %lu\n", frame_count); - } #endif - clearVRAMIfNeeded(ps2, frame, width, height); - gsKit_clear(ps2->gsGlobal, GS_BLACK); - if (frame) { - bool sendPalette = false; struct retro_hw_ps2_insets padding = empty_ps2_insets; + /* Checking if the transfer is done in the core */ if (frame != RETRO_HW_FRAME_BUFFER_VALID) - { - /* Checking if the transfer is done in the core */ + { /* calculate proper width based in the pitch */ - int bytes_per_pixel = (ps2->PSM == GS_PSM_CT32) ? 4 : 2; - int real_width = pitch / bytes_per_pixel; - - transfer_texture(ps2->coreTexture, frame, real_width, height, ps2->PSM, ps2->core_filter, 1); + int shifh_per_bytes = (ps2->PSM == GS_PSM_CT32) ? 2 : 1; + int real_width = pitch >> shifh_per_bytes; + set_texture(ps2->coreTexture, frame, real_width, height, ps2->PSM, ps2->core_filter); padding.right = real_width - width; } else { - sendPalette = ps2->iface.updatedPalette; - ps2->iface.updatedPalette = false; padding = ps2->iface.padding; - if (ps2->iface.clearTexture) - ps2->iface.clearTexture = false; } - if(ps2->clearVRAM) - vram_alloc(ps2->gsGlobal, ps2->coreTexture); - - ps2_texture_upload(ps2->gsGlobal, ps2->coreTexture, sendPalette); + gsKit_TexManager_invalidate(ps2->gsGlobal, ps2->coreTexture); + gsKit_TexManager_bind(ps2->gsGlobal, ps2->coreTexture); prim_texture(ps2->gsGlobal, ps2->coreTexture, 1, ps2->force_aspect, padding); } @@ -339,9 +247,6 @@ static bool ps2_gfx_frame(void *data, const void *frame, bool texture_empty = !ps2->menuTexture->Width || !ps2->menuTexture->Height; if (!texture_empty) { - if(ps2->clearVRAM) - vram_alloc(ps2->gsGlobal, ps2->menuTexture); - gsKit_texture_upload(ps2->gsGlobal, ps2->menuTexture); prim_texture(ps2->gsGlobal, ps2->menuTexture, 2, ps2->fullscreen, empty_ps2_insets); } } @@ -412,12 +317,11 @@ static void ps2_set_texture_frame(void *data, const void *frame, bool rgb32, { ps2_video_t *ps2 = (ps2_video_t*)data; - bool color_correction = false; int PSM = (rgb32 ? GS_PSM_CT32 : GS_PSM_CT16); - bool texture_changed = texture_need_prepare(ps2->menuTexture, width, height, PSM); - transfer_texture(ps2->menuTexture, frame, width, height, PSM, ps2->menu_filter, color_correction); - ps2->clearVRAM = ps2->clearVRAM || texture_changed; + set_texture(ps2->menuTexture, frame, width, height, PSM, ps2->menu_filter); + gsKit_TexManager_invalidate(ps2->gsGlobal, ps2->menuTexture); + gsKit_TexManager_bind(ps2->gsGlobal, ps2->menuTexture); } static void ps2_set_texture_enable(void *data, bool enable, bool fullscreen) @@ -426,10 +330,8 @@ static void ps2_set_texture_enable(void *data, bool enable, bool fullscreen) if (ps2->menuVisible != enable) { - /* If Menu change status, CLEAR VRAM */ - ps2->clearVRAM = true; - ps2->iface.clearTexture = true; - ps2->iface.updatedPalette = true; + /* If Menu change status, CLEAR SCREEN */ + gsKit_clear(ps2->gsGlobal, GS_BLACK); } ps2->menuVisible = enable; ps2->fullscreen = fullscreen; @@ -439,8 +341,6 @@ static bool ps2_get_hw_render_interface(void* data, const struct retro_hw_render_interface** iface) { ps2_video_t *ps2 = (ps2_video_t*)data; - ps2->iface.clearTexture = ps2->clearVRAM; - ps2->iface.updatedPalette = true; ps2->iface.padding = empty_ps2_insets; *iface = (const struct retro_hw_render_interface*)&ps2->iface; diff --git a/gfx/drivers_font/ps2_font.c b/gfx/drivers_font/ps2_font.c index d0406a5b88..2010500708 100644 --- a/gfx/drivers_font/ps2_font.c +++ b/gfx/drivers_font/ps2_font.c @@ -13,17 +13,16 @@ * If not, see . */ +#include +#include +#include #include #include #include #include "../font_driver.h" -#define FONTM_VRAM_SIZE 4096 #define FONTM_TEXTURE_COLOR GS_SETREG_RGBAQ(0x80,0x80,0x80,0x80,0x00) -#define FONTM_TEXTURE_WIDTH 52 -#define FONTM_TEXTURE_HEIGHT 832 -#define FONTM_TEXTURE_SPACING 1.0f #define FONTM_TEXTURE_SCALED 0.5f #define FONTM_TEXTURE_LEFT_MARGIN 0 #define FONTM_TEXTURE_BOTTOM_MARGIN 15 @@ -35,87 +34,14 @@ typedef struct ps2_font_info GSFONTM *gsFontM; } ps2_font_info_t; -/* Copied from GSKIT FONTM CLUT - FONTM Textures are GS_PSM_T4, and need a 16x16 CLUT - This is a greyscale ramp CLUT, with linear alpha. */ -static u32 gsKit_fontm_clut[16] = { - 0x00000000, 0x11111111, 0x22222222, 0x33333333, \ - 0x44444444, 0x55555555, 0x66666666, 0x77777777, \ - 0x80888888, 0x80999999, 0x80AAAAAA, 0x80BBBBBB, \ - 0x80CCCCCC, 0x80DDDDDD, 0x80EEEEEE, 0x80FFFFFF -}; - -static void deinit_gsfont_texture(GSTEXTURE *texture) -{ - if (texture->Mem) - free(texture->Mem); - texture->Mem = NULL; - - if (texture->Mem) - free(texture->Clut); - texture->Clut = NULL; -} - -static void deinit_gsfont(GSFONTM *gsFontM) -{ - deinit_gsfont_texture(gsFontM->Texture); - free(gsFontM->TexBase); - gsFontM->TexBase = NULL; - free(gsFontM); -} - -static void ps2_prepare_font(GSGLOBAL *gsGlobal, GSFONTM *gsFontM) -{ - if (gsKit_fontm_unpack(gsFontM) == 0) - { - gsFontM->Texture->Width = FONTM_TEXTURE_WIDTH; - gsFontM->Texture->Height = FONTM_TEXTURE_HEIGHT; - gsFontM->Texture->PSM = GS_PSM_T4; - gsFontM->Texture->ClutPSM = GS_PSM_CT32; - gsFontM->Texture->Filter = GS_FILTER_LINEAR; - gsKit_setup_tbw(gsFontM->Texture); - } -} - -static void ps2_upload_font(GSGLOBAL *gsGlobal, GSFONTM *gsFontM) -{ - unsigned i; - int TexSize = gsKit_texture_size( - gsFontM->Texture->Width, - gsFontM->Texture->Height, - gsFontM->Texture->PSM); - - gsFontM->Texture->VramClut = gsKit_vram_alloc( - gsGlobal, FONTM_VRAM_SIZE, GSKIT_ALLOC_USERBUFFER); - - for (i = 0; i < GS_FONTM_PAGE_COUNT; ++i) - { - gsFontM->Vram[i] = gsKit_vram_alloc( - gsGlobal, TexSize, GSKIT_ALLOC_USERBUFFER); - gsFontM->LastPage[i] = (u32) -1; - } - - gsFontM->Texture->Vram = gsFontM->Vram[0]; - gsFontM->VramIdx = 0; - gsFontM->Spacing = FONTM_TEXTURE_SPACING; - gsFontM->Align = GSKIT_FALIGN_LEFT; - - gsFontM->Texture->Clut = memalign(GS_VRAM_TBWALIGN_CLUT, GS_VRAM_TBWALIGN); - memcpy(gsFontM->Texture->Clut, gsKit_fontm_clut, GS_VRAM_TBWALIGN); - gsKit_texture_send(gsFontM->Texture->Clut, 8, 2, gsFontM->Texture->VramClut, gsFontM->Texture->ClutPSM, 1, GS_CLUT_PALLETE); - free(gsFontM->Texture->Clut); -} - static void *ps2_font_init_font(void *gl_data, const char *font_path, float font_size, bool is_threaded) { ps2_font_info_t *ps2 = (ps2_font_info_t*)calloc(1, sizeof(ps2_font_info_t)); + ps2->ps2_video = (ps2_video_t *)gl_data; + ps2->gsFontM = gsKit_init_fontm(); - ps2->ps2_video = (ps2_video_t *)gl_data; - ps2->gsFontM = gsKit_init_fontm(); - - ps2_prepare_font(ps2->ps2_video->gsGlobal, ps2->gsFontM); - ps2_upload_font(ps2->ps2_video->gsGlobal, ps2->gsFontM); + gsKit_fontm_upload(ps2->ps2_video->gsGlobal, ps2->gsFontM); return ps2; } @@ -123,34 +49,26 @@ static void *ps2_font_init_font(void *gl_data, const char *font_path, static void ps2_font_free_font(void *data, bool is_threaded) { ps2_font_info_t *ps2 = (ps2_font_info_t *)data; - - deinit_gsfont(ps2->gsFontM); - + gsKit_free_fontm(ps2->ps2_video->gsGlobal, ps2->gsFontM); ps2->ps2_video = NULL; - ps2 = NULL; + + free(ps2); + ps2 = NULL; } static void ps2_font_render_msg( - void *userdata, - void *data, - const char *msg, + video_frame_info_t *video_info, + void *data, const char *msg, const struct font_params *params) { ps2_font_info_t *ps2 = (ps2_font_info_t *)data; - if (ps2) + if (ps2) { int x = FONTM_TEXTURE_LEFT_MARGIN; int y = ps2->ps2_video->gsGlobal->Height - FONTM_TEXTURE_BOTTOM_MARGIN; - - if (ps2->ps2_video->clearVRAM_font) - { - ps2_upload_font(ps2->ps2_video->gsGlobal, ps2->gsFontM); - ps2->ps2_video->clearVRAM_font = false; - } - gsKit_fontm_print_scaled( - ps2->ps2_video->gsGlobal, + ps2->ps2_video->gsGlobal, ps2->gsFontM, x, y, FONTM_TEXTURE_ZPOSITION, FONTM_TEXTURE_SCALED , FONTM_TEXTURE_COLOR, msg); } diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index 63d01427a4..09fd5462ca 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -70,9 +70,7 @@ #endif #if defined(PS2) -#include -#include -#include +#include #endif #if defined(__PSL1GHT__) @@ -192,7 +190,7 @@ retro_perf_tick_t cpu_features_get_perf_counter(void) #elif defined(PSP) || defined(VITA) time_ticks = sceKernelGetSystemTimeWide(); #elif defined(PS2) - time_ticks = clock()*294912; // 294,912MHZ / 1000 msecs + time_ticks = ps2_clock(); #elif defined(_3DS) time_ticks = svcGetSystemTick(); #elif defined(WIIU) @@ -244,7 +242,7 @@ retro_time_t cpu_features_get_time_usec(void) #elif defined(EMSCRIPTEN) return emscripten_get_now() * 1000; #elif defined(PS2) - return clock()*1000; + return ps2_clock() / PS2_CLOCKS_PER_MSEC * 1000; #elif defined(VITA) || defined(PSP) return sceKernelGetSystemTimeWide(); #elif defined(_3DS) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index a1b7de00a6..28ebf03233 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -1079,7 +1079,7 @@ bool config_file_write(config_file_t *conf, const char *path, bool sort) return false; /* TODO: this is only useful for a few platforms, find which and add ifdef */ -#if !defined(PS2) && !defined(PSP) +#if !defined(PSP) buf = calloc(1, 0x4000); setvbuf(file, (char*)buf, _IOFBF, 0x4000); #endif diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index e8cd688308..866d54e4cd 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -79,11 +79,6 @@ #include #endif -#if defined(PS2) -#include -#include -#endif - #if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) #include #endif @@ -92,7 +87,7 @@ #define FIO_S_ISDIR SCE_S_ISDIR #endif -#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP) || defined(PS2) +#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP) #include /* stat() is defined here */ #endif diff --git a/libretro-common/file/file_path_io.c b/libretro-common/file/file_path_io.c index 4ca02051df..a473f12a60 100644 --- a/libretro-common/file/file_path_io.c +++ b/libretro-common/file/file_path_io.c @@ -82,11 +82,6 @@ #include #endif -#if defined(PS2) -#include -#include -#endif - #if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) #include #endif diff --git a/libretro-common/include/compat/intrinsics.h b/libretro-common/include/compat/intrinsics.h index 56fcaff90d..6c7ecafcb8 100644 --- a/libretro-common/include/compat/intrinsics.h +++ b/libretro-common/include/compat/intrinsics.h @@ -41,7 +41,7 @@ RETRO_BEGIN_DECLS /* Count Leading Zero, unsigned 16bit input value */ static INLINE unsigned compat_clz_u16(uint16_t val) { -#if defined(__GNUC__) && !defined(PS2) +#if defined(__GNUC__) return __builtin_clz(val << 16 | 0x8000); #else unsigned ret = 0; diff --git a/libretro-common/include/compat/posix_string.h b/libretro-common/include/compat/posix_string.h index 51b2ec144f..47964b2a0f 100644 --- a/libretro-common/include/compat/posix_string.h +++ b/libretro-common/include/compat/posix_string.h @@ -29,10 +29,6 @@ #include #endif -#if defined(PS2) -#include -#endif - RETRO_BEGIN_DECLS #ifdef _WIN32 diff --git a/libretro-common/include/compat/strcasestr.h b/libretro-common/include/compat/strcasestr.h index ef6231217e..227e253e7b 100644 --- a/libretro-common/include/compat/strcasestr.h +++ b/libretro-common/include/compat/strcasestr.h @@ -25,10 +25,6 @@ #include -#if defined(PS2) -#include -#endif - #if defined(RARCH_INTERNAL) && defined(HAVE_CONFIG_H) #include "../../../config.h" #endif diff --git a/libretro-common/include/libretro_gskit_ps2.h b/libretro-common/include/libretro_gskit_ps2.h index 9bbe272422..033bb1f681 100644 --- a/libretro-common/include/libretro_gskit_ps2.h +++ b/libretro-common/include/libretro_gskit_ps2.h @@ -33,7 +33,7 @@ #include -#define RETRO_HW_RENDER_INTERFACE_GSKIT_PS2_VERSION 1 +#define RETRO_HW_RENDER_INTERFACE_GSKIT_PS2_VERSION 2 struct retro_hw_ps2_insets { @@ -57,8 +57,6 @@ struct retro_hw_render_interface_gskit_ps2 * in this interface. */ GSTEXTURE *coreTexture; - bool clearTexture; - bool updatedPalette; struct retro_hw_ps2_insets padding; }; typedef struct retro_hw_render_interface_gskit_ps2 RETRO_HW_RENDER_INTEFACE_GSKIT_PS2; diff --git a/libretro-common/include/retro_timers.h b/libretro-common/include/retro_timers.h index 0e6dd923e7..1b4b0c1d10 100644 --- a/libretro-common/include/retro_timers.h +++ b/libretro-common/include/retro_timers.h @@ -37,8 +37,6 @@ #include #elif defined(VITA) #include -#elif defined(PS2) -#include #elif defined(_3DS) #include <3ds.h> #else @@ -91,8 +89,6 @@ static INLINE void retro_sleep(unsigned msec) sys_timer_usleep(1000 * msec); #elif defined(PSP) || defined(VITA) sceKernelDelayThread(1000 * msec); -#elif defined(PS2) - SDL_Delay(msec); #elif defined(_3DS) svcSleepThread(1000000 * (s64)msec); #elif defined(__WINRT__) || defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP diff --git a/libretro-common/rthreads/rthreads.c b/libretro-common/rthreads/rthreads.c index d69069b1a5..97a7a1f834 100644 --- a/libretro-common/rthreads/rthreads.c +++ b/libretro-common/rthreads/rthreads.c @@ -872,7 +872,7 @@ bool scond_wait_timeout(scond_t *cond, slock_t *lock, int64_t timeout_us) now.tv_sec = s; now.tv_nsec = n; #elif defined(PS2) - int tickms = clock(); + int tickms = ps2_clock(); now.tv_sec = tickms/1000; now.tv_nsec = tickms * 1000; #elif defined(__mips__) || defined(VITA) || defined(_3DS) diff --git a/libretro-common/vfs/vfs_implementation.c b/libretro-common/vfs/vfs_implementation.c index 38d844bbc0..ab6bdacf6c 100644 --- a/libretro-common/vfs/vfs_implementation.c +++ b/libretro-common/vfs/vfs_implementation.c @@ -51,10 +51,6 @@ # if defined(PSP) # include # endif -# if defined(PS2) -# include -# include -# endif # include # include # if !defined(VITA) @@ -93,16 +89,13 @@ # if defined(PSP) # include # endif -# if defined(PS2) -# include -# endif # include # include # include # include #endif -#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP) || defined(PS2) +#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP) #include /* stat() is defined here */ #endif @@ -146,11 +139,6 @@ #include #endif -#if defined(PS2) -#include -#include -#endif - #if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) #include #endif @@ -207,14 +195,6 @@ int64_t retro_vfs_file_seek_internal(libretro_vfs_implementation_file *stream, i return _fseeki64(stream->fp, offset, whence); #elif defined(__CELLOS_LV2__) || defined(_MSC_VER) && _MSC_VER <= 1310 return fseek(stream->fp, (long)offset, whence); -#elif defined(PS2) - { - int64_t ret = fileXioLseek(fileno(stream->fp), (off_t)offset, whence); - /* fileXioLseek could return positive numbers */ - if (ret > 0) - return 0; - return ret; - } #elif defined(ORBIS) { int ret = orbisLseek(stream->fd, offset, whence); @@ -350,9 +330,7 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl( flags = O_WRONLY | O_CREAT | O_TRUNC; #if !defined(ORBIS) -#if defined(PS2) - flags |= FIO_S_IRUSR | FIO_S_IWUSR; -#elif !defined(_WIN32) +#if !defined(_WIN32) flags |= S_IRUSR | S_IWUSR; #else flags |= O_BINARY; @@ -364,9 +342,7 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl( mode_str = "w+b"; flags = O_RDWR | O_CREAT | O_TRUNC; #if !defined(ORBIS) -#if defined(PS2) - flags |= FIO_S_IRUSR | FIO_S_IWUSR; -#elif !defined(_WIN32) +#if !defined(_WIN32) flags |= S_IRUSR | S_IWUSR; #else flags |= O_BINARY; @@ -380,9 +356,7 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl( flags = O_RDWR; #if !defined(ORBIS) -#if defined(PS2) - flags |= FIO_S_IRUSR | FIO_S_IWUSR; -#elif !defined(_WIN32) +#if !defined(_WIN32) flags |= S_IRUSR | S_IWUSR; #else flags |= O_BINARY; @@ -438,7 +412,7 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl( * Since C89 does not support specifying a null buffer with a non-zero size, we create and track our own buffer for it. */ /* TODO: this is only useful for a few platforms, find which and add ifdef */ -#if !defined(PS2) && !defined(PSP) +#if !defined(PSP) if (stream->scheme != VFS_SCHEME_CDROM) { stream->buf = (char*)calloc(1, 0x4000); @@ -913,42 +887,6 @@ int retro_vfs_stat_impl(const char *path, int32_t *size) return RETRO_VFS_STAT_IS_VALID | (is_dir ? RETRO_VFS_STAT_IS_DIRECTORY : 0) | (is_character_special ? RETRO_VFS_STAT_IS_CHARACTER_SPECIAL : 0); -#elif defined(PS2) - /* PS2 */ - iox_stat_t buf; - bool is_dir; - bool is_character_special = false; - char *tmp = NULL; - size_t len = 0; - - if (!path || !*path) - return 0; - - tmp = strdup(path); - len = strlen(tmp); - if (tmp[len-1] == '/') - tmp[len-1] = '\0'; - - fileXioGetStat(tmp, &buf); - free(tmp); - - if (size) - *size = (int32_t)buf.size; - - if (!buf.mode) - { - /* if fileXioGetStat fails */ - int dir_ret = fileXioDopen(path); - is_dir = dir_ret > 0; - if (is_dir) { - fileXioDclose(dir_ret); - } - } - else - is_dir = FIO_S_ISDIR(buf.mode); - - return RETRO_VFS_STAT_IS_VALID | (is_dir ? RETRO_VFS_STAT_IS_DIRECTORY : 0) | (is_character_special ? RETRO_VFS_STAT_IS_CHARACTER_SPECIAL : 0); - #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) /* CellOS Lv2 */ bool is_dir; @@ -1058,8 +996,6 @@ int retro_vfs_mkdir_impl(const char *dir) int ret = mkdir(dir, 0755); #elif defined(VITA) || defined(PSP) int ret = sceIoMkdir(dir, 0777); -#elif defined(PS2) - int ret = fileXioMkdir(dir, 0777); #elif defined(ORBIS) int ret = orbisMkdir(dir, 0755); #elif defined(__QNX__) @@ -1092,9 +1028,6 @@ struct libretro_vfs_implementation_dir #elif defined(VITA) || defined(PSP) SceUID directory; SceIoDirent entry; -#elif defined(PS2) - int directory; - iox_dirent_t entry; #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) CellFsErrno error; int directory; @@ -1112,7 +1045,7 @@ static bool dirent_check_error(libretro_vfs_implementation_dir *rdir) { #if defined(_WIN32) return (rdir->directory == INVALID_HANDLE_VALUE); -#elif defined(VITA) || defined(PSP) || defined(PS2) || defined(ORBIS) +#elif defined(VITA) || defined(PSP) || defined(ORBIS) return (rdir->directory < 0); #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) return (rdir->error != CELL_FS_SUCCEEDED); @@ -1176,8 +1109,6 @@ libretro_vfs_implementation_dir *retro_vfs_opendir_impl( #elif defined(VITA) || defined(PSP) rdir->directory = sceIoDopen(name); -#elif defined(PS2) - rdir->directory = ps2fileXioDopen(name); #elif defined(_3DS) rdir->directory = !string_is_empty(name) ? opendir(name) : NULL; rdir->entry = NULL; @@ -1218,11 +1149,6 @@ bool retro_vfs_readdir_impl(libretro_vfs_implementation_dir *rdir) return (rdir->directory != INVALID_HANDLE_VALUE); #elif defined(VITA) || defined(PSP) return (sceIoDread(rdir->directory, &rdir->entry) > 0); -#elif defined(PS2) - iox_dirent_t record; - int ret = ps2fileXioDread(rdir->directory, &record); - rdir->entry = record; - return ( ret > 0); #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) uint64_t nread; rdir->error = cellFsReaddir(rdir->directory, &rdir->entry, &nread); @@ -1259,8 +1185,6 @@ const char *retro_vfs_dirent_get_name_impl(libretro_vfs_implementation_dir *rdir return (char*)rdir->entry.cFileName; #elif defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) || defined(ORBIS) return rdir->entry.d_name; -#elif defined(PS2) - return rdir->entry.name; #else if (!rdir || !rdir->entry) return NULL; @@ -1280,9 +1204,6 @@ bool retro_vfs_dirent_is_dir_impl(libretro_vfs_implementation_dir *rdir) #elif defined(VITA) return SCE_S_ISDIR(entry->d_stat.st_mode); #endif -#elif defined(PS2) - const iox_dirent_t *entry = (const iox_dirent_t*)&rdir->entry; - return FIO_S_ISDIR(entry->stat.mode); #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) CellFsDirent *entry = (CellFsDirent*)&rdir->entry; return (entry->d_type == CELL_FS_TYPE_DIRECTORY); @@ -1322,8 +1243,6 @@ int retro_vfs_closedir_impl(libretro_vfs_implementation_dir *rdir) FindClose(rdir->directory); #elif defined(VITA) || defined(PSP) sceIoDclose(rdir->directory); -#elif defined(PS2) - ps2fileXioDclose(rdir->directory); #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) rdir->error = cellFsClosedir(rdir->directory); #elif defined(ORBIS) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index c1b13ef273..f6083484ed 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -2162,10 +2162,8 @@ static bool menu_init(menu_handle_t *menu_data) configuration_set_bool(settings, settings->bools.menu_show_start_screen, false); -#if !(defined(PS2) && defined(DEBUG)) /* TODO: PS2 IMPROVEMENT */ if (config_save_on_exit) command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL); -#endif } #endif diff --git a/ps2/compat_files/compat_ctype.c b/ps2/compat_files/compat_ctype.c deleted file mode 100644 index 1766833c05..0000000000 --- a/ps2/compat_files/compat_ctype.c +++ /dev/null @@ -1,476 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2018 - Francisco Javier Trujillo Mata - fjtrujy - * - * 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 - -#define ULLONG_MAX UINT64_C(0xffffffffffffffff) - -/* All the functions included in this file either could be: - - Because the PS2SDK doesn't contains this specific functionality - - Because the PS2SDK implementation is wrong - - Overrriding these methods here, make that the RetroArch will execute this code - rather than the code in the linked libraries - */ - -int islower(int c) -{ - if ((c < 'a') || (c > 'z')) - return 0; - - /* passed both criteria, so it - * is a lower case alpha char */ - return 1; -} - -int tolower(int ch) -{ - if (ch >= 'A' && ch <= 'Z') - return ('a' + ch - 'A'); - return ch; -} - -int toupper(int c) -{ - if (islower(c)) - c -= 32; - - return c; -} - -int memcmp(const void *s1, const void *s2, unsigned int length) -{ - const char *a = s1; - const char *b = s2; - - while (length--) - { - if (*a++ != *b++) - return 1; - } - - return 0; -} - -void * memcpy (void *dest, const void *src, size_t len) -{ - char *d = dest; - const char *s = src; - while (len--) - *d++ = *s++; - return dest; -} - -void * memset (void *dest, int val, size_t len) -{ - unsigned char *ptr = dest; - while (len-- > 0) - *ptr++ = val; - return dest; -} - -int sprintf (char *s, const char *format, ...) -{ - va_list arg; - int done; - va_start (arg, format); - done = vsprintf (s, format, arg); - va_end (arg); - return done; -} - -char * strcat(char *dest, const char *src) -{ - size_t i,j; - for (i = 0; dest[i] != '\0'; i++) - ; - for (j = 0; src[j] != '\0'; j++) - dest[i+j] = src[j]; - dest[i+j] = '\0'; - return dest; -} - -char *strchr(const char *string, int c) -{ - while (*string) - { - if (*string == c) - return (char *)string; - string++; - } - - if (*string == c) - return (char *)string; - - return NULL; -} - -int strcmp(const char *s1, const char *s2) -{ - while (*s1 == *s2++) - if (*s1++ == 0) - return (0); - return (*(unsigned char *)s1 - *(unsigned char *)--s2); -} - -char * strcpy(char *to, const char *from) -{ - char *save = to; - - for (; (*to = *from) != '\0'; ++from, ++to); - return(save); -} - -size_t strcspn(const char *s1, const char *s2) -{ - const char *p, *spanp; - char c, sc; - - /* - * Stop as soon as we find any character from s2. Note that there - * must be a NUL in s2; it suffices to stop when we find that, too. - */ - for (p = s1;;) - { - c = *p++; - spanp = s2; - do - { - if ((sc = *spanp++) == c) - return (p - 1 - s1); - }while(sc != 0); - } - /* NOTREACHED */ -} - -size_t strlen(const char *str) -{ - const char *s; - - for (s = str; *s; ++s) - ; - return (s - str); -} - -char * strncat(char *dst, const char *src, size_t n) -{ - if (n != 0) - { - char *d = dst; - const char *s = src; - - while (*d != 0) - d++; - do - { - if ((*d = *s++) == 0) - break; - d++; - }while(--n != 0); - *d = 0; - } - return (dst); -} - -int strncmp(const char *s1, const char *s2, size_t n) -{ - if (n == 0) - return (0); - - do - { - if (*s1 != *s2++) - return (*(unsigned char *)s1 - *(unsigned char *)--s2); - if (*s1++ == 0) - break; - }while (--n != 0); - - return (0); -} - -char * strncpy(char *dst, const char *src, size_t n) -{ - if (n != 0) - { - char *d = dst; - const char *s = src; - - do - { - if ((*d++ = *s++) == 0) - { - /* NUL pad the remaining n-1 bytes */ - while (--n != 0) - *d++ = 0; - break; - } - }while(--n != 0); - } - return (dst); -} - -char * strpbrk(const char *s1, const char *s2) -{ - const char *scanp; - int c, sc; - - while ((c = *s1++) != 0) - { - for (scanp = s2; (sc = *scanp++) != 0;) - if (sc == c) - return ((char *)(s1 - 1)); - } - return (NULL); -} - -/* Do not link to strrchr() from libc */ -char * strrchr(const char *p, int ch) -{ - char *save; - - for (save = NULL;; ++p) - { - if (*p == (char) ch) - save = (char *)p; - if (!*p) - return(save); - } -} - -size_t strspn(const char *s1, const char *s2) -{ - const char *p = s1, *spanp; - char c, sc; - - /* - * Skip any characters in s2, excluding the terminating \0. - */ -cont: - c = *p++; - for (spanp = s2; (sc = *spanp++) != 0;) - if (sc == c) - goto cont; - return (p - 1 - s1); -} - -char *strstr(const char *string, const char *substring) -{ - char *strpos; - - if (string == 0) - return 0; - - if (strlen(substring) == 0) - return (char *)string; - - strpos = (char *)string; - - while (*strpos != 0) - { - if (strncmp(strpos, substring, strlen(substring)) == 0) - return strpos; - - strpos++; - } - - return 0; -} - -size_t strnlen(const char *str, size_t maxlen) -{ - const char *cp; - - for (cp = str; maxlen != 0 && *cp != '\0'; cp++, maxlen--) - ; - - return (size_t)(cp - str); -} - -char *strtok(char *strToken, const char *strDelimit) -{ - static char *start; - static char *end; - - if (strToken) - start = strToken; - else - { - if (*end == 0) - return 0; - - start = end; - } - - if (*start == 0) - return 0; - - /* Strip out any leading delimiters */ - while (strchr(strDelimit, *start)) - { - /* If a character from the delimiting string - * then skip past it */ - start++; - - if (*start == 0) - return 0; - } - - if (*start == 0) - return 0; - - end = start; - - while (*end != 0) - { - if (strchr(strDelimit, *end)) - { - /* if we find a delimiting character - * before the end of the string, then - * terminate the token and move the end - * pointer to the next character - */ - *end = 0; - end++; - return start; - } - end++; - } - - /* reached the end of the string before finding a delimiter - * so dont move on to the next character */ - return start; -} - -char * strtok_r (char *s, const char *delim, char **save_ptr) -{ - char *end; - if (!s) - s = *save_ptr; - if (*s == '\0') - { - *save_ptr = s; - return NULL; - } - /* Scan leading delimiters. */ - s += strspn (s, delim); - if (*s == '\0') - { - *save_ptr = s; - return NULL; - } - /* Find the end of the token. */ - end = s + strcspn (s, delim); - if (*end == '\0') - { - *save_ptr = end; - return s; - } - /* Terminate the token and make *SAVE_PTR point past it. */ - *end = '\0'; - *save_ptr = end + 1; - return s; -} - -unsigned long long strtoull(const char * __restrict nptr, - char ** __restrict endptr, int base) -{ - char c; - unsigned long long acc; - unsigned long long cutoff; - int neg, any, cutlim; - /* - * See strtoq for comments as to the logic used. - */ - const char *s = nptr; - - do - { - c = *s++; - }while(isspace((unsigned char)c)); - if (c == '-') - { - neg = 1; - c = *s++; - } - else - { - neg = 0; - if (c == '+') - c = *s++; - } - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) - { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - acc = any = 0; - if (base < 2 || base > 36) - goto noconv; - - cutoff = ULLONG_MAX / base; - cutlim = ULLONG_MAX % base; - for ( ; ; c = *s++) - { - if (c >= '0' && c <= '9') - c -= '0'; - else if (c >= 'A' && c <= 'Z') - c -= 'A' - 10; - else if (c >= 'a' && c <= 'z') - c -= 'a' - 10; - else - break; - if (c >= base) - break; - if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) - any = -1; - else - { - any = 1; - acc *= base; - acc += c; - } - } - if (any < 0) - { - acc = ULLONG_MAX; - errno = ERANGE; - } - else if (!any) - { -noconv: - errno = EINVAL; - } - else if (neg) - acc = -acc; - if (endptr) - *endptr = (char *)(any ? s - 1 : nptr); - return (acc); -} - -float strtof(const char* str, char** endptr) -{ - return (float) strtod(str, endptr); -} - -int link(const char *oldpath, const char *newpath) { return fileXioSymlink(oldpath, newpath); } -int unlink(const char *path) { return fileXioRemove(path); } -int rename(const char *source, const char *dest) { return fileXioRename(source, dest); } diff --git a/ps2/compat_files/fileXio_cdvd.c b/ps2/compat_files/fileXio_cdvd.c deleted file mode 100644 index 66ca035ad2..0000000000 --- a/ps2/compat_files/fileXio_cdvd.c +++ /dev/null @@ -1,205 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ps2_devices.h" -#include "ps2_descriptor.h" - -/* I dont know why but this line is totally needed */ -static SifRpcClientData_t clientInit __attribute__ ((aligned(64))); - -static int comp_entries_by_filename(const void *elem1, const void *elem2) -{ - return strcmp(((entries*)elem1)->filename, ((entries*)elem2)->filename); -} - -/* returns 1 if disc valid, else returns 0 */ -static int ps2_cdDiscValid(void) -{ - int cdmode = sceCdGetDiskType(); - - switch (cdmode) - { - case SCECdPSCD: - case SCECdPSCDDA: - case SCECdPS2CD: - case SCECdPS2CDDA: - case SCECdPS2DVD: - case SCECdCDDA: - case SCECdDVDV: - return 1; - case SCECdNODISC: - case SCECdDETCT: - case SCECdDETCTCD: - case SCECdDETCTDVDS: - case SCECdDETCTDVDD: - case SCECdUNKNOWN: - case SCECdIllegalMedia: - default: - return 0; - } -} - -static u64 cd_Timer(void) -{ - return (clock() / (CLOCKS_PER_SEC / 1000)); -} - -static void ps2_cdStop(void) -{ - CDVD_Stop(); - sceCdSync(0); -} - -static int prepareCDVD(void) -{ - u64 wait_start; - int cdmode = sceCdGetDiskType(); - - if (sceCdGetDiskType() <= SCECdUNKNOWN) - { - wait_start = cd_Timer(); - while ((cd_Timer() < wait_start + 500) && !ps2_cdDiscValid()) - { - if (cdmode == SCECdNODISC) - return 0; - } - if (cdmode == SCECdNODISC) - return 0; - if ((cdmode < SCECdPSCD) || (cdmode > SCECdPS2DVD)) - { - ps2_cdStop(); - return 0; - } - } - - return 1; -} - -static int listcdvd(const char *path, entries *FileEntry) -{ - static struct TocEntry TocEntryList[FILEENTRY_SIZE]; - char dir[1025]; - int i, n; - int t = 0; - int first_file_index; - - strcpy(dir, &path[5]); - - /* Directories first... */ - - CDVD_FlushCache(); - n = CDVD_GetDir(dir, NULL, CDVD_GET_DIRS_ONLY, - TocEntryList, FILEENTRY_SIZE, dir); - - for (i = 0; i < n; i++) - { - /* Skip pseudopaths "." and ".." */ - if (TocEntryList[i].fileProperties & 0x02 && (!strcmp( - TocEntryList[i].filename, ".") || !strcmp( - TocEntryList[i].filename, ".."))) - continue; - - FileEntry[t].dircheck = 1; - strcpy(FileEntry[t].filename, TocEntryList[i].filename); - t++; - - if (t >= FILEENTRY_SIZE - 2) - break; - } - - qsort(FileEntry, t, sizeof(entries), comp_entries_by_filename); - first_file_index = t; - - /* Now files only */ - - CDVD_FlushCache(); - n = CDVD_GetDir(dir, NULL, CDVD_GET_FILES_ONLY, TocEntryList, FILEENTRY_SIZE, dir); - - for (i = 0; i < n; i++) - { - /* Skip pseudopaths "." and ".." */ - if (TocEntryList[i].fileProperties & 0x02 && (!strcmp( - TocEntryList[i].filename, ".") || !strcmp( - TocEntryList[i].filename, ".."))) - continue; - - FileEntry[t].dircheck = 0; - strcpy(FileEntry[t].filename, TocEntryList[i].filename); - t++; - - if (t >= FILEENTRY_SIZE - 2) - break; - } - - qsort(FileEntry + first_file_index, t - first_file_index, - sizeof(entries), comp_entries_by_filename); - - return t; -} - -static int fileXioCDDread(int fd, iox_dirent_t *dirent) -{ - DescriptorTranslation *descriptor = __ps2_fd_grab(fd); - - if (descriptor && descriptor->current_folder_position < descriptor->items) - { - strcpy(dirent->name, descriptor->FileEntry[descriptor->current_folder_position].filename); - if (descriptor->FileEntry[descriptor->current_folder_position].dircheck) - dirent->stat.mode = FIO_S_IFDIR; - else - dirent->stat.mode = FIO_S_IFREG; - descriptor->current_folder_position++; - } - else - { - descriptor->current_folder_position = 0; - return 0; - } - - return 1; -} - -static int fileXioCDDopen(const char *name) -{ - if (prepareCDVD()) - { - int fd = __ps2_acquire_descriptor(); - DescriptorTranslation *descriptor = __ps2_fd_grab(fd); - descriptor->current_folder_position = 0; - descriptor->items = listcdvd(name, descriptor->FileEntry); - return fd; - } - return -1; -} - - -int ps2fileXioDopen(const char *name) -{ - enum BootDeviceIDs deviceID = getBootDeviceID((char *)name); - if (deviceID == BOOT_DEVICE_CDFS) - return fileXioCDDopen(name); - return fileXioDopen(name); -} - -int ps2fileXioDread(int fd, iox_dirent_t *dirent) -{ - if (is_fd_valid(fd)) - return fileXioCDDread(fd, dirent); - return fileXioDread(fd, dirent); -} - -int ps2fileXioDclose(int fd) -{ - if (is_fd_valid(fd)) - return __ps2_release_descriptor(fd); - else if (fd > 0) - return fileXioDclose(fd); - return -19; -} diff --git a/ps2/compat_files/ps2_descriptor.c b/ps2/compat_files/ps2_descriptor.c deleted file mode 100644 index e74807ab1e..0000000000 --- a/ps2/compat_files/ps2_descriptor.c +++ /dev/null @@ -1,145 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2018 - Francisco Javier Trujillo Mata - fjtrujy - * - * 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 - -static DescriptorTranslation *__ps2_fdmap[MAX_OPEN_FILES]; -static DescriptorTranslation __ps2_fdmap_pool[MAX_OPEN_FILES]; -static int _lock_sema_id = -1; - -static inline int _lock(void) { return(WaitSema(_lock_sema_id)); } - -static inline int _unlock(void) { return(SignalSema(_lock_sema_id)); } - -static int __ps2_fd_drop(DescriptorTranslation *map) -{ - _lock(); - - if (map->ref_count == 1) - { - map->ref_count--; - map->current_folder_position = -1; - free(map->FileEntry); - memset(map, 0, sizeof(DescriptorTranslation)); - } - else - map->ref_count--; - - _unlock(); - return 0; -} - -int is_fd_valid(int fd) -{ - /* Correct fd value */ - fd = MAX_OPEN_FILES - fd; - - return (fd >= 0) && (fd < MAX_OPEN_FILES) && (__ps2_fdmap[fd] != NULL); -} - -void _init_ps2_io(void) -{ - ee_sema_t sp; - - memset(__ps2_fdmap, 0, sizeof(__ps2_fdmap)); - memset(__ps2_fdmap_pool, 0, sizeof(__ps2_fdmap_pool)); - - sp.init_count = 1; - sp.max_count = 1; - sp.option = 0; - _lock_sema_id = CreateSema(&sp); -} - -void _free_ps2_io(void) -{ - _lock(); - _unlock(); - if(_lock_sema_id >= 0) DeleteSema(_lock_sema_id); -} - -int __ps2_acquire_descriptor(void) -{ - int fd = -1; - int i = 0; - _lock(); - - /* get free descriptor */ - for (fd = 0; fd < MAX_OPEN_FILES; ++fd) - { - if (!__ps2_fdmap[fd]) - { - /* get free pool */ - for (i = 0; i < MAX_OPEN_FILES; ++i) - { - if (__ps2_fdmap_pool[i].ref_count == 0) - { - __ps2_fdmap[fd] = &__ps2_fdmap_pool[i]; - __ps2_fdmap[fd]->ref_count = 1; - __ps2_fdmap[fd]->current_folder_position = -1; - __ps2_fdmap[fd]->FileEntry = - calloc(sizeof(entries), FILEENTRY_SIZE); - _unlock(); - return MAX_OPEN_FILES - fd; - } - } - } - } - - /* no mores descriptors available... */ - _unlock(); - return -1; -} - -int __ps2_release_descriptor(int fd) -{ - int res = -1; - - if (is_fd_valid(fd) && - __ps2_fd_drop(__ps2_fdmap[MAX_OPEN_FILES - fd]) >= 0) - { - _lock(); - /* Correct fd value */ - fd = MAX_OPEN_FILES - fd; - __ps2_fdmap[fd] = NULL; - res = 0; - _unlock(); - } - - return res; -} - -DescriptorTranslation *__ps2_fd_grab(int fd) -{ - DescriptorTranslation *map = NULL; - - _lock(); - - if (is_fd_valid(fd)) - { - /* Correct fd value */ - fd = MAX_OPEN_FILES - fd; - map = __ps2_fdmap[fd]; - - if (map) - map->ref_count++; - } - - _unlock(); - return map; -} diff --git a/ps2/compat_files/ps2_devices.c b/ps2/compat_files/ps2_devices.c index e9bb2ae405..7ba3fe87b2 100644 --- a/ps2/compat_files/ps2_devices.c +++ b/ps2/compat_files/ps2_devices.c @@ -15,9 +15,10 @@ #include #include +#include #include #include -#include +#include #define DEVICE_SLASH "/" @@ -160,14 +161,14 @@ enum BootDeviceIDs getBootDeviceID(char *path) bool waitUntilDeviceIsReady(enum BootDeviceIDs device_id) { - int openFile = - 1; - /* just in case we tried a unit that is not working/connected */ + DIR *dir; + int ret = 0; int retries = 3; char *rootDevice = rootDevicePath(device_id); - while(openFile < 0 && retries > 0) + while(dir == NULL && retries > 0) { - openFile = fileXioDopen(rootDevice); + dir = opendir(rootDevice); /* Wait untill the device is ready */ nopdelay(); nopdelay(); @@ -180,9 +181,10 @@ bool waitUntilDeviceIsReady(enum BootDeviceIDs device_id) retries--; } - - if (openFile > 0) - fileXioDclose(openFile); + if (dir) { + ret = 1; + closedir(dir); + } - return openFile >= 0; + return ret; } diff --git a/ps2/compat_files/time.c b/ps2/compat_files/time.c deleted file mode 100644 index 5bdf1642bf..0000000000 --- a/ps2/compat_files/time.c +++ /dev/null @@ -1,138 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2019 - Francisco Javier Trujillo Mata - fjtrujy - * - * 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 . - */ - -/* This file improve the content of the original time.c file that belong to the PS2SDK. -The original time.c contains 4 non-static methods - -void _ps2sdk_time_init(void); -void _ps2sdk_time_deinit(void); -clock_t clock(void); -time_t time(time_t *t); - -So we need to duplicate all the method because this way the compiler will avoid to import -the code that belong to the PS2SDK */ - -#include -#include -#include -#include -#include -#include - -#define STARTING_YEAR 2000 -#define MIN_SUPPORTED_YEAR 1970 -#define MAX_SUPPORTED_YEAR 2108 -#define SECS_MIN 60L -#define MINS_HOUR 60L -#define HOURS_DAY 24L -#define DAYS_YEAR 365L -#define DEC(x) (10*(x/16)+(x%16)) -int _days[] = {-1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364}; - -static time_t _gmtotime_t ( - int yr, /* 0 based */ - int mo, /* 1 based */ - int dy, /* 1 based */ - int hr, - int mn, - int sc - ) -{ - time_t seconds_from_1970 = -1; - - if ((yr >= MIN_SUPPORTED_YEAR) || (yr <= MAX_SUPPORTED_YEAR)) - { - long passed_seconds_current_day; - int passed_years = (long)yr - MIN_SUPPORTED_YEAR; /* Years after 1970 */ - /* Calculate days for these years */ - long passed_days = passed_years * DAYS_YEAR; - passed_days += (passed_years >> 2) * (DAYS_YEAR + 1); /* passed leap years */ - passed_days += dy + _days[mo - 1]; /* passed days in the year */ - - if (!(yr & 3) && (mo > 2)) - passed_days++; /* if current year, is a leap year */ - - passed_seconds_current_day = (((hr * MINS_HOUR) + mn) * SECS_MIN) + sc; - seconds_from_1970 = (passed_days * HOURS_DAY * MINS_HOUR * SECS_MIN) + passed_seconds_current_day; - } - - return seconds_from_1970; -} - -time_t ps2_time(time_t *t) -{ - time_t tim; - sceCdCLOCK clocktime; /* defined in libcdvd.h */ - - sceCdReadClock(&clocktime); /* libcdvd.a */ - configConvertToLocalTime(&clocktime); - - tim = _gmtotime_t (DEC(clocktime.year)+ STARTING_YEAR, - DEC(clocktime.month), - DEC(clocktime.day), - DEC(clocktime.hour), - DEC(clocktime.minute), - DEC(clocktime.second)); - - if (t) - *t = tim; - - return tim; -} - -/* Protected methods in libc */ -void _ps2sdk_time_init(void) -{ - SDL_Init(SDL_INIT_TIMER); -} - -/* Protected methods in libc */ -void _ps2sdk_time_deinit(void) -{ - SDL_QuitSubSystem(SDL_INIT_TIMER); -} - -clock_t clock(void) -{ - return SDL_GetTicks(); -} - -time_t time(time_t *t) -{ - time_t tim = -1; - /* TODO: This function need to be implemented again because the SDK one is not working fine */ - return tim; -} - -time_t mktime(struct tm *timeptr) -{ - time_t tim = -1; - /* TODO: This function need to be implemented again because the SDK one is not working fine */ - return tim; -} - -struct tm *localtime(const time_t *timep) -{ - return NULL; -} - -size_t strftime(char *s, size_t max, const char *format, const struct tm *tm) -{ - return -1; -} - -char *setlocale(int category, const char *locale) -{ - return NULL; -} diff --git a/ps2/include/compat_ctype.h b/ps2/include/compat_ctype.h deleted file mode 100644 index 2a0e17c993..0000000000 --- a/ps2/include/compat_ctype.h +++ /dev/null @@ -1,27 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2018 - Francisco Javier Trujillo Mata - fjtrujy - * - * 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 COMPAT_CTYPE_H -#define COMPAT_CTYPE_H - -char *strtok_r(char *str, const char *delim, char **saveptr); - -unsigned long long strtoull(const char * __restrict nptr, char ** __restrict endptr, int base); - -int link(const char *oldpath, const char *newpath); -int unlink(const char *path); - -float strtof (const char* str, char** endptr); - -#endif diff --git a/ps2/include/fileXio_cdvd.h b/ps2/include/fileXio_cdvd.h deleted file mode 100644 index ada31a1006..0000000000 --- a/ps2/include/fileXio_cdvd.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef PS2_CD_H -#define PS2_CD_H - -#include -#include -#include - -#define CDVD_INIT_INIT 0x00 -#define CDVD_INIT_NOCHECK 0x01 -#define CDVD_INIT_EXIT 0x05 - -typedef enum { - CDVD_TYPE_NODISK = 0x00, /* No Disc inserted */ - CDVD_TYPE_DETECT, /* Detecting disc type */ - CDVD_TYPE_DETECT_CD, - CDVD_TYPE_DETECT_DVDSINGLE, - CDVD_TYPE_DETECT_DVDDUAL, - CDVD_TYPE_UNKNOWN, /* Unknown disc type */ - - CDVD_TYPE_PS1CD = 0x10, /* PS1 CD with no CDDA tracks */ - CDVD_TYPE_PS1CDDA, /* PS1 CD with CDDA tracks */ - CDVD_TYPE_PS2CD, /* PS2 CD with no CDDA tracks */ - CDVD_TYPE_PS2CDDA, /* PS2 CD with CDDA tracks */ - CDVD_TYPE_PS2DVD, /* PS2 DVD */ - - CDVD_TYPE_CDDA = 0xFD, /* CDDA */ - CDVD_TYPE_DVDVIDEO, /* DVD Video */ - CDVD_TYPE_ILLEGAL, /* Illegal disk type */ -} CdvdDiscType_t; - -int cdInit(int); - -int ps2fileXioDopen(const char *name); -int ps2fileXioDread(int fd, iox_dirent_t *dirent); -int ps2fileXioDclose(int fd); - -#endif /* PS2_CD_H */ diff --git a/ps2/include/inttypes.h b/ps2/include/inttypes.h deleted file mode 100644 index a41fb2c406..0000000000 --- a/ps2/include/inttypes.h +++ /dev/null @@ -1,22 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2018 - Francisco Javier Trujillo Mata - fjtrujy - * - * 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 INTTYPES_H -#define INTTYPES_H - -#define PRId64 "lld" -#define PRIu64 "llu" -#define PRIuPTR "llu" - -#endif /* INTTYPES_H */ diff --git a/ps2/include/math.h b/ps2/include/math.h deleted file mode 100644 index 71f0f858fb..0000000000 --- a/ps2/include/math.h +++ /dev/null @@ -1,38 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2018 - Francisco Javier Trujillo Mata - fjtrujy - * - * 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 MATH_H -#define MATH_H - -#include -#define roundf(in) (in >= 0.0f ? floorf(in + 0.5f) : ceilf(in - 0.5f)) - -#define cos(x) ((double)cosf((float)x)) -#define pow(x, y) ((double)powf((float)x, (float)y)) -#define sin(x) ((double)sinf((float)x)) -#define ceil(x) ((double)ceilf((float)x)) -#define floor(x) ((double)floorf((float)x)) -#define sqrt(x) ((double)sqrtf((float)x)) -#define fabs(x) ((double)fabsf((float)(x))) -#define round(x) ((double)roundf((float)(x))) - -#define fmaxf(a, b) (((a) > (b)) ? (a) : (b)) -#define fminf(a, b) (((a) < (b)) ? (a) : (b)) - -#define exp(a) ((double)expf((float)a)) -#define log(a) ((double)logf((float)a)) - -#define fmod(a, b) (a - b * floor(a / b)); - -#endif //MATH_H diff --git a/ps2/include/ps2_descriptor.h b/ps2/include/ps2_descriptor.h deleted file mode 100644 index b54c8def7f..0000000000 --- a/ps2/include/ps2_descriptor.h +++ /dev/null @@ -1,44 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2018 - Francisco Javier Trujillo Mata - fjtrujy - * - * 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 PS2_DESCRIPTOR_H -#define PS2_DESCRIPTOR_H - -#include -#include - -#define MAX_OPEN_FILES 256 -#define FILEENTRY_SIZE 2048 - -typedef struct { - int dircheck; - char filename[256]; -} entries; - -typedef struct -{ - int ref_count; - int items; - int current_folder_position; - entries *FileEntry; -} DescriptorTranslation; - -void _init_ps2_io(void); -void _free_ps2_io(void); -int is_fd_valid(int fd); -int __ps2_acquire_descriptor(void); -int __ps2_release_descriptor(int fd); -DescriptorTranslation *__ps2_fd_grab(int fd); - -#endif /* PS2_DESCRIPTOR_H */ diff --git a/ps2/include/ps2_irx_variables.h b/ps2/include/ps2_irx_variables.h index 856d82e209..6bd3c8e9c6 100644 --- a/ps2/include/ps2_irx_variables.h +++ b/ps2/include/ps2_irx_variables.h @@ -57,9 +57,6 @@ extern unsigned int size_usbd_irx; extern unsigned char usbhdfsd_irx; extern unsigned int size_usbhdfsd_irx; -extern unsigned char cdvd_irx; -extern unsigned int size_cdvd_irx; - extern unsigned char audsrv_irx; extern unsigned int size_audsrv_irx; diff --git a/ps2/include/pte_types.h b/ps2/include/pte_types.h deleted file mode 100644 index 4da1ebac65..0000000000 --- a/ps2/include/pte_types.h +++ /dev/null @@ -1,38 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2018 - Francisco Javier Trujillo Mata - fjtrujy - * - * 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 PTE_TYPES_H -#define PTE_TYPES_H - -#include -#include -#include -#include - -/** UIDs are used to describe many different kernel objects. */ -typedef int SceUID; - -/* Misc. kernel types. */ -typedef unsigned int SceSize; -typedef int SceSSize; - -typedef unsigned char SceUChar; -typedef unsigned int SceUInt; - -/* File I/O types. */ -typedef int SceMode; -typedef long SceOff; -typedef long SceIores; - -#endif /* PTE_TYPES_H */ diff --git a/ps2/include/stdint.h b/ps2/include/stdint.h deleted file mode 100644 index cc2582c1f3..0000000000 --- a/ps2/include/stdint.h +++ /dev/null @@ -1,44 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2018 - Francisco Javier Trujillo Mata - fjtrujy - * - * 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 STDINT_H -#define STDINT_H - -typedef unsigned long uintptr_t; -typedef signed long intptr_t; - -typedef signed char int8_t; -typedef signed short int16_t; -typedef signed int int32_t; -typedef signed long int64_t; -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long uint64_t; - -#define STDIN_FILENO 0 /* standard input file descriptor */ -#define STDOUT_FILENO 1 /* standard output file descriptor */ -#define STDERR_FILENO 2 /* standard error file descriptor */ - -#define INT8_C(val) val##c -#define INT16_C(val) val##h -#define INT32_C(val) val##i -#define INT64_C(val) val##l - -#define UINT8_C(val) val##uc -#define UINT16_C(val) val##uh -#define UINT32_C(val) val##ui -#define UINT64_C(val) val##ul - -#endif /* STDINT_H */ diff --git a/ps2/irx/Makefile b/ps2/irx/Makefile index ce28efa15b..cc22763f9e 100644 --- a/ps2/irx/Makefile +++ b/ps2/irx/Makefile @@ -2,17 +2,13 @@ EE_BIN2C = bin2c IRX_DIR = $(PS2SDK)/iop/irx -#Specific folder for cdvd.irx -LIBCDVD_DIR = ../libcdvd -LIBCDVD_IRX_DIR = $(LIBCDVD_DIR)/lib - #IRX modules # IRX modules - modules have to be in IRX_DIR IRX_FILES += freemtap.irx freepad.irx freesio2.irx iomanX.irx fileXio.irx mcman.irx mcserv.irx usbd.irx usbhdfsd.irx IRX_FILES += freesd.irx audsrv.irx poweroff.irx -IRX_C_FILES = $(IRX_FILES:.irx=_irx.c) cdvd_irx.c +IRX_C_FILES = $(IRX_FILES:.irx=_irx.c) -all: cdvd irxs +all: irxs # Specific file name and output per IRX Module %.irx: @@ -20,13 +16,8 @@ all: cdvd irxs irxs: $(IRX_FILES) -cdvd: - $(MAKE) -C $(LIBCDVD_DIR) - $(EE_BIN2C) $(LIBCDVD_IRX_DIR)/$@.irx $@_irx.c $@_irx - clean: rm -f $(IRX_C_FILES) - $(MAKE) -C $(LIBCDVD_DIR) clean #Include preferences include $(PS2SDK)/samples/Makefile.pref diff --git a/ps2/libcdvd/Makefile b/ps2/libcdvd/Makefile deleted file mode 100644 index 765a8e05e4..0000000000 --- a/ps2/libcdvd/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# Remove the line below, if you want to disable silent mode -#.SILENT: - -all: lib/libcdvdfs.a lib/cdvd.irx - -lib: - mkdir -p $@ - -clean: - $(MAKE) -C ee clean - $(MAKE) -C iop clean - -lib/cdvd.irx: iop | lib - @echo Building IRX - $(MAKE) -C $< - -lib/libcdvdfs.a: ee | lib - @echo Building EE client - $(MAKE) -C $< diff --git a/ps2/libcdvd/common/cdvd.h b/ps2/libcdvd/common/cdvd.h deleted file mode 100644 index 516e0fc9dd..0000000000 --- a/ps2/libcdvd/common/cdvd.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef _CDVD_H -#define _CDVD_H - -// This header contains the common definitions for libcdvd -// that are used by both IOP and EE sides - -#define CDVD_IRX 0xB001337 -#define CDVD_FINDFILE 0x01 -#define CDVD_GETDIR 0x02 -#define CDVD_STOP 0x04 -#define CDVD_TRAYREQ 0x05 -#define CDVD_DISKREADY 0x06 -#define CDVD_FLUSHCACHE 0x07 -#define CDVD_GETSIZE 0x08 - - -struct TocEntry -{ - u32 fileLBA; - u32 fileSize; - u8 fileProperties; - u8 padding1[3]; - char filename[128 + 1]; - u8 padding2[3]; -} __attribute__((packed)); - - -enum CDVD_getMode { - CDVD_GET_FILES_ONLY = 1, - CDVD_GET_DIRS_ONLY = 2, - CDVD_GET_FILES_AND_DIRS = 3 -}; - -// Macros for TrayReq -#define CdTrayOpen 0 -#define CdTrayClose 1 -#define CdTrayCheck 2 - -// Macros for DiskReady -#define CdComplete 0x02 -#define CdNotReady 0x06 -#define CdBlock 0x00 -#define CdNonBlock 0x01 - -#endif // _CDVD_H diff --git a/ps2/libcdvd/ee/Makefile b/ps2/libcdvd/ee/Makefile deleted file mode 100644 index 9a079c88eb..0000000000 --- a/ps2/libcdvd/ee/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -EE_LIB = ../lib/libcdvdfs.a -EE_OBJS = cdvd_rpc.o - -all: $(EE_LIB) - -clean: - rm -f $(EE_LIB) $(EE_OBJS) - -include $(PS2SDK)/samples/Makefile.pref -include $(PS2SDK)/samples/Makefile.eeglobal diff --git a/ps2/libcdvd/ee/cdvd_rpc.c b/ps2/libcdvd/ee/cdvd_rpc.c deleted file mode 100644 index 14227a5bb8..0000000000 --- a/ps2/libcdvd/ee/cdvd_rpc.c +++ /dev/null @@ -1,135 +0,0 @@ -#include -#include -#include -#include -#include - -#include "cdvd_rpc.h" - -int k_sceSifDmaStat(unsigned int id); -static unsigned sbuff[0x1300] __attribute__((aligned(64))); -static SifRpcClientData_t cd0; - -int cdvd_inited = 0; - -int CDVD_Init() -{ - int i; - - while (1) { - if (SifBindRpc(&cd0, CDVD_IRX, 0) < 0) - return -1; // bind error - if (cd0.server != 0) - break; - i = 0x10000; - while (i--) - ; - } - - cdvd_inited = 1; - - return 0; -} - -int CDVD_DiskReady(int mode) -{ - if (!cdvd_inited) - return -1; - - sbuff[0] = mode; - - SifCallRpc(&cd0, CDVD_DISKREADY, 0, (void *)(&sbuff[0]), 4, (void *)(&sbuff[0]), 4, 0, 0); - - return sbuff[0]; -} - -int CDVD_FindFile(const char *fname, struct TocEntry *tocEntry) -{ - if (!cdvd_inited) - return -1; - - strncpy((char *)&sbuff, fname, 1024); - - SifCallRpc(&cd0, CDVD_FINDFILE, 0, (void *)(&sbuff[0]), 1024, (void *)(&sbuff[0]), sizeof(struct TocEntry) + 1024, 0, 0); - - memcpy(tocEntry, &sbuff[256], sizeof(struct TocEntry)); - - return sbuff[0]; -} - -void CDVD_Stop() -{ - if (!cdvd_inited) - return; - - SifCallRpc(&cd0, CDVD_STOP, 0, (void *)(&sbuff[0]), 0, (void *)(&sbuff[0]), 0, 0, 0); - - return; -} - -int CDVD_TrayReq(int mode) -{ - if (!cdvd_inited) - return -1; - - SifCallRpc(&cd0, CDVD_TRAYREQ, 0, (void *)(&sbuff[0]), 4, (void *)(&sbuff[0]), 4, 0, 0); - - return sbuff[0]; -} - -int CDVD_GetDir(const char *pathname, const char *extensions, enum CDVD_getMode getMode, struct TocEntry tocEntry[], unsigned int req_entries, char *new_pathname) -{ - unsigned int num_entries; - - if (!cdvd_inited) - return -1; - - // copy the requested pathname to the rpc buffer - strncpy((char *)sbuff, pathname, 1023); - - // copy in the extension list to the rpc buffer - if (extensions == NULL) { - // Can't copy in the extension list since there isnt one, so just null the string in the rpc buffer - sbuff[1024 / 4] = 0; - } else { - strncpy((char *)&sbuff[1024 / 4], extensions, 127); - } - - sbuff[1152 / 4] = getMode; - - sbuff[1156 / 4] = (int)tocEntry; - - sbuff[1160 / 4] = req_entries; - - SifWriteBackDCache(tocEntry, req_entries * sizeof(struct TocEntry)); - - // This will get the directory contents, and fill tocEntry via DMA - SifCallRpc(&cd0, CDVD_GETDIR, 0, (void *)(&sbuff[0]), 1024 + 128 + 4 + 4 + 4, (void *)(&sbuff[0]), 4 + 1024, 0, 0); - - num_entries = sbuff[0]; - - if (new_pathname != NULL) - strncpy(new_pathname, (char *)&sbuff[1], 1023); - - return (num_entries); -} - -void CDVD_FlushCache() -{ - if (!cdvd_inited) - return; - - SifCallRpc(&cd0, CDVD_FLUSHCACHE, 0, (void *)(&sbuff[0]), 0, (void *)(&sbuff[0]), 0, 0, 0); - - return; -} - -unsigned int CDVD_GetSize() -{ - if (!cdvd_inited) - return -1; - - SifCallRpc(&cd0, CDVD_GETSIZE, 0, (void *)(&sbuff[0]), 0, (void *)(&sbuff[0]), 4, 0, 0); - - return sbuff[0]; -} diff --git a/ps2/libcdvd/ee/cdvd_rpc.h b/ps2/libcdvd/ee/cdvd_rpc.h deleted file mode 100644 index 394adb73e7..0000000000 --- a/ps2/libcdvd/ee/cdvd_rpc.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _CDVD_RPC_H -#define _CDVD_RPC_H - -// include the common definitions -#include "../common/cdvd.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -int CDVD_Init(); -int CDVD_DiskReady(int mode); -int CDVD_FindFile(const char *fname, struct TocEntry *tocEntry); -void CDVD_Stop(); -int CDVD_TrayReq(int mode); -int CDVD_DiskReady(int mode); -int CDVD_GetDir(const char *pathname, const char *extensions, enum CDVD_getMode getMode, struct TocEntry tocEntry[], unsigned int req_entries, char *new_pathname); -void CDVD_FlushCache(); -unsigned int CDVD_GetSize(); - - -#ifdef __cplusplus -} -#endif - - -#endif // _CDVD_H diff --git a/ps2/libcdvd/iop/Makefile b/ps2/libcdvd/iop/Makefile deleted file mode 100644 index c1dfd7c6c3..0000000000 --- a/ps2/libcdvd/iop/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -IOP_BIN = ../lib/cdvd.irx - -IOP_OBJS = cdvd_iop.o imports.o - - -all: $(IOP_BIN) - -clean: - rm -f $(IOP_BIN) $(IOP_OBJS) - -include $(PS2SDK)/Defs.make -include Rules.make diff --git a/ps2/libcdvd/iop/Rules.make b/ps2/libcdvd/iop/Rules.make deleted file mode 100644 index 3a53febbe3..0000000000 --- a/ps2/libcdvd/iop/Rules.make +++ /dev/null @@ -1,54 +0,0 @@ -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004. -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. - - -IOP_CC_VERSION := $(shell $(IOP_CC) -v 2>&1 | sed -n 's/^.*version //p') - -ASFLAGS_TARGET = -mcpu=r3000 - -ifeq ($(IOP_CC_VERSION),3.2.2) -CFLAGS_TARGET = -miop -ASFLAGS_TARGET = -march=r3000 -LDFLAGS_TARGET = -miop -endif - -IOP_INCS := $(IOP_INCS) -I$(PS2SDK)/iop/include -I$(PS2SDK)/common/include - -IOP_CFLAGS := $(CFLAGS_TARGET) -O2 -G0 -D_IOP -c $(IOP_INCS) $(IOP_CFLAGS) -IOP_ASFLAGS := $(ASFLAGS_TARGET) -EL -G0 $(IOP_ASFLAGS) -IOP_LDFLAGS := $(LDFLAGS_TARGET) -nostdlib $(IOP_LDFLAGS) - -# Externally defined variables: IOP_BIN, IOP_OBJS, IOP_LIB - -%.o : %.c - $(IOP_CC) $(IOP_CFLAGS) $< -o $@ - -%.o : %.s - $(IOP_AS) $(IOP_ASFLAGS) $< -o $@ - -# A rule to build imports.lst. -%.o : %.lst - echo "#include \"irx_imports.h\"" > build-imports.c - cat $< >> build-imports.c - $(IOP_CC) $(IOP_CFLAGS) build-imports.c -o $@ - -rm -f build-imports.c - -# A rule to build exports.tab. -%.o : %.tab - echo "#include \"irx.h\"" > build-exports.c - cat $< >> build-exports.c - $(IOP_CC) $(IOP_CFLAGS) build-exports.c -o $@ - -rm -f build-exports.c - - -$(IOP_BIN) : $(IOP_OBJS) - $(IOP_CC) $(IOP_LDFLAGS) -o $(IOP_BIN) $(IOP_OBJS) $(IOP_LIBS) - -$(IOP_LIB) : $(IOP_OBJS) - $(IOP_AR) cru $(IOP_LIB) $(IOP_OBJS) - diff --git a/ps2/libcdvd/iop/cdvd_iop.c b/ps2/libcdvd/iop/cdvd_iop.c deleted file mode 100644 index 6fd3b8dd6c..0000000000 --- a/ps2/libcdvd/iop/cdvd_iop.c +++ /dev/null @@ -1,1852 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "cdvd_iop.h" - -#define TRUE 1 -#define FALSE 0 - -enum PathMatch { - NOT_MATCH = 0, - MATCH, - SUBDIR -}; - -//#define DEBUG - -// 16 sectors worth of toc entry -#define MAX_DIR_CACHE_SECTORS 32 - - -//static u8 cdVolDescriptor[2048]; -static sceCdRMode cdReadMode; - -int lastsector; -int last_bk = 0; - - -struct rootDirTocHeader -{ - u16 length; - u32 tocLBA; - u32 tocLBA_bigend; - u32 tocSize; - u32 tocSize_bigend; - u8 dateStamp[8]; - u8 reserved[6]; - u8 reserved2; - u8 reserved3; -} __attribute__((packed)); - -struct asciiDate -{ - char year[4]; - char month[2]; - char day[2]; - char hours[2]; - char minutes[2]; - char seconds[2]; - char hundreths[2]; - char terminator[1]; -} __attribute__((packed)); - -struct cdVolDesc -{ - u8 filesystemType; // 0x01 = ISO9660, 0x02 = Joliet, 0xFF = NULL - u8 volID[5]; // "CD001" - u8 reserved2; - u8 reserved3; - u8 sysIdName[32]; - u8 volName[32]; // The ISO9660 Volume Name - u8 reserved5[8]; - u32 volSize; // Volume Size - u32 volSizeBig; // Volume Size Big-Endian - u8 reserved6[32]; - u32 unknown1; - u32 unknown1_bigend; - u16 volDescSize; - u16 volDescSize_bigend; - u32 unknown3; - u32 unknown3_bigend; - u32 priDirTableLBA; // LBA of Primary Dir Table - u32 reserved7; - u32 secDirTableLBA; // LBA of Secondary Dir Table - u32 reserved8; - struct rootDirTocHeader rootToc; - u8 volSetName[128]; - u8 publisherName[128]; - u8 preparerName[128]; - u8 applicationName[128]; - u8 copyrightFileName[37]; - u8 abstractFileName[37]; - u8 bibliographyFileName[37]; - struct asciiDate creationDate; - struct asciiDate modificationDate; - struct asciiDate effectiveDate; - struct asciiDate expirationDate; - u8 reserved10; - u8 reserved11[1166]; -} __attribute__((packed)); - -struct dirTableEntry -{ - u8 dirNameLength; - u8 reserved; - u32 dirTOCLBA; - u16 dirDepth; - u8 dirName[32]; -} __attribute__((packed)); - -struct dirTocEntry -{ - short length; - unsigned int fileLBA; - unsigned int fileLBA_bigend; - unsigned int fileSize; - unsigned int fileSize_bigend; - unsigned char dateStamp[6]; - unsigned char reserved1; - unsigned char fileProperties; - unsigned char reserved2[6]; - unsigned char filenameLength; - unsigned char filename[128]; -} __attribute__((packed)); // This is the internal format on the CD -// a file with a single character filename will have a 34byte toc entry -// (max 60 entries per sector)6 - -// TocEntry structure contains only the important stuff needed for export -// - -struct fdtable -{ - iop_file_t *fd; - int fileSize; - int LBA; - int filePos; -}; - - -struct dir_cache_info -{ - char pathname[1024]; // The pathname of the cached directory - unsigned int valid; // TRUE if cache data is valid, FALSE if not - - unsigned int path_depth; // The path depth of the cached directory (0 = root) - - unsigned int sector_start; // The start sector (LBA) of the cached directory - unsigned int sector_num; // The total size of the directory (in sectors) - unsigned int cache_offset; // The offset from sector_start of the cached area - unsigned int cache_size; // The size of the cached directory area (in sectors) - - char *cache; // The actual cached data -}; - - -static struct dir_cache_info CachedDirInfo; - -enum Cache_getMode { - CACHE_START = 0, - CACHE_NEXT = 1 -}; - -static struct cdVolDesc CDVolDesc; - -static unsigned int *buffer; // RPC send/receive buffer -struct t_SifRpcDataQueue qd; -struct t_SifRpcServerData sd0; - - -static struct fdtable fd_table[16]; -static int fd_used[16]; -static int files_open; - -static iop_device_t file_driver; - -/* Filing-system exported functions */ -int CDVD_init(iop_device_t *driver); -int CDVD_open(iop_file_t *f, const char *name, int mode); -int CDVD_lseek(iop_file_t *f, int offset, int whence); -int CDVD_read(iop_file_t *f, void *buffer, int size); -int CDVD_write(iop_file_t *f, void *buffer, int size); -int CDVD_close(iop_file_t *f); - -/* RPC exported functions */ -int CDVD_findfile(const char *fname, struct TocEntry *tocEntry); -int CDVD_stop(void); -int CDVD_trayreq(int mode); -int CDVD_diskready(void); -int CDVD_GetDir_RPC(const char *pathname, const char *extensions, enum CDVD_getMode getMode, struct TocEntry tocEntry[], unsigned int req_entries); - -int CDVD_getdir_IOP(const char *pathname, const char *extensions, enum CDVD_getMode getMode, struct TocEntry tocEntry[], unsigned int req_entries); - - -// Functions called by the RPC server -void *CDVDRpc_Stop(); -void *CDVDRpc_FlushCache(); -void *CDVDRpc_TrayReq(unsigned int *sbuff); -void *CDVDRpc_DiskReady(unsigned int *sbuff); -void *CDVDRpc_FindFile(unsigned int *sbuff); -void *CDVDRpc_Getdir(unsigned int *sbuff); -void *CDVDRpc_GetSize(unsigned int *sbuff); - - -/* Internal use functions */ -int isValidDisc(void); -int strcasecmp(const char *s1, const char *s2); -int strncasecmp(const char *s1, const char *s2, int limit); -int CDVD_GetVolumeDescriptor(void); -void _splitpath(const char *constpath, char *dir, char *fname); -void TocEntryCopy(struct TocEntry *tocEntry, struct dirTocEntry *internalTocEntry); -int TocEntryCompare(char *filename, const char *extensions); - -enum PathMatch ComparePath(const char *path); - -int CDVD_Cache_Dir(const char *pathname, enum Cache_getMode getMode); -int FindPath(char *pathname); - - -void *CDVD_rpc_server(int fno, void *data, int size); -void CDVD_Thread(void *param); - - - -/******************** -* Optimised CD Read * -********************/ - -int ReadSect(u32 lsn, u32 sectors, void *buf, sceCdRMode *mode) -{ - int retry; - int result = 0; - cdReadMode.trycount = 32; - - for (retry = 0; retry < 32; retry++) // 32 retries - { - if (retry <= 8) - cdReadMode.spindlctrl = 1; // Try fast reads for first 8 tries - else - cdReadMode.spindlctrl = 0; // Then try slow reads - - if (!isValidDisc()) - return FALSE; - - sceCdDiskReady(0); - - if (sceCdRead(lsn, sectors, buf, mode) != TRUE) { - // Failed to read - if (retry == 31) { - // Still failed after last retry - memset(buf, 0, (sectors << 11)); - // printf("Couldn't Read from file for some reason\n"); - return FALSE; // error - } - } else { - // Read okay - sceCdSync(0); - break; - } - - result = sceCdGetError(); - if (result == 0) - break; - } - - cdReadMode.trycount = 32; - cdReadMode.spindlctrl = 1; - - if (result == 0) - return TRUE; - - memset(buf, 0, (sectors << 11)); - - return FALSE; // error -} - -/*********************************************** -* Determines if there is a valid disc inserted * -***********************************************/ -int isValidDisc(void) -{ - int result; - - switch (sceCdGetDiskType()) { - case SCECdPSCD: - case SCECdPSCDDA: - case SCECdPS2CD: - case SCECdPS2CDDA: - case SCECdPS2DVD: - result = 1; - break; - default: - result = 0; - } - - return result; -} - -/************************************************************* -* The functions below are the normal file-system operations, * -* used to provide a standard filesystem interface. There is * -* no need to export these functions for calling via RPC * -*************************************************************/ -int dummy() -{ -#ifdef DEBUG - printf("CDVD: dummy function called\n"); -#endif - - return -5; -} - -int CDVD_init(iop_device_t *driver) -{ - printf("CDVD: CDVD Filesystem v1.15\n"); - printf("by A.Lee (aka Hiryu) & Nicholas Van Veen (aka Sjeep)\n"); - printf("CDVD: Initializing '%s' file driver.\n", driver->name); - - sceCdInit(SCECdINoD); - - memset(fd_table, 0, sizeof(fd_table)); - memset(fd_used, 0, 16 * 4); - - return 0; -} - -int CDVD_deinit(iop_device_t *driver) -{ - return 0; -} - -int CDVD_open(iop_file_t *f, const char *name, int mode) -{ - int j; - static struct TocEntry tocEntry; - -#ifdef DEBUG - printf("CDVD: fd_open called.\n"); - printf(" kernel_fd.. %p\n", f); - printf(" name....... %s %x\n", name, (int)name); - printf(" mode....... %d\n\n", mode); -#endif - - // check if the file exists - if (CDVD_findfile(name, &tocEntry) != TRUE) { - return -1; - } - - if (mode != O_RDONLY) - return -2; - - // set up a new file descriptor - for (j = 0; j < 16; j++) { - if (fd_used[j] == 0) - break; - } - - if (j >= 16) - return -3; - - - fd_used[j] = 1; - files_open++; - -#ifdef DEBUG - printf("CDVD: internal fd %d\n", j); -#endif - - fd_table[j].fd = f; - fd_table[j].fileSize = tocEntry.fileSize; - fd_table[j].LBA = tocEntry.fileLBA; - fd_table[j].filePos = 0; - -#ifdef DEBUG - printf("tocEntry.fileSize = %d\n", tocEntry.fileSize); - - printf("Opened file: %s\n", name); -#endif - - return j; -} - - - -int CDVD_lseek(iop_file_t *f, int offset, int whence) -{ - int i; - -#ifdef DEBUG - printf("CDVD: fd_seek called.\n"); - printf(" kernel_fd... %p\n", f); - printf(" offset...... %d\n", offset); - printf(" whence...... %d\n\n", whence); -#endif - - for (i = 0; i < 16; i++) { - if (fd_table[i].fd == f) - break; - } - - if (i >= 16) { -#ifdef DEBUG - printf("CDVD_lseek: ERROR: File does not appear to be open!\n"); -#endif - - return -1; - } - - switch (whence) { - case SEEK_SET: - fd_table[i].filePos = offset; - break; - - case SEEK_CUR: - fd_table[i].filePos += offset; - break; - - case SEEK_END: - fd_table[i].filePos = fd_table[i].fileSize + offset; - break; - - default: - return -1; - } - - if (fd_table[i].filePos < 0) - fd_table[i].filePos = 0; - - if (fd_table[i].filePos > fd_table[i].fileSize) - fd_table[i].filePos = fd_table[i].fileSize; - - return fd_table[i].filePos; -} - - -int CDVD_read(iop_file_t *f, void *buffer, int size) -{ - int i; - - int start_sector; - int off_sector; - int num_sectors; - - int read = 0; - // int sector; - - // int size_left; - // int copy_size; - - static char local_buffer[9 * 2048]; - - -#ifdef DEBUG - printf("CDVD: read called\n"); - printf(" kernel_fd... %p\n", f); - printf(" buffer...... 0x%X\n", (int)buffer); - printf(" size........ %d\n\n", size); -#endif - - for (i = 0; i < 16; i++) { - if (fd_table[i].fd == f) - break; - } - - if (i >= 16) { -#ifdef DEBUG - printf("CDVD_read: ERROR: File does not appear to be open!\n"); -#endif - - return -1; - } - - - // A few sanity checks - if (fd_table[i].filePos > fd_table[i].fileSize) { - // We cant start reading from past the beginning of the file - return 0; // File exists but we couldnt read anything from it - } - - if ((fd_table[i].filePos + size) > fd_table[i].fileSize) - size = fd_table[i].fileSize - fd_table[i].filePos; - - if (size <= 0) - return 0; - - if (size > 16384) - size = 16384; - - // Now work out where we want to start reading from - start_sector = fd_table[i].LBA + (fd_table[i].filePos >> 11); - off_sector = (fd_table[i].filePos & 0x7FF); - - num_sectors = (off_sector + size); - num_sectors = (num_sectors >> 11) + ((num_sectors & 2047) != 0); - -#ifdef DEBUG - printf("CDVD_read: read sectors %d to %d\n", start_sector, start_sector + num_sectors); -#endif - - // Skip a Sector for equal (use the last sector in buffer) - if (start_sector == lastsector) { - read = 1; - if (last_bk > 0) - memcpy(local_buffer, local_buffer + 2048 * (last_bk), 2048); - last_bk = 0; - } - - lastsector = start_sector + num_sectors - 1; - // Read the data (we only ever get 16KB max request at once) - - if (read == 0 || (read == 1 && num_sectors > 1)) { - if (ReadSect(start_sector + read, num_sectors - read, local_buffer + ((read) << 11), &cdReadMode) != TRUE) { -#ifdef DEBUG - printf("Couldn't Read from file for some reason\n"); -#endif - } - - last_bk = num_sectors - 1; - } - - memcpy(buffer, local_buffer + off_sector, size); - - fd_table[i].filePos += size; - - return (size); -} - - -int CDVD_write(iop_file_t *f, void *buffer, int size) -{ - if (size == 0) - return 0; - else - return -1; -} - - - -int CDVD_close(iop_file_t *f) -{ - int i; - -#ifdef DEBUG - printf("CDVD: fd_close called.\n"); - printf(" kernel fd.. %p\n\n", f); -#endif - - for (i = 0; i < 16; i++) { - if (fd_table[i].fd == f) - break; - } - - if (i >= 16) { -#ifdef DEBUG - printf("CDVD_close: ERROR: File does not appear to be open!\n"); -#endif - - return -1; - } - -#ifdef DEBUG - printf("CDVD: internal fd %d\n", i); -#endif - - fd_used[i] = 0; - files_open--; - - return 0; -} - - -static iop_device_ops_t filedriver_ops = { - &CDVD_init, - &CDVD_deinit, - (void *)&dummy, - &CDVD_open, - &CDVD_close, - &CDVD_read, - &CDVD_write, - &CDVD_lseek, - (void *)&dummy, - (void *)&dummy, - (void *)&dummy, - (void *)&dummy, - (void *)&dummy, - (void *)&dummy, - (void *)&dummy, - (void *)&dummy, - (void *)&dummy}; - -int _start(int argc, char **argv) -{ - int i; - struct _iop_thread param; - int th; - - // Initialise the directory cache - strcpy(CachedDirInfo.pathname, ""); // The pathname of the cached directory - CachedDirInfo.valid = FALSE; // Cache is not valid - CachedDirInfo.path_depth = 0; // 0 = root) - CachedDirInfo.sector_start = 0; // The start sector (LBA) of the cached directory - CachedDirInfo.sector_num = 0; // The total size of the directory (in sectors) - CachedDirInfo.cache_offset = 0; // The offset from sector_start of the cached area - CachedDirInfo.cache_size = 0; // The size of the cached directory area (in sectors) - - if (CachedDirInfo.cache == NULL) - CachedDirInfo.cache = (char *)AllocSysMemory(0, MAX_DIR_CACHE_SECTORS * 2048, NULL); - - - // setup the cdReadMode structure - cdReadMode.trycount = 0; - cdReadMode.spindlctrl = SCECdSpinStm; - cdReadMode.datapattern = SCECdSecS2048; - - // setup the file_driver structure - file_driver.name = "cdfs"; - file_driver.type = IOP_DT_FS; - file_driver.version = 1; - file_driver.desc = "CDVD Filedriver"; - file_driver.ops = &filedriver_ops; - - DelDrv("cdfs"); - AddDrv(&file_driver); - - param.attr = TH_C; - param.thread = (void *)CDVD_Thread; - param.priority = 40; - param.stacksize = 0x8000; - param.option = 0; - - th = CreateThread(¶m); - - if (th > 0) { - StartThread(th, NULL); - return MODULE_RESIDENT_END; - } else - return MODULE_NO_RESIDENT_END; -} - -/************************************************************** -* The functions below are not exported for normal file-system * -* operations, but are used by the file-system operations, and * -* may also be exported for use via RPC * -**************************************************************/ - - -int CDVD_GetVolumeDescriptor(void) -{ - // Read until we find the last valid Volume Descriptor - int volDescSector; - - static struct cdVolDesc localVolDesc; - -#ifdef DEBUG - printf("CDVD_GetVolumeDescriptor called\n"); -#endif - - for (volDescSector = 16; volDescSector < 20; volDescSector++) { - ReadSect(volDescSector, 1, &localVolDesc, &cdReadMode); - - // If this is still a volume Descriptor - if (strncmp(localVolDesc.volID, "CD001", 5) == 0) { - if ((localVolDesc.filesystemType == 1) || - (localVolDesc.filesystemType == 2)) { - memcpy(&CDVolDesc, &localVolDesc, sizeof(struct cdVolDesc)); - } - } else - break; - } - -#ifdef DEBUG - switch (CDVolDesc.filesystemType) { - case 1: - printf("CD FileSystem is ISO9660\n"); - break; - - case 2: - printf("CD FileSystem is Joliet\n"); - break; - - default: - printf("CD FileSystem is unknown type\n"); - break; - } -#endif - // sceCdStop(); - - return TRUE; -} - - -int CDVD_findfile(const char *fname, struct TocEntry *tocEntry) -{ - static char filename[128 + 1]; - static char pathname[1024 + 1]; - - struct dirTocEntry *tocEntryPointer; - -#ifdef DEBUG - printf("CDVD_findfile called\n"); -#endif - - _splitpath(fname, pathname, filename); - -#ifdef DEBUG - printf("Trying to find file: %s in directory: %s\n", filename, pathname); -#endif - - // if ((CachedDirInfo.valid==TRUE) - // && (strcasecmp(pathname, CachedDirInfo.pathname)==0)) - - if ((CachedDirInfo.valid == TRUE) && (ComparePath(pathname) == MATCH)) { - // the directory is already cached, so check through the currently - // cached chunk of the directory first - - tocEntryPointer = (struct dirTocEntry *)CachedDirInfo.cache; - - for (; tocEntryPointer < (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048)); tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length)) { - if (tocEntryPointer->length == 0) { -#ifdef DEBUG - printf("Got a null pointer entry, so either reached end of dir, or end of sector\n"); -#endif - - tocEntryPointer = (struct dirTocEntry *)(CachedDirInfo.cache + (((((char *)tocEntryPointer - CachedDirInfo.cache) / 2048) + 1) * 2048)); - } - - if (tocEntryPointer >= (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048))) { - // reached the end of the cache block - break; - } - - if ((tocEntryPointer->fileProperties & 0x02) == 0) { - // It's a file - TocEntryCopy(tocEntry, tocEntryPointer); - - if (strcasecmp(tocEntry->filename, filename) == 0) { - // and it matches !! - return TRUE; - } - } - } // end of for loop - - - - // If that was the only dir block, and we havent found it, then fail - if (CachedDirInfo.cache_size == CachedDirInfo.sector_num) - return FALSE; - - // Otherwise there is more dir to check - if (CachedDirInfo.cache_offset == 0) { - // If that was the first block then continue with the next block - if (CDVD_Cache_Dir(pathname, CACHE_NEXT) != TRUE) - return FALSE; - } else { - // otherwise (if that wasnt the first block) then start checking from the start - if (CDVD_Cache_Dir(pathname, CACHE_START) != TRUE) - return FALSE; - } - } else { -#ifdef DEBUG - printf("Trying to cache directory\n"); -#endif - // The wanted directory wasnt already cached, so cache it now - if (CDVD_Cache_Dir(pathname, CACHE_START) != TRUE) { -#ifdef DEBUG - printf("Failed to cache directory\n"); -#endif - - return FALSE; - } - } - -// If we've got here, then we have a block of the directory cached, and want to check -// from this point, to the end of the dir -#ifdef DEBUG - printf("cache_size = %d\n", CachedDirInfo.cache_size); -#endif - - while (CachedDirInfo.cache_size > 0) { - tocEntryPointer = (struct dirTocEntry *)CachedDirInfo.cache; - - if (CachedDirInfo.cache_offset == 0) - tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length); - - for (; tocEntryPointer < (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048)); tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length)) { - if (tocEntryPointer->length == 0) { -#ifdef DEBUG - printf("Got a null pointer entry, so either reached end of dir, or end of sector\n"); - printf("Offset into cache = %d bytes\n", (char *)tocEntryPointer - CachedDirInfo.cache); -#endif - - tocEntryPointer = (struct dirTocEntry *)(CachedDirInfo.cache + (((((char *)tocEntryPointer - CachedDirInfo.cache) / 2048) + 1) * 2048)); - } - - if (tocEntryPointer >= (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048))) { - // reached the end of the cache block - break; - } - - TocEntryCopy(tocEntry, tocEntryPointer); - - if (strcasecmp(tocEntry->filename, filename) == 0) { -#ifdef DEBUG - printf("Found a matching file\n"); -#endif - // and it matches !! - return TRUE; - } - -#ifdef DEBUG - printf("Non-matching file - looking for %s , found %s\n", filename, tocEntry->filename); -#endif - } // end of for loop - -#ifdef DEBUG - printf("Reached end of cache block\n"); -#endif - // cache the next block - CDVD_Cache_Dir(pathname, CACHE_NEXT); - } - -// we've run out of dir blocks to cache, and still not found it, so fail - -#ifdef DEBUG - printf("CDVD_findfile: could not find file\n"); -#endif - - return FALSE; -} - - - -// Find, and cache, the requested directory, for use by GetDir or (and thus open) -// provide an optional offset variable, for use when caching dirs of greater than 500 files - -// returns TRUE if all TOC entries have been retrieved, or -// returns FALSE if there are more TOC entries to be retrieved -int CDVD_Cache_Dir(const char *pathname, enum Cache_getMode getMode) -{ - - // macke sure that the requested pathname is not directly modified - static char dirname[1024]; - - int path_len; - -#ifdef DEBUG - printf("Attempting to find, and cache, directory: %s\n", pathname); -#endif - - // only take any notice of the existing cache, if it's valid - if (CachedDirInfo.valid == TRUE) { - // Check if the requested path is already cached - // if (strcasecmp(pathname,CachedDirInfo.pathname)==0) - if (ComparePath(pathname) == MATCH) { -#ifdef DEBUG - printf("CacheDir: The requested path is already cached\n"); -#endif - - // If so, is the request ot cache the start of the directory, or to resume the next block ? - if (getMode == CACHE_START) { -#ifdef DEBUG - printf(" and requested cache from start of dir\n"); -#endif - - if (CachedDirInfo.cache_offset == 0) { -// requested cache of start of the directory, and thats what's already cached -// so sit back and do nothing -#ifdef DEBUG - printf(" and start of dir is already cached so nothing to do :o)\n"); -#endif - - CachedDirInfo.valid = TRUE; - return TRUE; - } else { -// Requested cache of start of the directory, but thats not what's cached -// so re-cache the start of the directory - -#ifdef DEBUG - printf(" but dir isn't cached from start, so re-cache existing dir from start\n"); -#endif - - // reset cache data to start of existing directory - CachedDirInfo.cache_offset = 0; - CachedDirInfo.cache_size = CachedDirInfo.sector_num; - - if (CachedDirInfo.cache_size > MAX_DIR_CACHE_SECTORS) - CachedDirInfo.cache_size = MAX_DIR_CACHE_SECTORS; - - // Now fill the cache with the specified sectors - if (ReadSect(CachedDirInfo.sector_start + CachedDirInfo.cache_offset, CachedDirInfo.cache_size, CachedDirInfo.cache, &cdReadMode) != TRUE) { -#ifdef DEBUG - printf("Couldn't Read from CD !\n"); -#endif - - CachedDirInfo.valid = FALSE; // should we completely invalidate just because we couldnt read first time? - return FALSE; - } - - CachedDirInfo.valid = TRUE; - return TRUE; - } - } else // getMode == CACHE_NEXT - { - // So get the next block of the existing directory - - CachedDirInfo.cache_offset += CachedDirInfo.cache_size; - - CachedDirInfo.cache_size = CachedDirInfo.sector_num - CachedDirInfo.cache_offset; - - if (CachedDirInfo.cache_size > MAX_DIR_CACHE_SECTORS) - CachedDirInfo.cache_size = MAX_DIR_CACHE_SECTORS; - - // Now fill the cache with the specified sectors - if (ReadSect(CachedDirInfo.sector_start + CachedDirInfo.cache_offset, CachedDirInfo.cache_size, CachedDirInfo.cache, &cdReadMode) != TRUE) { -#ifdef DEBUG - printf("Couldn't Read from CD !\n"); -#endif - - CachedDirInfo.valid = FALSE; // should we completely invalidate just because we couldnt read first time? - return FALSE; - } - - CachedDirInfo.valid = TRUE; - return TRUE; - } - } else // requested directory is not the cached directory (but cache is still valid) - { -#ifdef DEBUG - printf("Cache is valid, but cached directory, is not the requested one\n" - "so check if the requested directory is a sub-dir of the cached one\n"); - - printf("Requested Path = %s , Cached Path = %s\n", pathname, CachedDirInfo.pathname); -#endif - - - // Is the requested pathname a sub-directory of the current-directory ? - - // if the requested pathname is longer than the pathname of the cached dir - // and the pathname of the cached dir matches the beginning of the requested pathname - // and the next character in the requested pathname is a dir seperator - // printf("Length of Cached pathname = %d, length of req'd pathname = %d\n",path_len, strlen(pathname)); - // printf("Result of strncasecmp = %d\n",strncasecmp(pathname, CachedDirInfo.pathname, path_len)); - // printf("next character after length of cached name = %c\n",pathname[path_len]); - - // if ((strlen(pathname) > path_len) - // && (strncasecmp(pathname, CachedDirInfo.pathname, path_len)==0) - // && ((pathname[path_len]=='/') || (pathname[path_len]=='\\'))) - - if (ComparePath(pathname) == SUBDIR) { -// If so then we can start our search for the path, from the currently cached directory -#ifdef DEBUG - printf("Requested dir is a sub-dir of the cached directory,\n" - "so start search from current cached dir\n"); -#endif - // if the cached chunk, is not the start of the dir, - // then we will need to re-load it before starting search - if (CachedDirInfo.cache_offset != 0) { - CachedDirInfo.cache_offset = 0; - CachedDirInfo.cache_size = CachedDirInfo.sector_num; - if (CachedDirInfo.cache_size > MAX_DIR_CACHE_SECTORS) - CachedDirInfo.cache_size = MAX_DIR_CACHE_SECTORS; - - // Now fill the cache with the specified sectors - if (ReadSect(CachedDirInfo.sector_start + CachedDirInfo.cache_offset, CachedDirInfo.cache_size, CachedDirInfo.cache, &cdReadMode) != TRUE) { -#ifdef DEBUG - printf("Couldn't Read from CD !\n"); -#endif - - CachedDirInfo.valid = FALSE; // should we completely invalidate just because we couldnt read time? - return FALSE; - } - } - - // start the search, with the path after the current directory - path_len = strlen(CachedDirInfo.pathname); - strcpy(dirname, pathname + path_len); - - // FindPath should use the current directory cache to start it's search - // and should change CachedDirInfo.pathname, to the path of the dir it finds - // it should also cache the first chunk of directory sectors, - // and fill the contents of the other elements of CachedDirInfo appropriately - - return (FindPath(dirname)); - } - } - } - -// If we've got here, then either the cache was not valid to start with -// or the requested path is not a subdirectory of the currently cached directory -// so lets start again -#ifdef DEBUG - printf("The cache is not valid, or the requested directory is not a sub-dir of the cached one\n"); -#endif - - if (!isValidDisc()) { -#ifdef DEBUG - printf("No supported disc inserted.\n"); -#endif - - return -1; - } - - sceCdDiskReady(0); - - // Read the main volume descriptor - if (CDVD_GetVolumeDescriptor() != TRUE) { -#ifdef DEBUG - printf("Could not read the CD/DVD Volume Descriptor\n"); -#endif - - return -1; - } - -#ifdef DEBUG - printf("Read the CD Volume Descriptor\n"); -#endif - - CachedDirInfo.path_depth = 0; - - strcpy(CachedDirInfo.pathname, ""); - - // Setup the lba and sector size, for retrieving the root toc - CachedDirInfo.cache_offset = 0; - CachedDirInfo.sector_start = CDVolDesc.rootToc.tocLBA; - CachedDirInfo.sector_num = (CDVolDesc.rootToc.tocSize >> 11) + ((CDVolDesc.rootToc.tocSize & 2047) != 0); - - CachedDirInfo.cache_size = CachedDirInfo.sector_num; - - if (CachedDirInfo.cache_size > MAX_DIR_CACHE_SECTORS) - CachedDirInfo.cache_size = MAX_DIR_CACHE_SECTORS; - - - // Now fill the cache with the specified sectors - if (ReadSect(CachedDirInfo.sector_start + CachedDirInfo.cache_offset, CachedDirInfo.cache_size, CachedDirInfo.cache, &cdReadMode) != TRUE) { -#ifdef DEBUG - printf("Couldn't Read from CD !\n"); -#endif - - CachedDirInfo.valid = FALSE; // should we completely invalidate just because we couldnt read time? - return FALSE; - } - -#ifdef DEBUG - printf("Read the first block from the root directory\n"); -#endif - -// FindPath should use the current directory cache to start it's search (in this case the root) -// and should change CachedDirInfo.pathname, to the path of the dir it finds -// it should also cache the first chunk of directory sectors, -// and fill the contents of the other elements of CachedDirInfo appropriately -#ifdef DEBUG - printf("Calling FindPath\n"); -#endif - strcpy(dirname, pathname); - - return (FindPath(dirname)); -} - -int FindPath(char *pathname) -{ - char *dirname; - char *seperator; - - int dir_entry; - int found_dir; - - struct dirTocEntry *tocEntryPointer; - struct TocEntry localTocEntry; - - dirname = strtok(pathname, "\\/"); - -#ifdef DEBUG - printf("FindPath: trying to find directory %s\n", pathname); -#endif - - if (!isValidDisc()) - return FALSE; - - sceCdDiskReady(0); - - while (dirname != NULL) { - found_dir = FALSE; - - tocEntryPointer = (struct dirTocEntry *)CachedDirInfo.cache; - - // Always skip the first entry (self-refencing entry) - tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length); - - dir_entry = 0; - - for (; tocEntryPointer < (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048)); tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length)) { - // If we have a null toc entry, then we've either reached the end of the dir, or have reached a sector boundary - if (tocEntryPointer->length == 0) { -#ifdef DEBUG - printf("Got a null pointer entry, so either reached end of dir, or end of sector\n"); -#endif - - tocEntryPointer = (struct dirTocEntry *)(CachedDirInfo.cache + (((((char *)tocEntryPointer - CachedDirInfo.cache) / 2048) + 1) * 2048)); - } - - if (tocEntryPointer >= (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048))) { - // If we've gone past the end of the cache - // then check if there are more sectors to load into the cache - - if ((CachedDirInfo.cache_offset + CachedDirInfo.cache_size) < CachedDirInfo.sector_num) { - // If there are more sectors to load, then load them - CachedDirInfo.cache_offset += CachedDirInfo.cache_size; - CachedDirInfo.cache_size = CachedDirInfo.sector_num - CachedDirInfo.cache_offset; - - if (CachedDirInfo.cache_size > MAX_DIR_CACHE_SECTORS) - CachedDirInfo.cache_size = MAX_DIR_CACHE_SECTORS; - - if (ReadSect(CachedDirInfo.sector_start + CachedDirInfo.cache_offset, CachedDirInfo.cache_size, CachedDirInfo.cache, &cdReadMode) != TRUE) { -#ifdef DEBUG - printf("Couldn't Read from CD !\n"); -#endif - - CachedDirInfo.valid = FALSE; // should we completely invalidate just because we couldnt read time? - return FALSE; - } - - tocEntryPointer = (struct dirTocEntry *)CachedDirInfo.cache; - } else { - CachedDirInfo.valid = FALSE; - return FALSE; - } - } - - // If the toc Entry is a directory ... - if (tocEntryPointer->fileProperties & 0x02) { - // Convert to our format (inc ascii name), for the check - TocEntryCopy(&localTocEntry, tocEntryPointer); - - // If it's the link to the parent directory, then give it the name ".." - if (dir_entry == 0) { - if (CachedDirInfo.path_depth != 0) { -#ifdef DEBUG - printf("First directory entry in dir, so name it '..'\n"); -#endif - - strcpy(localTocEntry.filename, ".."); - } - } - - // Check if this is the directory that we are looking for - if (strcasecmp(dirname, localTocEntry.filename) == 0) { -#ifdef DEBUG - printf("Found the matching sub-directory\n"); -#endif - - found_dir = TRUE; - - if (dir_entry == 0) { - // We've matched with the parent directory - // so truncate the pathname by one level - - if (CachedDirInfo.path_depth > 0) - CachedDirInfo.path_depth--; - - if (CachedDirInfo.path_depth == 0) { - // If at root then just clear the path to root - // (simpler than finding the colon seperator etc) - CachedDirInfo.pathname[0] = 0; - } else { - seperator = strrchr(CachedDirInfo.pathname, '/'); - - if (seperator != NULL) - *seperator = 0; - } - } else { - // otherwise append a seperator, and the matched directory - // to the pathname - strcat(CachedDirInfo.pathname, "/"); - -#ifdef DEBUG - printf("Adding '%s' to cached pathname - path depth = %d\n", dirname, CachedDirInfo.path_depth); -#endif - - strcat(CachedDirInfo.pathname, dirname); - - CachedDirInfo.path_depth++; - } - - // Exit out of the search loop - // (and find the next sub-directory, if there is one) - break; - } else { -#ifdef DEBUG - printf("Found a directory, but it doesn't match\n"); -#endif - } - } - - dir_entry++; - - } // end of cache block search loop - - - // if we've reached here, without finding the directory, then it's not there - if (found_dir != TRUE) { - CachedDirInfo.valid = FALSE; - return FALSE; - } - - // find name of next dir - dirname = strtok(NULL, "\\/"); - - CachedDirInfo.sector_start = localTocEntry.fileLBA; - CachedDirInfo.sector_num = (localTocEntry.fileSize >> 11) + ((CDVolDesc.rootToc.tocSize & 2047) != 0); - - // Cache the start of the found directory - // (used in searching if this isn't the last dir, - // or used by whatever requested the cache in the first place if it is the last dir) - CachedDirInfo.cache_offset = 0; - CachedDirInfo.cache_size = CachedDirInfo.sector_num; - - if (CachedDirInfo.cache_size > MAX_DIR_CACHE_SECTORS) - CachedDirInfo.cache_size = MAX_DIR_CACHE_SECTORS; - - if (ReadSect(CachedDirInfo.sector_start + CachedDirInfo.cache_offset, CachedDirInfo.cache_size, CachedDirInfo.cache, &cdReadMode) != TRUE) { -#ifdef DEBUG - printf("Couldn't Read from CD, trying to read %d sectors, starting at sector %d !\n", - CachedDirInfo.cache_size, CachedDirInfo.sector_start + CachedDirInfo.cache_offset); -#endif - - CachedDirInfo.valid = FALSE; // should we completely invalidate just because we couldnt read time? - return FALSE; - } - } - -// If we've got here then we found the requested directory -#ifdef DEBUG - printf("FindPath found the path\n"); -#endif - - CachedDirInfo.valid = TRUE; - return TRUE; -} - - - -// This is the getdir for use by IOP clients -// fills an array of TocEntry stucts in IOP memory -int CDVD_getdir_IOP(const char *pathname, const char *extensions, enum CDVD_getMode getMode, struct TocEntry tocEntry[], unsigned int req_entries) -{ - // TO DO - return FALSE; -} - - -// This is the getdir for use by the EE RPC client -// It DMA's entries to the specified buffer in EE memory -int CDVD_GetDir_RPC(const char *pathname, const char *extensions, enum CDVD_getMode getMode, struct TocEntry tocEntry[], unsigned int req_entries) -{ - int matched_entries; - int dir_entry; - - struct TocEntry localTocEntry; - - struct dirTocEntry *tocEntryPointer; - - int intStatus; // interrupt status - for dis/en-abling interrupts - - struct t_SifDmaTransfer dmaStruct; - int dmaID; - - dmaID = 0; - -#ifdef DEBUG - printf("RPC GetDir Request\n"); -#endif - - matched_entries = 0; - - // pre-cache the dir (and get the new pathname - in-case selected "..") - if (CDVD_Cache_Dir(pathname, CACHE_START) != TRUE) { -#ifdef DEBUG - printf("CDVD_GetDir_RPC - Call of CDVD_Cache_Dir failed\n"); -#endif - - return -1; - } - -#ifdef DEBUG - printf("requested directory is %d sectors\n", CachedDirInfo.sector_num); -#endif - - if ((getMode == CDVD_GET_DIRS_ONLY) || (getMode == CDVD_GET_FILES_AND_DIRS)) { - // Cache the start of the requested directory - if (CDVD_Cache_Dir(CachedDirInfo.pathname, CACHE_START) != TRUE) { -#ifdef DEBUG - printf("CDVD_GetDir_RPC - Call of CDVD_Cache_Dir failed\n"); -#endif - - return -1; - } - - tocEntryPointer = (struct dirTocEntry *)CachedDirInfo.cache; - - // skip the first self-referencing entry - tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length); - - // skip the parent entry if this is the root - if (CachedDirInfo.path_depth == 0) - tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length); - - dir_entry = 0; - - while (1) { -#ifdef DEBUG - printf("CDVD_GetDir_RPC - inside while-loop\n"); -#endif - - // parse the current cache block - for (; tocEntryPointer < (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048)); tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length)) { - if (tocEntryPointer->length == 0) { - // if we have a toc entry length of zero, - // then we've either reached the end of the sector, or the end of the dir - // so point to next sector (if there is one - will be checked by next condition) - - tocEntryPointer = (struct dirTocEntry *)(CachedDirInfo.cache + (((((char *)tocEntryPointer - CachedDirInfo.cache) / 2048) + 1) * 2048)); - } - - if (tocEntryPointer >= (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048))) { - // we've reached the end of the current cache block (which may be end of entire dir - // so just break the loop - break; - } - - // Check if the current entry is a dir or a file - if (tocEntryPointer->fileProperties & 0x02) { -#ifdef DEBUG - printf("We found a dir, and we want all dirs\n"); -#endif - - // wait for any previous DMA to complete - // before over-writing localTocEntry - while (sceSifDmaStat(dmaID) >= 0) - ; - - TocEntryCopy(&localTocEntry, tocEntryPointer); - - if (dir_entry == 0) { - if (CachedDirInfo.path_depth != 0) { -#ifdef DEBUG - printf("It's the first directory entry, so name it '..'\n"); -#endif - - strcpy(localTocEntry.filename, ".."); - } - } - - // DMA localTocEntry to the address specified by tocEntry[matched_entries] - - // setup the dma struct - dmaStruct.src = &localTocEntry; - dmaStruct.dest = &tocEntry[matched_entries]; - dmaStruct.size = sizeof(struct TocEntry); - dmaStruct.attr = 0; - - // Do the DMA transfer - CpuSuspendIntr(&intStatus); - - dmaID = sceSifSetDma(&dmaStruct, 1); - - CpuResumeIntr(intStatus); - - matched_entries++; - } else // it must be a file - { -#ifdef DEBUG - printf("We found a file, but we dont want files (at least not yet)\n"); -#endif - } - - dir_entry++; - - if (matched_entries >= req_entries) // if we've filled the requested buffer - return (matched_entries); // then just return - - } // end of the current cache block - - // if there is more dir to load, then load next chunk, else finish - if ((CachedDirInfo.cache_offset + CachedDirInfo.cache_size) < CachedDirInfo.sector_num) { - if (CDVD_Cache_Dir(CachedDirInfo.pathname, CACHE_NEXT) != TRUE) { - // failed to cache next block (should return TRUE even if - // there is no more directory, as long as a CD read didnt fail - return -1; - } - } else - break; - - tocEntryPointer = (struct dirTocEntry *)CachedDirInfo.cache; - } - } - - // Next do files - if ((getMode == CDVD_GET_FILES_ONLY) || (getMode == CDVD_GET_FILES_AND_DIRS)) { - // Cache the start of the requested directory - if (CDVD_Cache_Dir(CachedDirInfo.pathname, CACHE_START) != TRUE) { -#ifdef DEBUG - printf("CDVD_GetDir_RPC - Call of CDVD_Cache_Dir failed\n"); -#endif - - return -1; - } - - tocEntryPointer = (struct dirTocEntry *)CachedDirInfo.cache; - - // skip the first self-referencing entry - tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length); - - // skip the parent entry if this is the root - if (CachedDirInfo.path_depth == 0) - tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length); - - dir_entry = 0; - - while (1) { -#ifdef DEBUG - printf("CDVD_GetDir_RPC - inside while-loop\n"); -#endif - - // parse the current cache block - for (; tocEntryPointer < (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048)); tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length)) { - if (tocEntryPointer->length == 0) { - // if we have a toc entry length of zero, - // then we've either reached the end of the sector, or the end of the dir - // so point to next sector (if there is one - will be checked by next condition) - - tocEntryPointer = (struct dirTocEntry *)(CachedDirInfo.cache + (((((char *)tocEntryPointer - CachedDirInfo.cache) / 2048) + 1) * 2048)); - } - - if (tocEntryPointer >= (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048))) { - // we've reached the end of the current cache block (which may be end of entire dir - // so just break the loop - break; - } - - // Check if the current entry is a dir or a file - if (tocEntryPointer->fileProperties & 0x02) { -#ifdef DEBUG - printf("We don't want files now\n"); -#endif - } else // it must be a file - { - // wait for any previous DMA to complete - // before over-writing localTocEntry - while (sceSifDmaStat(dmaID) >= 0) - ; - - TocEntryCopy(&localTocEntry, tocEntryPointer); - - if (strlen(extensions) > 0) { - // check if the file matches the extension list - if (TocEntryCompare(localTocEntry.filename, extensions) == TRUE) { -#ifdef DEBUG - printf("We found a file that matches the requested extension list\n"); -#endif - - // DMA localTocEntry to the address specified by tocEntry[matched_entries] - - // setup the dma struct - dmaStruct.src = &localTocEntry; - dmaStruct.dest = &tocEntry[matched_entries]; - dmaStruct.size = sizeof(struct TocEntry); - dmaStruct.attr = 0; - - // Do the DMA transfer - CpuSuspendIntr(&intStatus); - - dmaID = sceSifSetDma(&dmaStruct, 1); - - CpuResumeIntr(intStatus); - - matched_entries++; - } else { -#ifdef DEBUG - printf("We found a file, but it didnt match the requested extension list\n"); -#endif - } - } else // no extension list to match against - { -#ifdef DEBUG - printf("We found a file, and there is not extension list to match against\n"); -#endif - - // DMA localTocEntry to the address specified by tocEntry[matched_entries] - - // setup the dma struct - dmaStruct.src = &localTocEntry; - dmaStruct.dest = &tocEntry[matched_entries]; - dmaStruct.size = sizeof(struct TocEntry); - dmaStruct.attr = 0; - - // Do the DMA transfer - CpuSuspendIntr(&intStatus); - - dmaID = sceSifSetDma(&dmaStruct, 1); - - CpuResumeIntr(intStatus); - - matched_entries++; - } - } - - dir_entry++; - - if (matched_entries >= req_entries) // if we've filled the requested buffer - return (matched_entries); // then just return - - } // end of the current cache block - - - // if there is more dir to load, then load next chunk, else finish - if ((CachedDirInfo.cache_offset + CachedDirInfo.cache_size) < CachedDirInfo.sector_num) { - if (CDVD_Cache_Dir(CachedDirInfo.pathname, CACHE_NEXT) != TRUE) { - // failed to cache next block (should return TRUE even if - // there is no more directory, as long as a CD read didnt fail - return -1; - } - } else - break; - - tocEntryPointer = (struct dirTocEntry *)CachedDirInfo.cache; - } - } - // reached the end of the dir, before filling up the requested entries - - return (matched_entries); -} - -int CdFlushCache(void) -{ - strcpy(CachedDirInfo.pathname, ""); // The pathname of the cached directory - CachedDirInfo.valid = FALSE; // Cache is not valid - CachedDirInfo.path_depth = 0; // 0 = root) - CachedDirInfo.sector_start = 0; // The start sector (LBA) of the cached directory - CachedDirInfo.sector_num = 0; // The total size of the directory (in sectors) - CachedDirInfo.cache_offset = 0; // The offset from sector_start of the cached area - CachedDirInfo.cache_size = 0; // The size of the cached directory area (in sectors) - - return TRUE; -} - -unsigned int CdGetSize(void) -{ - if (CDVD_GetVolumeDescriptor() != TRUE) - return TRUE; - - return CDVolDesc.volSize; -} - -void *CDVDRpc_FlushCache() -{ - CdFlushCache(); - - return NULL; -} - - -void *CDVDRpc_Stop() -{ - if (isValidDisc()) { - sceCdStop(); - sceCdSync(0); - } - - return NULL; -} - -// Send: Offset 0 = mode. Size = int -// Return: Offset 0 = traycnt. Size = int -void *CDVDRpc_TrayReq(unsigned int *sbuff) -{ - int ret; - - sceCdTrayReq(sbuff[0], (int *)&ret); - - sbuff[0] = ret; - return sbuff; -} - -// Send: Offset 0 = mode -// Return: Offset 0 = ret val (cd status) -void *CDVDRpc_DiskReady(unsigned int *sbuff) -{ - int ret; - - if (isValidDisc()) - ret = sceCdDiskReady(sbuff[0]); - else - ret = -1; - - sbuff[0] = ret; - return sbuff; -} - -// Send: Offset 0 = filename string (1024 bytes) -// Return: Offset 0 = ret val (true/false). Size = int -// Offset 1024 = start of TocEntry structure -void *CDVDRpc_FindFile(unsigned int *sbuff) -{ - int ret; - - ret = CDVD_findfile((char *)&sbuff[0], (struct TocEntry *)&sbuff[1024 / 4]); - - sbuff[0] = ret; - - return sbuff; -} - -// Send: Offset 0 = filename string (1024 bytes) -// Send: Offset 1024 = extension string (128 bytes) -// Send: Offset 1152 = CDVD_getMode -// Send: Offset 1156 = pointer to array of TocEntry structures in EE mem -// Send: Offset 1160 = requested number of entries - -// Return: Offset 0 = ret val (number of matched entries). Size = int -// Return: Offset 4 = updated pathname (for if path selected = ".." -void *CDVDRpc_Getdir(unsigned int *sbuff) -{ - int ret; - - ret = CDVD_GetDir_RPC( - (char *)&sbuff[0 / 4], // pathname string - (char *)&sbuff[1024 / 4], // extension string - sbuff[1152 / 4], // CDVD_getMode - (struct TocEntry *)sbuff[1156 / 4], // pointer to array of TocEntry structures in EE mem - sbuff[1160 / 4] // requested number of entries - ); - - sbuff[0] = ret; - strcpy((char *)&sbuff[1], CachedDirInfo.pathname); - return sbuff; -} - -void *CDVDRpc_GetSize(unsigned int *sbuff) -{ - sbuff[0] = CdGetSize(); - return sbuff; -} - -/************************************************* -* The functions below are for internal use only, * -* and are not to be exported * -*************************************************/ - -void CDVD_Thread(void *param) -{ -#ifdef DEBUG - printf("CDVD: RPC Initialize\n"); -#endif - - sceSifInitRpc(0); - - // 0x4800 bytes for TocEntry structures (can fit 128 of them) - // 0x400 bytes for the filename string - buffer = AllocSysMemory(0, 0x4C00, NULL); - if (buffer == NULL) { -#ifdef DEBUG - printf("Failed to allocate memory for RPC buffer!\n"); -#endif - - SleepThread(); - } - - sceSifSetRpcQueue(&qd, GetThreadId()); - sceSifRegisterRpc(&sd0, CDVD_IRX, CDVD_rpc_server, (void *)buffer, 0, 0, &qd); - sceSifRpcLoop(&qd); -} - -void *CDVD_rpc_server(int fno, void *data, int size) -{ - - switch (fno) { - case CDVD_FINDFILE: - return CDVDRpc_FindFile((unsigned *)data); - case CDVD_GETDIR: - return CDVDRpc_Getdir((unsigned *)data); - case CDVD_STOP: - return CDVDRpc_Stop(); - case CDVD_TRAYREQ: - return CDVDRpc_TrayReq((unsigned *)data); - case CDVD_DISKREADY: - return CDVDRpc_DiskReady((unsigned *)data); - case CDVD_FLUSHCACHE: - return CDVDRpc_FlushCache(); - } - - return NULL; -} - -void _splitpath(const char *constpath, char *dir, char *fname) -{ - // 255 char max path-length is an ISO9660 restriction - // we must change this for Joliet or relaxed iso restriction support - static char pathcopy[1024 + 1]; - - char *slash; - - strncpy(pathcopy, constpath, 1024); - - slash = strrchr(pathcopy, '/'); - - // if the path doesn't contain a '/' then look for a '\' - if (!slash) - slash = strrchr(pathcopy, (int)'\\'); - - // if a slash was found - if (slash != NULL) { - // null terminate the path - slash[0] = 0; - // and copy the path into 'dir' - strncpy(dir, pathcopy, 1024); - dir[255] = 0; - - // copy the filename into 'fname' - strncpy(fname, slash + 1, 128); - fname[128] = 0; - } else { - dir[0] = 0; - - strncpy(fname, pathcopy, 128); - fname[128] = 0; - } -} - -// Copy a TOC Entry from the CD native format to our tidier format -void TocEntryCopy(struct TocEntry *tocEntry, struct dirTocEntry *internalTocEntry) -{ - int i; - int filenamelen; - - tocEntry->fileSize = internalTocEntry->fileSize; - tocEntry->fileLBA = internalTocEntry->fileLBA; - tocEntry->fileProperties = internalTocEntry->fileProperties; - - if (CDVolDesc.filesystemType == 2) { - // This is a Joliet Filesystem, so use Unicode to ISO string copy - filenamelen = internalTocEntry->filenameLength / 2; - - for (i = 0; i < filenamelen; i++) - tocEntry->filename[i] = internalTocEntry->filename[(i << 1) + 1]; - } else { - filenamelen = internalTocEntry->filenameLength; - - // use normal string copy - strncpy(tocEntry->filename, internalTocEntry->filename, 128); - } - - tocEntry->filename[filenamelen] = 0; - - if (!(tocEntry->fileProperties & 0x02)) { - // strip the ;1 from the filename (if it's there) - strtok(tocEntry->filename, ";"); - } -} - -// Check if a TOC Entry matches our extension list -int TocEntryCompare(char *filename, const char *extensions) -{ - static char ext_list[129]; - - char *token; - - char *ext_point; - - strncpy(ext_list, extensions, 128); - ext_list[128] = 0; - - token = strtok(ext_list, " ,"); - while (token != NULL) { - // if 'token' matches extension of 'filename' - // then return a match - ext_point = strrchr(filename, '.'); - - if (strcasecmp(ext_point, token) == 0) - return (TRUE); - - /* Get next token: */ - token = strtok(NULL, " ,"); - } - - // If not match found then return FALSE - return (FALSE); -} - -// Used in findfile -//int tolower(int c); -int strcasecmp(const char *s1, const char *s2) -{ - while (*s1 != '\0' && tolower(*s1) == tolower(*s2)) { - s1++; - s2++; - } - - return tolower(*(unsigned char *)s1) - tolower(*(unsigned char *)s2); -} - -int strncasecmp(const char *s1, const char *s2, int limit) -{ - int i; - - for (i = 0; i < limit; i++) { - if (*s1 == '\0') - return tolower(*(unsigned char *)s1) - tolower(*(unsigned char *)s2); - - if (tolower(*s1) != tolower(*s2)) - return tolower(*(unsigned char *)s1) - tolower(*(unsigned char *)s2); - - s1++; - s2++; - } - - return 0; -} - -enum PathMatch ComparePath(const char *path) -{ - int length; - int i; - - length = strlen(CachedDirInfo.pathname); - - for (i = 0; i < length; i++) { - // check if character matches - if (path[i] != CachedDirInfo.pathname[i]) { - // if not, then is it just because of different path seperator ? - if ((path[i] == '/') || (path[i] == '\\')) { - if ((CachedDirInfo.pathname[i] == '/') || (CachedDirInfo.pathname[i] == '\\')) { - continue; - } - } - - // if the characters don't match for any other reason then report a failure - return NOT_MATCH; - } - } - - // Reached the end of the Cached pathname - - // if requested path is same length, then report exact match - if (path[length] == 0) - return MATCH; - - // if requested path is longer, and next char is a dir seperator - // then report sub-dir match - if ((path[length] == '/') || (path[length] == '\\')) - return SUBDIR; - else - return NOT_MATCH; -} diff --git a/ps2/libcdvd/iop/cdvd_iop.h b/ps2/libcdvd/iop/cdvd_iop.h deleted file mode 100644 index 989ed12cef..0000000000 --- a/ps2/libcdvd/iop/cdvd_iop.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef _CDVD_IOP_H -#define _CDVD_IOP_H - -#include "../common/cdvd.h" - -// Macros for READ Data pattan -#define CdSecS2048 0 // sector size 2048 -#define CdSecS2328 1 // sector size 2328 -#define CdSecS2340 2 // sector size 2340 - -// Macros for Spindle control -#define CdSpinMax 0 -#define CdSpinNom 1 // Starts reading data at maximum rotational velocity and if a read error occurs, the rotational velocity is reduced. -#define CdSpinStm 0 // Recommended stream rotation speed. - -typedef struct -{ - u8 stat; // 0: normal. Any other: error - u8 second; // second (BCD value) - u8 minute; // minute (BCD value) - u8 hour; // hour (BCD value) - u8 week; // week (BCD value) - u8 day; // day (BCD value) - u8 month; // month (BCD value) - u8 year; // year (BCD value) -} CdCLOCK; - -typedef struct -{ - u32 lsn; // Logical sector number of file - u32 size; // File size (in bytes) - char name[16]; // Filename - u8 date[8]; // 1th: Seconds - // 2th: Minutes - // 3th: Hours - // 4th: Date - // 5th: Month - // 6th 7th: Year (4 digits) -} CdlFILE; - -typedef struct -{ - u8 minute; // Minutes - u8 second; // Seconds - u8 sector; // Sector - u8 track; // Track number -} CdlLOCCD; - -typedef struct -{ - u8 trycount; // Read try count (No. of error retries + 1) (0 - 255) - u8 spindlctrl; // SCECdSpinStm: Recommended stream rotation speed. - // SCECdSpinNom: Starts reading data at maximum rotational velocity and if a read error occurs, the rotational velocity is reduced. - u8 datapattern; // SCECdSecS2048: Data size 2048 bytes - // SCECdSecS2328: 2328 bytes - // SCECdSecS2340: 2340 bytes - u8 pad; // Padding data produced by alignment. -} CdRMode; - - -int CdBreak(void); -int CdCallback(void (*func)()); -int CdDiskReady(int mode); -int CdGetDiskType(void); -int CdGetError(void); -u32 CdGetReadPos(void); -int CdGetToc(u8 *toc); -int CdInit(int init_mode); -CdlLOCCD *CdIntToPos(int i, CdlLOCCD *p); -int CdPause(void); -int CdPosToInt(CdlLOCCD *p); -int CdRead(u32 lsn, u32 sectors, void *buf, CdRMode *mode); -int CdReadClock(CdCLOCK *rtc); -int CdSearchFile(CdlFILE *fp, const char *name); -int CdSeek(u32 lsn); -int CdStandby(void); -int CdStatus(void); -int CdStop(void); -int CdSync(int mode); -int CdTrayReq(int mode, u32 *traycnt); -int CdFlushCache(void); -unsigned int CdGetSize(void); - -#endif // _CDVD_H diff --git a/ps2/libcdvd/iop/imports.lst b/ps2/libcdvd/iop/imports.lst deleted file mode 100644 index f47423c148..0000000000 --- a/ps2/libcdvd/iop/imports.lst +++ /dev/null @@ -1,62 +0,0 @@ -cdvdman_IMPORTS_start -I_sceCdInit -I_sceCdGetError -I_sceCdRead -I_sceCdStop -I_sceCdSync -I_sceCdDiskReady -I_sceCdGetDiskType -I_sceCdTrayReq -cdvdman_IMPORTS_end - -intrman_IMPORTS_start -I_CpuSuspendIntr -I_CpuResumeIntr -intrman_IMPORTS_end - -ioman_IMPORTS_start -I_AddDrv -I_DelDrv -ioman_IMPORTS_end - -sifcmd_IMPORTS_start -I_sceSifInitRpc -I_sceSifSetRpcQueue -I_sceSifRegisterRpc -I_sceSifRpcLoop -sifcmd_IMPORTS_end - -sifman_IMPORTS_start -I_sceSifSetDma -I_sceSifDmaStat -sifman_IMPORTS_end - -stdio_IMPORTS_start -I_printf -I_puts -stdio_IMPORTS_end - -sysclib_IMPORTS_start -I_tolower -I_strcpy -I_strncpy -I_strncmp -I_strtok -I_strrchr -I_strcat -I_strlen -I_memset -I_memcpy -I_memcmp -sysclib_IMPORTS_end - -sysmem_IMPORTS_start -I_AllocSysMemory -sysmem_IMPORTS_end - -thbase_IMPORTS_start -I_GetThreadId -I_CreateThread -I_StartThread -I_SleepThread -thbase_IMPORTS_end diff --git a/ps2/libcdvd/iop/irx_imports.h b/ps2/libcdvd/iop/irx_imports.h deleted file mode 100644 index 4048b3d831..0000000000 --- a/ps2/libcdvd/iop/irx_imports.h +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include diff --git a/ps2/libcdvd/license.txt b/ps2/libcdvd/license.txt deleted file mode 100644 index bd0a0cb71d..0000000000 --- a/ps2/libcdvd/license.txt +++ /dev/null @@ -1,45 +0,0 @@ -Copyright (c) 2002, A.Lee & Nicholas Van Veen -All rights reserved. - -Redistribution and use of this software, in source and binary forms, with or -without modification, are permitted provided that the following conditions are -met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. You are granted a license to use this software for academic, research and - non-commercial purposes only. - -4. The copyright holder imposes no restrictions on any code developed using - this software. However, the copyright holder retains a non-exclusive - royalty-free license to any modifications to the distribution made by the - licensee. - -5. Any licensee wishing to make commercial use of this software should contact - the copyright holder to execute the appropriate license for such commercial - use. Commercial use includes: - - - Integration of all or part of the source code into a product for sale - or commercial license by or on behalf of Licensee to third parties, or - - - Distribution of the binary code or source code to third parties that - need it to utilize a commercial product sold or licensed by or on - behalf of Licensee. - - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY -OF SUCH DAMAGE. - diff --git a/verbosity.c b/verbosity.c index 6a7e091081..23425582fa 100644 --- a/verbosity.c +++ b/verbosity.c @@ -177,11 +177,9 @@ void retro_main_log_file_init(const char *path, bool append) g_verbosity->fp = tmp; g_verbosity->initialized = true; -#if !defined(PS2) /* TODO: PS2 IMPROVEMENT */ /* TODO: this is only useful for a few platforms, find which and add ifdef */ g_verbosity->buf = calloc(1, 0x4000); setvbuf(g_verbosity->fp, (char*)g_verbosity->buf, _IOFBF, 0x4000); -#endif } void retro_main_log_file_deinit(void) From 0fced84f933313aaac72b402f0b1691a9f9f7466 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 23:01:04 +0200 Subject: [PATCH 160/192] (Netplay) Lower announce rate --- network/netplay/netplay_frontend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c index a9aa3d6537..0ba67629d7 100644 --- a/network/netplay/netplay_frontend.c +++ b/network/netplay/netplay_frontend.c @@ -1000,7 +1000,7 @@ bool netplay_pre_frame(netplay_t *netplay) if (settings->bools.netplay_public_announce) { reannounce++; - if ((netplay->is_server || is_mitm) && (reannounce % 600 == 0)) + if ((netplay->is_server || is_mitm) && (reannounce % 300 == 0)) netplay_announce(); } /* Make sure that if announcement is turned on mid-game, it gets announced */ From 41fd598195b560e88d430aa2ae55e076da0d83a6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 23:02:54 +0200 Subject: [PATCH 161/192] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 9639562b76..9c058b1c7d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ - MENU/THUMBNAILS/BUGFIX: Fix heap-use-after-free error - MENU/OZONE/ANDROIDTV: Default to Ozone menu driver - MENU/OZONE/ANDROID: Gamepad-like devices default to Ozone now (Shield Portable) +- NETPLAY: Lower announcement rate - OVERLAYS: Fix memory leak when loading overlays - WIIU: Gamepad hotplugging support - WIIU: Theoretical multi-gamepad support From 060ad389058d2402313350e375c430d3e4427567 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 23:34:23 +0200 Subject: [PATCH 162/192] (WiiU) Buildfix --- gfx/drivers/gx2_gfx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gfx/drivers/gx2_gfx.c b/gfx/drivers/gx2_gfx.c index 1cac6587c2..f097b8bf68 100644 --- a/gfx/drivers/gx2_gfx.c +++ b/gfx/drivers/gx2_gfx.c @@ -1047,6 +1047,7 @@ static bool wiiu_gfx_frame(void *data, const void *frame, { uint32_t i; wiiu_video_t *wiiu = (wiiu_video_t *) data; + bool menu_is_alive = video_info->menu_is_alive; (void)msg; @@ -1500,6 +1501,8 @@ static bool wiiu_gfx_set_shader(void *data, if (image_texture_load(&image, wiiu->shader_preset->lut[i].path)) { + unsigned j; + wiiu->luts[i].surface.width = image.width; wiiu->luts[i].surface.height = image.height; wiiu->luts[i].surface.depth = 1; From 6173d11b62e1d539900e66bf6ae13c5a2ac8b877 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 23:35:32 +0200 Subject: [PATCH 163/192] Silence unused function warning --- menu/cbs/menu_cbs_ok.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 8ddc5b1713..2bd26efcb1 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -5448,6 +5448,7 @@ finish: } +#ifndef RARCH_CONSOLE static void netplay_lan_scan_callback(retro_task_t *task, void *task_data, void *user_data, const char *error) @@ -5503,6 +5504,7 @@ static void netplay_lan_scan_callback(retro_task_t *task, } } } +#endif static int action_ok_push_netplay_refresh_rooms(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) From 2037de5b335b0277a4723eeda3dc31fa6bbfeb20 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2020 23:40:26 +0200 Subject: [PATCH 164/192] Silence more warnings --- retroarch.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/retroarch.c b/retroarch.c index cd5c188acd..4a9b386124 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1853,7 +1853,9 @@ static unsigned osk_last_codepoint = 0; static unsigned osk_last_codepoint_len = 0; static unsigned input_driver_flushing_input = 0; static unsigned input_driver_max_users = 0; +#ifdef HAVE_ACCESSIBILITY static unsigned gamepad_input_override = 0; +#endif #ifdef HAVE_MENU static unsigned char menu_keyboard_key_state[RETROK_LAST] = {0}; @@ -2308,7 +2310,9 @@ static void retroarch_deinit_core_options(void); static void retroarch_init_core_variables(const struct retro_variable *vars); static void rarch_init_core_options( const struct retro_core_option_definition *option_defs); +#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB) static bool secondary_core_create(void); +#endif static int16_t input_state_get_last(unsigned port, unsigned device, unsigned index, unsigned id); static int16_t input_state(unsigned port, unsigned device, @@ -7494,14 +7498,12 @@ bool command_event(enum event_command cmd, void *data) } break; case CMD_EVENT_AUTOSAVE_INIT: +#ifdef HAVE_THREADS + retroarch_autosave_deinit(); { #ifdef HAVE_NETWORKING - unsigned autosave_interval = configuration_settings->uints.autosave_interval; -#endif - -#ifdef HAVE_THREADS - retroarch_autosave_deinit(); -#ifdef HAVE_NETWORKING + unsigned autosave_interval = + configuration_settings->uints.autosave_interval; /* Only enable state manager if netplay is not underway TODO/FIXME: Add a setting for these tweaks */ if ( (autosave_interval != 0) @@ -7662,7 +7664,9 @@ bool command_event(enum event_command cmd, void *data) #if defined(HAVE_FFMPEG) || defined(HAVE_MPV) const char *path_content_video_history = settings->paths.path_content_video_history; #endif +#ifdef HAVE_IMAGEVIEWER const char *path_content_image_history = settings->paths.path_content_image_history; +#endif command_event(CMD_EVENT_HISTORY_DEINIT, NULL); @@ -23039,8 +23043,6 @@ bool video_driver_texture_unload(uintptr_t *id) void video_driver_build_info(video_frame_info_t *video_info) { video_viewport_t *custom_vp = NULL; - struct retro_hw_render_callback *hwr = - video_driver_get_hw_context_internal(); settings_t *settings = configuration_settings; #ifdef HAVE_THREADS bool is_threaded = video_driver_is_threaded_internal(); From a4f143a71a512d08e40430246414467daf720031 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 21 May 2020 00:46:49 +0200 Subject: [PATCH 165/192] Buildfix --- retroarch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroarch.c b/retroarch.c index 4a9b386124..e177d0b188 100644 --- a/retroarch.c +++ b/retroarch.c @@ -7511,8 +7511,8 @@ bool command_event(enum event_command cmd, void *data) RARCH_NETPLAY_CTL_IS_ENABLED, NULL)) #endif runloop_autosave = autosave_init(); -#endif } +#endif break; case CMD_EVENT_AUDIO_STOP: midi_driver_set_all_sounds_off(); From 4f2566ad507a0a4f72c27f67c8c3ff0080c2f0f0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 21 May 2020 04:21:00 +0200 Subject: [PATCH 166/192] (JACK) Query audio device from settings struct again --- audio/drivers/jack.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/audio/drivers/jack.c b/audio/drivers/jack.c index fd68cc8600..053d62b654 100644 --- a/audio/drivers/jack.c +++ b/audio/drivers/jack.c @@ -25,6 +25,7 @@ #include #include +#include "../../configuration.h" #include "../../retroarch.h" #include "../../verbosity.h" @@ -96,13 +97,13 @@ static void shutdown_cb(void *data) #endif } -static int parse_ports(const char *audio_device, - char **dest_ports, const char **jports) +static int parse_ports(char **dest_ports, const char **jports) { int i; char *save = NULL; int parsed = 0; - char *audio_device_cpy = strdup(audio_device); + settings_t *settings = config_get_ptr(); + char *audio_device_cpy = strdup(settings->arrays.audio_device); const char *con = strtok_r(audio_device_cpy, ",", &save); if (con) @@ -203,7 +204,7 @@ static void *ja_init(const char *device, } } - parsed = parse_ports(device, dest_ports, jports); + parsed = parse_ports(dest_ports, jports); if (jack_activate(jd->client) < 0) { From 70f57974c75e9686e2d17bfc594273f188bfe861 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 21 May 2020 04:23:01 +0200 Subject: [PATCH 167/192] Buildfix --- deps/discord-rpc/src/rpc_connection.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/deps/discord-rpc/src/rpc_connection.cpp b/deps/discord-rpc/src/rpc_connection.cpp index 0afeda85fa..6904b32249 100644 --- a/deps/discord-rpc/src/rpc_connection.cpp +++ b/deps/discord-rpc/src/rpc_connection.cpp @@ -3,8 +3,6 @@ #include -#include - static const int RpcVersion = 1; static RpcConnection Instance; @@ -41,8 +39,8 @@ void RpcConnection::Open() const char *cmd = GetStrMember(&message, "cmd"); const char *evt = GetStrMember(&message, "evt"); if (cmd && evt - && string_is_equal(cmd, "DISPATCH") - && string_is_equal(evt, "READY")) + && !strcmp(cmd, "DISPATCH") + && !strcmp(evt, "READY")) { state = State::Connected; if (onConnect) From 6fa4350ade0bf5ed596992496e8212a339bb7fbc Mon Sep 17 00:00:00 2001 From: Autechre Date: Thu, 21 May 2020 04:53:51 +0200 Subject: [PATCH 168/192] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 9c058b1c7d..8392f2d87b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,5 @@ # Future +- AUDIO/JACK: Fix regression introduced after 1.8.4 - would hang at startup - CHEEVOS: Disable hardcore when cheats are enabled - CHD: Return false when special track cannot be found - INPUT MAPPING/REMAPPING: Restore broken 'reset to default' functionality with RetroPad 'start' button From e1e6f2db51fc32ef9d423ed6a97f1ef4a7955911 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 21 May 2020 05:10:19 +0200 Subject: [PATCH 169/192] Fix CXX_BUILD --- deps/discord-rpc/src/discord_rpc.cpp | 6 ++++-- network/discord.c | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/deps/discord-rpc/src/discord_rpc.cpp b/deps/discord-rpc/src/discord_rpc.cpp index 23b885f08e..3f430bed16 100644 --- a/deps/discord-rpc/src/discord_rpc.cpp +++ b/deps/discord-rpc/src/discord_rpc.cpp @@ -1,3 +1,4 @@ +#include #include "discord_rpc.h" #include "backoff.h" @@ -14,15 +15,16 @@ #include #endif + /* Forward declarations */ -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CXX_BUILD) extern "C" { #endif void Discord_Register(const char *a, const char *b); void Discord_RegisterSteamGame(const char *a, const char *b); -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CXX_BUILD) } #endif diff --git a/network/discord.c b/network/discord.c index 89ac517c53..92f6234378 100644 --- a/network/discord.c +++ b/network/discord.c @@ -13,6 +13,8 @@ * If not, see . */ +#include + #include #include #include @@ -89,14 +91,13 @@ static discord_state_t discord_st; #define CDN_URL "https://cdn.discordapp.com/avatars" /* Forward declarations */ -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CXX_BUILD) extern "C" { #endif void Discord_Register(const char *a, const char *b); -void Discord_RegisterSteamGame(const char *a, const char *b); -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CXX_BUILD) } #endif From 04016ed4a6dff9d872c104300468e2a26b6767e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Coll=20Cerd=C3=A1n?= Date: Thu, 21 May 2020 13:28:17 +0200 Subject: [PATCH 170/192] Improve shader initialization code. Patch by @jdgleaver. --- retroarch.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/retroarch.c b/retroarch.c index 419e45c8de..2116301289 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2452,8 +2452,10 @@ struct string_list *dir_list_new_special(const char *input_dir, string_list_free(str_list); exts = ext_shaders; } -#endif break; +#else + return NULL; +#endif case DIR_LIST_COLLECTIONS: exts = "lpl"; break; @@ -21668,6 +21670,7 @@ static bool video_driver_init_internal(bool *video_is_threaded) dir_free_shader(); +#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) if (!string_is_empty(settings->paths.directory_video_shader)) dir_list_is_free = !dir_init_shader( settings->paths.directory_video_shader, @@ -21680,18 +21683,18 @@ static bool video_driver_init_internal(bool *video_is_threaded) if (dir_list_is_free && !path_is_empty(RARCH_PATH_CONFIG)) { - config_file_directory = (char*)malloc(PATH_MAX_LENGTH); - - fill_pathname_basedir(config_file_directory, - path_get(RARCH_PATH_CONFIG), PATH_MAX_LENGTH); + config_file_directory = strdup(path_get(RARCH_PATH_CONFIG)); + path_basedir(config_file_directory); if (config_file_directory) { dir_list_is_free = !dir_init_shader( config_file_directory, settings->bools.show_hidden_files); + free(config_file_directory); } } +#endif return true; From f522cfcce89adab5100178193094ea5bc0ab981f Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Thu, 21 May 2020 13:28:42 +0100 Subject: [PATCH 171/192] Optimise 'path_is_absolute()' --- libretro-common/file/file_path.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 866d54e4cd..a6a464d786 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -621,19 +621,29 @@ const char *path_basename(const char *path) **/ bool path_is_absolute(const char *path) { +#if defined(__wiiu__) || defined(VITA) + const char *seperator = NULL; +#endif + + if (string_is_empty(path)) + return false; + if (path[0] == '/') return true; -#ifdef _WIN32 - /* Many roads lead to Rome ... */ - if (( strstr(path, "\\\\") == path) - || strstr(path, ":/") - || strstr(path, ":\\") - || strstr(path, ":\\\\")) + +#if defined(_WIN32) + /* Many roads lead to Rome... + * Note: Drive letter can only be 1 character long */ + if (string_starts_with(path, "\\\\") || + string_starts_with(path + 1, ":/") || + string_starts_with(path + 1, ":\\")) return true; #elif defined(__wiiu__) || defined(VITA) - if (strstr(path, ":/")) + seperator = strchr(path, ':'); + if (seperator && (seperator[1] == '/')) return true; #endif + return false; } From a9cf718e75cced656b7511e1801429fceb83c2d3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 21 May 2020 05:45:44 +0200 Subject: [PATCH 172/192] Get rid of auto variable in glslang.cpp --- gfx/drivers_shader/glslang.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gfx/drivers_shader/glslang.cpp b/gfx/drivers_shader/glslang.cpp index b4e9820e94..845f8e4061 100644 --- a/gfx/drivers_shader/glslang.cpp +++ b/gfx/drivers_shader/glslang.cpp @@ -400,7 +400,9 @@ bool glslang::compile_spirv(const string &source, Stage stage, EShMessages messages = static_cast(EShMsgDefault | EShMsgVulkanRules | EShMsgSpvRules); - auto forbid_include = glslang::TShader::ForbidIncluder(); + glslang::TShader::ForbidIncluder forbid_include = + glslang::TShader::ForbidIncluder(); + if (!shader.preprocess(&process.GetResources(), 100, ENoProfile, false, false, messages, &msg, forbid_include)) From 0edd97d5dbda4202aa015e750c2b4508d9408681 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 21 May 2020 20:04:22 +0200 Subject: [PATCH 173/192] file_path.c) Cleanup --- libretro-common/file/file_path.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index a6a464d786..62a3eceaf2 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -621,10 +621,6 @@ const char *path_basename(const char *path) **/ bool path_is_absolute(const char *path) { -#if defined(__wiiu__) || defined(VITA) - const char *seperator = NULL; -#endif - if (string_is_empty(path)) return false; @@ -639,9 +635,11 @@ bool path_is_absolute(const char *path) string_starts_with(path + 1, ":\\")) return true; #elif defined(__wiiu__) || defined(VITA) - seperator = strchr(path, ':'); - if (seperator && (seperator[1] == '/')) - return true; + { + const char *seperator = strchr(path, ':'); + if (seperator && (seperator[1] == '/')) + return true; + } #endif return false; From 4b4a8693ac941e121588c8fa84dfc06aa5b3f7c4 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Thu, 21 May 2020 22:26:59 +0200 Subject: [PATCH 174/192] Remove unused variable --- ui/drivers/ui_cocoa.m | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index d31c99b989..1244430a64 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -123,7 +123,6 @@ static void app_terminate(void) case NSEventTypeOtherMouseDragged: { NSPoint pos; - NSPoint mouse_pos; apple = (cocoa_input_data_t*)input_driver_get_data(); if (!apple) return; From ede03659ca8099a78361d9c1c9862c03edc37d57 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Thu, 21 May 2020 22:31:51 +0200 Subject: [PATCH 175/192] Update --- gfx/gfx_widgets.c | 5 +++-- retroarch.c | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/gfx/gfx_widgets.c b/gfx/gfx_widgets.c index 32a5c437a5..f34a0ce3ed 100644 --- a/gfx/gfx_widgets.c +++ b/gfx/gfx_widgets.c @@ -1509,7 +1509,9 @@ void gfx_widgets_frame(void *data) bool widgets_is_rewinding; bool runloop_is_slowmotion; int top_right_x_advance; - int scissor_me_timbers; +#ifdef HAVE_CHEEVOS + int scissor_me_timbers = 0; +#endif if (!widgets_active) return; @@ -1528,7 +1530,6 @@ void gfx_widgets_frame(void *data) widgets_is_rewinding = video_info->widgets_is_rewinding; runloop_is_slowmotion = video_info->runloop_is_slowmotion; top_right_x_advance = video_width; - scissor_me_timbers = 0; gfx_widgets_frame_count++; diff --git a/retroarch.c b/retroarch.c index 1e0a30c1b2..1942c8a549 100644 --- a/retroarch.c +++ b/retroarch.c @@ -5771,26 +5771,27 @@ static bool run_translation_service(bool paused) json_buffer = (char*)malloc(json_length); if (!json_buffer) goto finish; + /* Image data */ - memcpy(json_buffer, (const void*)rf1, 11*sizeof(uint8_t)); - memcpy(json_buffer+11, bmp64_buffer, (out_length)*sizeof(uint8_t)); - memcpy(json_buffer+11+out_length, "\"", 1*sizeof(uint8_t)); - curr_length = 11+out_length+1; + memcpy(json_buffer, (const void*)rf1, 11 * sizeof(uint8_t)); + memcpy(json_buffer + 11, bmp64_buffer, out_length * sizeof(uint8_t)); + memcpy(json_buffer + 11 + out_length, "\"", 1 * sizeof(uint8_t)); + curr_length = 11 + out_length + 1; /* State data */ memcpy(json_buffer+curr_length, state_son, state_son_length*sizeof(uint8_t)); - curr_length+= state_son_length; + curr_length += state_son_length; /* System Label */ if (rf3) { - memcpy(json_buffer+curr_length, (const void*)rf3, (15+strlen(system_label))*sizeof(uint8_t)); - curr_length+=15+strlen(system_label); + memcpy(json_buffer + curr_length, (const void*)rf3, (15 + strlen(system_label)) * sizeof(uint8_t)); + curr_length += 15 + strlen(system_label); } else { - memcpy(json_buffer+curr_length, (const void*)rf2, 3*sizeof(uint8_t)); - curr_length+=3; + memcpy(json_buffer + curr_length, (const void*)rf2, 3 * sizeof(uint8_t)); + curr_length += 3; } #ifdef DEBUG @@ -21690,7 +21691,7 @@ static bool video_driver_init_internal(bool *video_is_threaded) if (config_file_directory) { - dir_list_is_free = !dir_init_shader( + dir_init_shader( config_file_directory, settings->bools.show_hidden_files); free(config_file_directory); From 6dc758a080fdbd2499168422642b9bb8bc6de618 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 21 May 2020 23:23:01 +0200 Subject: [PATCH 176/192] Move cheevos-new to cheevos/ --- Makefile.common | 10 +++++----- {cheevos-new => cheevos}/badges.c | 0 {cheevos-new => cheevos}/badges.h | 0 {cheevos-new => cheevos}/cheevos.c | 0 {cheevos-new => cheevos}/cheevos.h | 0 {cheevos-new => cheevos}/coro.h | 0 {cheevos-new => cheevos}/fixup.c | 0 {cheevos-new => cheevos}/fixup.h | 0 {cheevos-new => cheevos}/hash.c | 0 {cheevos-new => cheevos}/hash.h | 0 {cheevos-new => cheevos}/parser.c | 0 {cheevos-new => cheevos}/parser.h | 0 {cheevos-new => cheevos}/util.h | 0 gfx/gfx_widgets.c | 2 +- griffin/griffin.c | 10 +++++----- managers/cheat_manager.c | 2 +- menu/cbs/menu_cbs_get_value.c | 2 +- menu/cbs/menu_cbs_ok.c | 2 +- menu/cbs/menu_cbs_sublabel.c | 2 +- menu/drivers/ozone/ozone_texture.c | 2 +- menu/drivers/stripes.c | 2 +- menu/drivers/xmb.c | 2 +- menu/menu_displaylist.c | 2 +- menu/menu_setting.c | 2 +- menu/widgets/menu_dialog.c | 2 +- network/discord.c | 2 +- retroarch.c | 4 ++-- tasks/task_content.c | 2 +- 28 files changed, 25 insertions(+), 25 deletions(-) rename {cheevos-new => cheevos}/badges.c (100%) rename {cheevos-new => cheevos}/badges.h (100%) rename {cheevos-new => cheevos}/cheevos.c (100%) rename {cheevos-new => cheevos}/cheevos.h (100%) rename {cheevos-new => cheevos}/coro.h (100%) rename {cheevos-new => cheevos}/fixup.c (100%) rename {cheevos-new => cheevos}/fixup.h (100%) rename {cheevos-new => cheevos}/hash.c (100%) rename {cheevos-new => cheevos}/hash.h (100%) rename {cheevos-new => cheevos}/parser.c (100%) rename {cheevos-new => cheevos}/parser.h (100%) rename {cheevos-new => cheevos}/util.h (100%) diff --git a/Makefile.common b/Makefile.common index 89f07121c3..a18a4ec671 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1845,11 +1845,11 @@ ifeq ($(HAVE_NETWORKING), 1) DEFINES += -DHAVE_CHEEVOS INCLUDE_DIRS += -Ideps/rcheevos/include - OBJ += cheevos-new/cheevos.o \ - cheevos-new/badges.o \ - cheevos-new/fixup.o \ - cheevos-new/parser.o \ - cheevos-new/hash.o \ + OBJ += cheevos/cheevos.o \ + cheevos/badges.o \ + cheevos/fixup.o \ + cheevos/parser.o \ + cheevos/hash.o \ $(LIBRETRO_COMM_DIR)/formats/cdfs/cdfs.o \ deps/rcheevos/src/rcheevos/alloc.o \ deps/rcheevos/src/rcheevos/compat.o \ diff --git a/cheevos-new/badges.c b/cheevos/badges.c similarity index 100% rename from cheevos-new/badges.c rename to cheevos/badges.c diff --git a/cheevos-new/badges.h b/cheevos/badges.h similarity index 100% rename from cheevos-new/badges.h rename to cheevos/badges.h diff --git a/cheevos-new/cheevos.c b/cheevos/cheevos.c similarity index 100% rename from cheevos-new/cheevos.c rename to cheevos/cheevos.c diff --git a/cheevos-new/cheevos.h b/cheevos/cheevos.h similarity index 100% rename from cheevos-new/cheevos.h rename to cheevos/cheevos.h diff --git a/cheevos-new/coro.h b/cheevos/coro.h similarity index 100% rename from cheevos-new/coro.h rename to cheevos/coro.h diff --git a/cheevos-new/fixup.c b/cheevos/fixup.c similarity index 100% rename from cheevos-new/fixup.c rename to cheevos/fixup.c diff --git a/cheevos-new/fixup.h b/cheevos/fixup.h similarity index 100% rename from cheevos-new/fixup.h rename to cheevos/fixup.h diff --git a/cheevos-new/hash.c b/cheevos/hash.c similarity index 100% rename from cheevos-new/hash.c rename to cheevos/hash.c diff --git a/cheevos-new/hash.h b/cheevos/hash.h similarity index 100% rename from cheevos-new/hash.h rename to cheevos/hash.h diff --git a/cheevos-new/parser.c b/cheevos/parser.c similarity index 100% rename from cheevos-new/parser.c rename to cheevos/parser.c diff --git a/cheevos-new/parser.h b/cheevos/parser.h similarity index 100% rename from cheevos-new/parser.h rename to cheevos/parser.h diff --git a/cheevos-new/util.h b/cheevos/util.h similarity index 100% rename from cheevos-new/util.h rename to cheevos/util.h diff --git a/gfx/gfx_widgets.c b/gfx/gfx_widgets.c index f34a0ce3ed..7118c76bf5 100644 --- a/gfx/gfx_widgets.c +++ b/gfx/gfx_widgets.c @@ -44,7 +44,7 @@ #include "../tasks/task_content.h" #ifdef HAVE_CHEEVOS -#include "../cheevos-new/badges.h" +#include "../cheevos/badges.h" #endif static bool widgets_inited = false; diff --git a/griffin/griffin.c b/griffin/griffin.c index b7e28112a1..28cc31a289 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -174,11 +174,11 @@ ACHIEVEMENTS #include "../libretro-common/formats/cdfs/cdfs.c" #include "../network/net_http_special.c" -#include "../cheevos-new/cheevos.c" -#include "../cheevos-new/badges.c" -#include "../cheevos-new/fixup.c" -#include "../cheevos-new/hash.c" -#include "../cheevos-new/parser.c" +#include "../cheevos/cheevos.c" +#include "../cheevos/badges.c" +#include "../cheevos/fixup.c" +#include "../cheevos/hash.c" +#include "../cheevos/parser.c" #include "../deps/rcheevos/src/rcheevos/alloc.c" #include "../deps/rcheevos/src/rcheevos/compat.c" diff --git a/managers/cheat_manager.c b/managers/cheat_manager.c index b7209c818e..22851cc067 100644 --- a/managers/cheat_manager.c +++ b/managers/cheat_manager.c @@ -38,7 +38,7 @@ #endif #ifdef HAVE_CHEEVOS -#include "../cheevos-new/cheevos.h" +#include "../cheevos/cheevos.h" #endif #include "cheat_manager.h" diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 9c5fcbe5fc..c1b8d6d293 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -49,7 +49,7 @@ #endif #ifdef HAVE_CHEEVOS -#include "../../cheevos-new/cheevos.h" +#include "../../cheevos/cheevos.h" #endif #ifndef BIND_ACTION_GET_VALUE diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 2bd26efcb1..22ec4b824f 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -84,7 +84,7 @@ #endif #ifdef HAVE_CHEEVOS -#include "../../cheevos-new/cheevos.h" +#include "../../cheevos/cheevos.h" #endif #ifdef __WINRT__ diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 6c8e8ab826..fb8706a54a 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -26,7 +26,7 @@ #include "../../managers/core_option_manager.h" #ifdef HAVE_CHEEVOS -#include "../../cheevos-new/cheevos.h" +#include "../../cheevos/cheevos.h" #endif #include "../../core_info.h" #include "../../verbosity.h" diff --git a/menu/drivers/ozone/ozone_texture.c b/menu/drivers/ozone/ozone_texture.c index aa6b712e27..15a0d0e2b3 100644 --- a/menu/drivers/ozone/ozone_texture.c +++ b/menu/drivers/ozone/ozone_texture.c @@ -24,7 +24,7 @@ #include #ifdef HAVE_CHEEVOS -#include "../../../cheevos-new/badges.h" +#include "../../../cheevos/badges.h" #endif #include "../../../verbosity.h" diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index 991bf6f334..7b2ecac23d 100644 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -59,7 +59,7 @@ #include "../../tasks/tasks_internal.h" #ifdef HAVE_CHEEVOS -#include "../../cheevos-new/badges.h" +#include "../../cheevos/badges.h" #endif #include "../../content.h" diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index c2979b1e2a..04d6b9a1f2 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -56,7 +56,7 @@ #include "../../tasks/tasks_internal.h" -#include "../../cheevos-new/badges.h" +#include "../../cheevos/badges.h" #include "../../content.h" #define XMB_RIBBON_ROWS 64 diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 52fa8005cc..2fc1f61b92 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -39,7 +39,7 @@ #endif #ifdef HAVE_CHEEVOS -#include "../cheevos-new/cheevos.h" +#include "../cheevos/cheevos.h" #endif #ifdef HAVE_NETWORKING diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 30f6239e24..cb989d0d57 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -53,7 +53,7 @@ #endif #ifdef HAVE_CHEEVOS -#include "../cheevos-new/cheevos.h" +#include "../cheevos/cheevos.h" #endif #ifdef HAVE_TRANSLATE diff --git a/menu/widgets/menu_dialog.c b/menu/widgets/menu_dialog.c index 4a3551d3a7..df11a034d1 100644 --- a/menu/widgets/menu_dialog.c +++ b/menu/widgets/menu_dialog.c @@ -24,7 +24,7 @@ #endif #ifdef HAVE_CHEEVOS -#include "../../cheevos-new/cheevos.h" +#include "../../cheevos/cheevos.h" #endif #include "menu_dialog.h" diff --git a/network/discord.c b/network/discord.c index 92f6234378..882da7ae64 100644 --- a/network/discord.c +++ b/network/discord.c @@ -44,7 +44,7 @@ #endif #ifdef HAVE_CHEEVOS -#include "../cheevos-new/cheevos.h" +#include "../cheevos/cheevos.h" #endif #ifdef HAVE_MENU diff --git a/retroarch.c b/retroarch.c index 1942c8a549..46224cb30a 100644 --- a/retroarch.c +++ b/retroarch.c @@ -155,8 +155,8 @@ #include "input/input_remapping.h" #ifdef HAVE_CHEEVOS -#include "cheevos-new/cheevos.h" -#include "cheevos-new/fixup.h" +#include "cheevos/cheevos.h" +#include "cheevos/fixup.h" #endif #ifdef HAVE_TRANSLATE diff --git a/tasks/task_content.c b/tasks/task_content.c index 13ef8d75fc..2120fe5725 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -82,7 +82,7 @@ #endif #ifdef HAVE_CHEEVOS -#include "../cheevos-new/cheevos.h" +#include "../cheevos/cheevos.h" #endif #include "task_content.h" From 875791b40c7e79bba35c450efd9102e8a8df2bba Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 22 May 2020 01:09:28 +0200 Subject: [PATCH 177/192] (cheat manager) Cleanups - go through function pointer --- managers/cheat_manager.c | 847 +++++++++++++++++++++------------------ 1 file changed, 451 insertions(+), 396 deletions(-) diff --git a/managers/cheat_manager.c b/managers/cheat_manager.c index 22851cc067..5a6d111721 100644 --- a/managers/cheat_manager.c +++ b/managers/cheat_manager.c @@ -53,52 +53,53 @@ cheat_manager_t cheat_manager_state; unsigned cheat_manager_get_buf_size(void) { - return cheat_manager_state.buf_size; + cheat_manager_t *cheat_st = &cheat_manager_state; + return cheat_st->buf_size; } unsigned cheat_manager_get_size(void) { - return cheat_manager_state.size; + cheat_manager_t *cheat_st = &cheat_manager_state; + return cheat_st->size; } #ifdef HAVE_CHEEVOS -static void cheat_manager_pause_cheevos() +static void cheat_manager_pause_cheevos(void) { - if (rcheevos_hardcore_active && rcheevos_loaded && !rcheevos_hardcore_paused) - { - rcheevos_pause_hardcore(); + rcheevos_pause_hardcore(); - runloop_msg_queue_push(msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); - RARCH_LOG("%s\n", msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT)); - } + runloop_msg_queue_push(msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + RARCH_LOG("%s\n", msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT)); } #endif void cheat_manager_apply_cheats(void) { unsigned i, idx = 0; + cheat_manager_t *cheat_st = &cheat_manager_state; - if (!cheat_manager_state.cheats) + if (!cheat_st->cheats) return; core_reset_cheat(); - for (i = 0; i < cheat_manager_state.size; i++) + for (i = 0; i < cheat_st->size; i++) { - if (cheat_manager_state.cheats[i].state && cheat_manager_state.cheats[i].handler == CHEAT_HANDLER_TYPE_EMU) + if ( cheat_st->cheats[i].state + && cheat_st->cheats[i].handler == CHEAT_HANDLER_TYPE_EMU) { retro_ctx_cheat_info_t cheat_info; - cheat_info.index = idx++; + cheat_info.index = idx++; cheat_info.enabled = true; - cheat_info.code = cheat_manager_state.cheats[i].code; + cheat_info.code = cheat_st->cheats[i].code; if (!string_is_empty(cheat_info.code)) core_set_cheat(&cheat_info); } } - if (cheat_manager_state.size > 0) + if (cheat_st->size > 0) { runloop_msg_queue_push(msg_hash_to_str(MSG_APPLYING_CHEAT), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); RARCH_LOG("%s\n", msg_hash_to_str(MSG_APPLYING_CHEAT)); @@ -106,19 +107,23 @@ void cheat_manager_apply_cheats(void) #ifdef HAVE_CHEEVOS if (idx != 0) - cheat_manager_pause_cheevos(); + if ( rcheevos_hardcore_active + && rcheevos_loaded + && !rcheevos_hardcore_paused) + cheat_manager_pause_cheevos(); #endif } void cheat_manager_set_code(unsigned i, const char *str) { - if (!cheat_manager_state.cheats) + cheat_manager_t *cheat_st = &cheat_manager_state; + if (!cheat_st->cheats) return; if (!string_is_empty(str)) - strcpy(cheat_manager_state.cheats[i].code, str); + strcpy(cheat_st->cheats[i].code, str); - cheat_manager_state.cheats[i].state = true; + cheat_st->cheats[i].state = true; } /** @@ -129,13 +134,17 @@ void cheat_manager_set_code(unsigned i, const char *str) * * Returns: true (1) if successful, otherwise false (0). **/ -bool cheat_manager_save(const char *path, const char *cheat_database, bool overwrite) +bool cheat_manager_save( + const char *path, + const char *cheat_database, + bool overwrite) { bool ret; unsigned i; char buf[PATH_MAX_LENGTH]; char cheats_file[PATH_MAX_LENGTH]; - config_file_t *conf = NULL; + config_file_t *conf = NULL; + cheat_manager_t *cheat_st = &cheat_manager_state; unsigned int* data_ptrs[16] = { NULL}; char* keys[16] = { (char*)"cheat%u_handler", @@ -158,7 +167,7 @@ bool cheat_manager_save(const char *path, const char *cheat_database, bool overw buf[0] = cheats_file[0] = '\0'; - if ((!cheat_manager_state.cheats) || cheat_manager_state.size == 0) + if (!cheat_st->cheats || cheat_st->size == 0) return false; if (!cheat_database) @@ -179,9 +188,9 @@ bool cheat_manager_save(const char *path, const char *cheat_database, bool overw conf->guaranteed_no_duplicates = true; - config_set_int(conf, "cheats", cheat_manager_state.size); + config_set_int(conf, "cheats", cheat_st->size); - for (i = 0; i < cheat_manager_state.size; i++) + for (i = 0; i < cheat_st->size; i++) { unsigned j; char endian_key[100]; @@ -197,31 +206,31 @@ bool cheat_manager_save(const char *path, const char *cheat_database, bool overw snprintf(code_key, sizeof(code_key), "cheat%u_code", i); snprintf(enable_key, sizeof(enable_key), "cheat%u_enable", i); - if (!string_is_empty(cheat_manager_state.cheats[i].desc)) - config_set_string(conf, desc_key, cheat_manager_state.cheats[i].desc); + if (!string_is_empty(cheat_st->cheats[i].desc)) + config_set_string(conf, desc_key, cheat_st->cheats[i].desc); else - config_set_string(conf, desc_key, cheat_manager_state.cheats[i].code); + config_set_string(conf, desc_key, cheat_st->cheats[i].code); - config_set_string(conf, code_key, cheat_manager_state.cheats[i].code); - config_set_bool(conf, enable_key, cheat_manager_state.cheats[i].state); - config_set_bool(conf, endian_key, cheat_manager_state.cheats[i].big_endian); + config_set_string(conf, code_key, cheat_st->cheats[i].code); + config_set_bool(conf, enable_key, cheat_st->cheats[i].state); + config_set_bool(conf, endian_key, cheat_st->cheats[i].big_endian); - data_ptrs[0] = &cheat_manager_state.cheats[i].handler; - data_ptrs[1] = &cheat_manager_state.cheats[i].memory_search_size; - data_ptrs[2] = &cheat_manager_state.cheats[i].cheat_type; - data_ptrs[3] = &cheat_manager_state.cheats[i].value; - data_ptrs[4] = &cheat_manager_state.cheats[i].address; - data_ptrs[5] = &cheat_manager_state.cheats[i].address_mask; - data_ptrs[6] = &cheat_manager_state.cheats[i].rumble_type; - data_ptrs[7] = &cheat_manager_state.cheats[i].rumble_value; - data_ptrs[8] = &cheat_manager_state.cheats[i].rumble_port; - data_ptrs[9] = &cheat_manager_state.cheats[i].rumble_primary_strength; - data_ptrs[10] = &cheat_manager_state.cheats[i].rumble_primary_duration; - data_ptrs[11] = &cheat_manager_state.cheats[i].rumble_secondary_strength; - data_ptrs[12] = &cheat_manager_state.cheats[i].rumble_secondary_duration; - data_ptrs[13] = &cheat_manager_state.cheats[i].repeat_count; - data_ptrs[14] = &cheat_manager_state.cheats[i].repeat_add_to_value; - data_ptrs[15] = &cheat_manager_state.cheats[i].repeat_add_to_address; + data_ptrs[0] = &cheat_st->cheats[i].handler; + data_ptrs[1] = &cheat_st->cheats[i].memory_search_size; + data_ptrs[2] = &cheat_st->cheats[i].cheat_type; + data_ptrs[3] = &cheat_st->cheats[i].value; + data_ptrs[4] = &cheat_st->cheats[i].address; + data_ptrs[5] = &cheat_st->cheats[i].address_mask; + data_ptrs[6] = &cheat_st->cheats[i].rumble_type; + data_ptrs[7] = &cheat_st->cheats[i].rumble_value; + data_ptrs[8] = &cheat_st->cheats[i].rumble_port; + data_ptrs[9] = &cheat_st->cheats[i].rumble_primary_strength; + data_ptrs[10] = &cheat_st->cheats[i].rumble_primary_duration; + data_ptrs[11] = &cheat_st->cheats[i].rumble_secondary_strength; + data_ptrs[12] = &cheat_st->cheats[i].rumble_secondary_duration; + data_ptrs[13] = &cheat_st->cheats[i].repeat_count; + data_ptrs[14] = &cheat_st->cheats[i].repeat_add_to_value; + data_ptrs[15] = &cheat_st->cheats[i].repeat_add_to_address; for (j = 0; j < 16; j++) { @@ -240,40 +249,46 @@ bool cheat_manager_save(const char *path, const char *cheat_database, bool overw bool cheat_manager_copy_idx_to_working(unsigned idx) { - if ((!cheat_manager_state.cheats) || (cheat_manager_state.size < idx + 1)) + cheat_manager_t *cheat_st = &cheat_manager_state; + if (!cheat_st->cheats || (cheat_st->size < idx + 1)) return false; - memcpy(&(cheat_manager_state.working_cheat), &(cheat_manager_state.cheats[idx]), sizeof(struct item_cheat)); + memcpy(&cheat_st->working_cheat, + &cheat_st->cheats[idx], sizeof(struct item_cheat)); - if (cheat_manager_state.cheats[idx].desc) - strlcpy(cheat_manager_state.working_desc, cheat_manager_state.cheats[idx].desc, CHEAT_DESC_SCRATCH_SIZE); + if (cheat_st->cheats[idx].desc) + strlcpy(cheat_st->working_desc, cheat_st->cheats[idx].desc, CHEAT_DESC_SCRATCH_SIZE); else - cheat_manager_state.working_desc[0] = '\0'; + cheat_st->working_desc[0] = '\0'; - if (cheat_manager_state.cheats[idx].code) - strlcpy(cheat_manager_state.working_code, cheat_manager_state.cheats[idx].code, CHEAT_CODE_SCRATCH_SIZE); + if (cheat_st->cheats[idx].code) + strlcpy(cheat_st->working_code, + cheat_st->cheats[idx].code, + CHEAT_CODE_SCRATCH_SIZE); else - cheat_manager_state.working_code[0] = '\0'; + cheat_st->working_code[0] = '\0'; return true; } bool cheat_manager_copy_working_to_idx(unsigned idx) { - if ((!cheat_manager_state.cheats) || (cheat_manager_state.size < idx + 1)) + cheat_manager_t *cheat_st = &cheat_manager_state; + if (!cheat_st->cheats || (cheat_st->size < idx + 1)) return false; - memcpy(&(cheat_manager_state.cheats[idx]), &(cheat_manager_state.working_cheat), sizeof(struct item_cheat)); + memcpy(&cheat_st->cheats[idx], &cheat_st->working_cheat, + sizeof(struct item_cheat)); - if (cheat_manager_state.cheats[idx].desc) - free(cheat_manager_state.cheats[idx].desc); + if (cheat_st->cheats[idx].desc) + free(cheat_st->cheats[idx].desc); - cheat_manager_state.cheats[idx].desc = strdup(cheat_manager_state.working_desc); + cheat_st->cheats[idx].desc = strdup(cheat_st->working_desc); - if (cheat_manager_state.cheats[idx].code) - free(cheat_manager_state.cheats[idx].code); + if (cheat_st->cheats[idx].code) + free(cheat_st->cheats[idx].code); - cheat_manager_state.cheats[idx].code = strdup(cheat_manager_state.working_code); + cheat_st->cheats[idx].code = strdup(cheat_st->working_code); return true; } @@ -281,89 +296,90 @@ bool cheat_manager_copy_working_to_idx(unsigned idx) static void cheat_manager_free(void) { unsigned i = 0; + cheat_manager_t *cheat_st = &cheat_manager_state; - if (cheat_manager_state.cheats) + if (cheat_st->cheats) { - for (i = 0; i < cheat_manager_state.size; i++) + for (i = 0; i < cheat_st->size; i++) { - if (cheat_manager_state.cheats[i].desc) - free(cheat_manager_state.cheats[i].desc); - if (cheat_manager_state.cheats[i].code) - free(cheat_manager_state.cheats[i].code); + if (cheat_st->cheats[i].desc) + free(cheat_st->cheats[i].desc); + if (cheat_st->cheats[i].code) + free(cheat_st->cheats[i].code); } - free(cheat_manager_state.cheats); + free(cheat_st->cheats); } - if (cheat_manager_state.prev_memory_buf) - free(cheat_manager_state.prev_memory_buf); + if (cheat_st->prev_memory_buf) + free(cheat_st->prev_memory_buf); - if (cheat_manager_state.matches) - free(cheat_manager_state.matches); + if (cheat_st->matches) + free(cheat_st->matches); - if (cheat_manager_state.memory_buf_list) - free(cheat_manager_state.memory_buf_list); + if (cheat_st->memory_buf_list) + free(cheat_st->memory_buf_list); - if (cheat_manager_state.memory_size_list) - free(cheat_manager_state.memory_size_list); - - cheat_manager_state.cheats = NULL; - cheat_manager_state.size = 0; - cheat_manager_state.buf_size = 0; - cheat_manager_state.prev_memory_buf = NULL; - cheat_manager_state.curr_memory_buf = NULL; - cheat_manager_state.memory_buf_list = NULL; - cheat_manager_state.memory_size_list = NULL; - cheat_manager_state.matches = NULL; - cheat_manager_state.num_memory_buffers = 0; - cheat_manager_state.total_memory_size = 0; - cheat_manager_state.memory_initialized = false; - cheat_manager_state.memory_search_initialized = false; + if (cheat_st->memory_size_list) + free(cheat_st->memory_size_list); + cheat_st->cheats = NULL; + cheat_st->size = 0; + cheat_st->buf_size = 0; + cheat_st->prev_memory_buf = NULL; + cheat_st->curr_memory_buf = NULL; + cheat_st->memory_buf_list = NULL; + cheat_st->memory_size_list = NULL; + cheat_st->matches = NULL; + cheat_st->num_memory_buffers = 0; + cheat_st->total_memory_size = 0; + cheat_st->memory_initialized = false; + cheat_st->memory_search_initialized = false; } - static void cheat_manager_new(unsigned size) { unsigned i; + cheat_manager_t *cheat_st = &cheat_manager_state; cheat_manager_free(); - cheat_manager_state.buf_size = size; - cheat_manager_state.size = size; - cheat_manager_state.search_bit_size = 3; - cheat_manager_state.cheats = (struct item_cheat*) - calloc(cheat_manager_state.buf_size, sizeof(struct item_cheat)); + cheat_st->buf_size = size; + cheat_st->size = size; + cheat_st->search_bit_size = 3; + cheat_st->cheats = (struct item_cheat*) + calloc(cheat_st->buf_size, sizeof(struct item_cheat)); - if (!cheat_manager_state.cheats) + if (!cheat_st->cheats) { - cheat_manager_state.buf_size = 0; - cheat_manager_state.size = 0; - cheat_manager_state.cheats = NULL; + cheat_st->buf_size = 0; + cheat_st->size = 0; + cheat_st->cheats = NULL; return; } - for (i = 0; i < cheat_manager_state.size; i++) + for (i = 0; i < cheat_st->size; i++) { - cheat_manager_state.cheats[i].desc = NULL; - cheat_manager_state.cheats[i].code = NULL; - cheat_manager_state.cheats[i].state = false; - cheat_manager_state.cheats[i].repeat_count = 1; - cheat_manager_state.cheats[i].repeat_add_to_value = 0; - cheat_manager_state.cheats[i].repeat_add_to_address = 1; + cheat_st->cheats[i].desc = NULL; + cheat_st->cheats[i].code = NULL; + cheat_st->cheats[i].state = false; + cheat_st->cheats[i].repeat_count = 1; + cheat_st->cheats[i].repeat_add_to_value = 0; + cheat_st->cheats[i].repeat_add_to_address = 1; } } static void cheat_manager_load_cb_first_pass(char *key, char *value) { - errno = 0; + errno = 0; + cheat_manager_t *cheat_st = &cheat_manager_state; if (string_is_equal(key, "cheats")) { - cheat_manager_state.loading_cheat_size = (unsigned)strtoul(value, NULL, 0); + cheat_st->loading_cheat_size = (unsigned)strtoul(value, NULL, 0); if (errno != 0) - cheat_manager_state.loading_cheat_size = 0; + cheat_st->loading_cheat_size = 0; } } @@ -372,9 +388,11 @@ static void cheat_manager_load_cb_second_pass(char *key, char *value) char cheat_num_str[20]; unsigned cheat_num; unsigned cheat_idx; - unsigned idx = 5; - size_t key_length = 0; - errno = 0; + unsigned idx = 5; + size_t key_length = 0; + cheat_manager_t *cheat_st = &cheat_manager_state; + + errno = 0; if (strncmp(key, "cheat", 5) != 0) return; @@ -391,73 +409,74 @@ static void cheat_manager_load_cb_second_pass(char *key, char *value) cheat_num = (unsigned)strtoul(cheat_num_str, NULL, 0); - if (cheat_num + cheat_manager_state.loading_cheat_offset >= cheat_manager_state.size) + if (cheat_num + cheat_st->loading_cheat_offset >= cheat_st->size) return; key = key + idx + 1; - cheat_idx = cheat_num + cheat_manager_state.loading_cheat_offset; + cheat_idx = cheat_num + cheat_st->loading_cheat_offset; if (string_is_equal(key, "address")) - cheat_manager_state.cheats[cheat_idx].address = (unsigned)strtoul(value, NULL, 0); + cheat_st->cheats[cheat_idx].address = (unsigned)strtoul(value, NULL, 0); else if (string_is_equal(key, "address_bit_position")) - cheat_manager_state.cheats[cheat_idx].address_mask = (unsigned)strtoul(value, NULL, 0); + cheat_st->cheats[cheat_idx].address_mask = (unsigned)strtoul(value, NULL, 0); else if (string_is_equal(key, "big_endian")) - cheat_manager_state.cheats[cheat_idx].big_endian = (string_is_equal(value, "true") || string_is_equal(value, "1")); + cheat_st->cheats[cheat_idx].big_endian = (string_is_equal(value, "true") || string_is_equal(value, "1")); else if (string_is_equal(key, "cheat_type")) - cheat_manager_state.cheats[cheat_idx].cheat_type = (unsigned)strtoul(value, NULL, 0); + cheat_st->cheats[cheat_idx].cheat_type = (unsigned)strtoul(value, NULL, 0); else if (string_is_equal(key, "code")) - cheat_manager_state.cheats[cheat_idx].code = strdup(value); + cheat_st->cheats[cheat_idx].code = strdup(value); else if (string_is_equal(key, "desc")) - cheat_manager_state.cheats[cheat_idx].desc = strdup(value); + cheat_st->cheats[cheat_idx].desc = strdup(value); else if (string_is_equal(key, "enable")) - cheat_manager_state.cheats[cheat_idx].state = (string_is_equal(value, "true") || string_is_equal(value, "1")); + cheat_st->cheats[cheat_idx].state = (string_is_equal(value, "true") || string_is_equal(value, "1")); else if (string_is_equal(key, "handler")) - cheat_manager_state.cheats[cheat_idx].handler = (unsigned)strtoul(value, NULL, 0); + cheat_st->cheats[cheat_idx].handler = (unsigned)strtoul(value, NULL, 0); else if (string_is_equal(key, "memory_search_size")) - cheat_manager_state.cheats[cheat_idx].memory_search_size = (unsigned)strtoul(value, NULL, 0); + cheat_st->cheats[cheat_idx].memory_search_size = (unsigned)strtoul(value, NULL, 0); else if (string_is_equal(key, "repeat_add_to_address")) - cheat_manager_state.cheats[cheat_idx].repeat_add_to_address = (unsigned)strtoul(value, NULL, 0); + cheat_st->cheats[cheat_idx].repeat_add_to_address = (unsigned)strtoul(value, NULL, 0); else if (string_is_equal(key, "repeat_add_to_value")) - cheat_manager_state.cheats[cheat_idx].repeat_add_to_value = (unsigned)strtoul(value, NULL, 0); + cheat_st->cheats[cheat_idx].repeat_add_to_value = (unsigned)strtoul(value, NULL, 0); else if (string_is_equal(key, "repeat_count")) - cheat_manager_state.cheats[cheat_idx].repeat_count = (unsigned)strtoul(value, NULL, 0); + cheat_st->cheats[cheat_idx].repeat_count = (unsigned)strtoul(value, NULL, 0); else if (string_is_equal(key, "rumble_port")) - cheat_manager_state.cheats[cheat_idx].rumble_port = (unsigned)strtoul(value, NULL, 0); + cheat_st->cheats[cheat_idx].rumble_port = (unsigned)strtoul(value, NULL, 0); else if (string_is_equal(key, "rumble_primary_duration")) - cheat_manager_state.cheats[cheat_idx].rumble_primary_duration = (unsigned)strtoul(value, NULL, 0); + cheat_st->cheats[cheat_idx].rumble_primary_duration = (unsigned)strtoul(value, NULL, 0); else if (string_is_equal(key, "rumble_primary_strength")) - cheat_manager_state.cheats[cheat_idx].rumble_primary_strength = (unsigned)strtoul(value, NULL, 0); + cheat_st->cheats[cheat_idx].rumble_primary_strength = (unsigned)strtoul(value, NULL, 0); else if (string_is_equal(key, "rumble_secondary_duration")) - cheat_manager_state.cheats[cheat_idx].rumble_secondary_duration = (unsigned)strtoul(value, NULL, 0); + cheat_st->cheats[cheat_idx].rumble_secondary_duration = (unsigned)strtoul(value, NULL, 0); else if (string_is_equal(key, "rumble_secondary_strength")) - cheat_manager_state.cheats[cheat_idx].rumble_secondary_strength = (unsigned)strtoul(value, NULL, 0); + cheat_st->cheats[cheat_idx].rumble_secondary_strength = (unsigned)strtoul(value, NULL, 0); else if (string_is_equal(key, "rumble_type")) - cheat_manager_state.cheats[cheat_idx].rumble_type = (unsigned)strtoul(value, NULL, 0); + cheat_st->cheats[cheat_idx].rumble_type = (unsigned)strtoul(value, NULL, 0); else if (string_is_equal(key, "rumble_value")) - cheat_manager_state.cheats[cheat_idx].rumble_value = (unsigned)strtoul(value, NULL, 0); + cheat_st->cheats[cheat_idx].rumble_value = (unsigned)strtoul(value, NULL, 0); else if (string_is_equal(key, "value")) - cheat_manager_state.cheats[cheat_idx].value = (unsigned)strtoul(value, NULL, 0); + cheat_st->cheats[cheat_idx].value = (unsigned)strtoul(value, NULL, 0); } bool cheat_manager_load(const char *path, bool append) { config_file_cb_t cb; - unsigned orig_size = 0; - unsigned cheats = 0; - unsigned i = 0; - config_file_t *conf = NULL; + unsigned orig_size = 0; + unsigned cheats = 0; + unsigned i = 0; + config_file_t *conf = NULL; + cheat_manager_t *cheat_st = &cheat_manager_state; cb.config_file_new_entry_cb = cheat_manager_load_cb_first_pass; - cheat_manager_state.loading_cheat_size = 0; + cheat_st->loading_cheat_size = 0; conf = config_file_new_with_callback(path, &cb); if (!conf) return false; - cheats = cheat_manager_state.loading_cheat_size; + cheats = cheat_st->loading_cheat_size; if (cheats == 0) goto error; @@ -475,9 +494,7 @@ bool cheat_manager_load(const char *path, bool append) else { cheats = cheats + orig_size; - if (cheat_manager_realloc(cheats, CHEAT_HANDLER_TYPE_EMU)) - { - } + if (cheat_manager_realloc(cheats, CHEAT_HANDLER_TYPE_EMU)) { } } } else @@ -486,19 +503,20 @@ bool cheat_manager_load(const char *path, bool append) cheat_manager_new(cheats); } - for (i = orig_size; cheat_manager_state.cheats && i < cheats; i++) + for (i = orig_size; cheat_st->cheats && i < cheats; i++) { - cheat_manager_state.cheats[i].idx = i; - cheat_manager_state.cheats[i].desc = NULL; - cheat_manager_state.cheats[i].code = NULL; - cheat_manager_state.cheats[i].state = false; - cheat_manager_state.cheats[i].big_endian = false; - cheat_manager_state.cheats[i].cheat_type = CHEAT_TYPE_SET_TO_VALUE; - cheat_manager_state.cheats[i].memory_search_size = 3; + cheat_st->cheats[i].idx = i; + cheat_st->cheats[i].desc = NULL; + cheat_st->cheats[i].code = NULL; + cheat_st->cheats[i].state = false; + cheat_st->cheats[i].big_endian = false; + cheat_st->cheats[i].cheat_type = CHEAT_TYPE_SET_TO_VALUE; + cheat_st->cheats[i].memory_search_size = 3; } - cheat_manager_state.loading_cheat_offset = orig_size; - cb.config_file_new_entry_cb = cheat_manager_load_cb_second_pass; + cheat_st->loading_cheat_offset = orig_size; + cb.config_file_new_entry_cb = + cheat_manager_load_cb_second_pass; conf = config_file_new_with_callback(path, &cb); if (!conf) @@ -516,56 +534,57 @@ error: bool cheat_manager_realloc(unsigned new_size, unsigned default_handler) { unsigned i; - unsigned orig_size = 0; + unsigned orig_size = 0; + cheat_manager_t *cheat_st = &cheat_manager_state; - if (!cheat_manager_state.cheats) + if (!cheat_st->cheats) { - cheat_manager_state.cheats = (struct item_cheat*) + cheat_st->cheats = (struct item_cheat*) calloc(new_size, sizeof(struct item_cheat)); - orig_size = 0; + orig_size = 0; } else { struct item_cheat *val = NULL; - orig_size = cheat_manager_state.size; + orig_size = cheat_st->size; /* if size is decreasing, free the items that will be lost */ for (i = new_size; i < orig_size; i++) { - if (cheat_manager_state.cheats[i].code) - free(cheat_manager_state.cheats[i].code); - if (cheat_manager_state.cheats[i].desc) - free(cheat_manager_state.cheats[i].desc); + if (cheat_st->cheats[i].code) + free(cheat_st->cheats[i].code); + if (cheat_st->cheats[i].desc) + free(cheat_st->cheats[i].desc); } val = (struct item_cheat*) - realloc(cheat_manager_state.cheats, + realloc(cheat_st->cheats, new_size * sizeof(struct item_cheat)); - cheat_manager_state.cheats = val ? val : NULL; + cheat_st->cheats = val ? val : NULL; } - if (!cheat_manager_state.cheats) + if (!cheat_st->cheats) { - cheat_manager_state.buf_size = cheat_manager_state.size = 0; - cheat_manager_state.cheats = NULL; + cheat_st->buf_size = cheat_st->size = 0; + cheat_st->cheats = NULL; return false; } - cheat_manager_state.buf_size = new_size; - cheat_manager_state.size = new_size; + cheat_st->buf_size = new_size; + cheat_st->size = new_size; - for (i = orig_size; i < cheat_manager_state.size; i++) + for (i = orig_size; i < cheat_st->size; i++) { - memset(&(cheat_manager_state.cheats[i]), 0, sizeof(cheat_manager_state.cheats[i])); - cheat_manager_state.cheats[i].state = false; - cheat_manager_state.cheats[i].handler = default_handler; - cheat_manager_state.cheats[i].cheat_type = CHEAT_TYPE_SET_TO_VALUE; - cheat_manager_state.cheats[i].memory_search_size = 3; - cheat_manager_state.cheats[i].idx = i; - cheat_manager_state.cheats[i].repeat_count = 1; - cheat_manager_state.cheats[i].repeat_add_to_value = 0; - cheat_manager_state.cheats[i].repeat_add_to_address = 1; + memset(&cheat_st->cheats[i], 0, sizeof(cheat_st->cheats[i])); + cheat_st->cheats[i].state = false; + cheat_st->cheats[i].handler = default_handler; + cheat_st->cheats[i].cheat_type = CHEAT_TYPE_SET_TO_VALUE; + cheat_st->cheats[i].memory_search_size = 3; + cheat_st->cheats[i].idx = i; + cheat_st->cheats[i].repeat_count = 1; + cheat_st->cheats[i].repeat_add_to_value = 0; + cheat_st->cheats[i].repeat_add_to_address = 1; } return true; @@ -578,10 +597,13 @@ void cheat_manager_update(cheat_manager_t *handle, unsigned handle_idx) if (!handle || !handle->cheats || handle->size == 0) return; - snprintf(msg, sizeof(msg), "Cheat: #%u [%s]: %s", - handle_idx, handle->cheats[handle_idx].state ? "ON" : "OFF", - (handle->cheats[handle_idx].desc != NULL) ? - (handle->cheats[handle_idx].desc) : (handle->cheats[handle_idx].code) + snprintf(msg, sizeof(msg), + "Cheat: #%u [%s]: %s", + handle_idx, + handle->cheats[handle_idx].state ? "ON" : "OFF", + handle->cheats[handle_idx].desc + ? (handle->cheats[handle_idx].desc) + : (handle->cheats[handle_idx].code) ); runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); RARCH_LOG("%s\n", msg); @@ -590,10 +612,11 @@ void cheat_manager_update(cheat_manager_t *handle, unsigned handle_idx) void cheat_manager_toggle_index(bool apply_cheats_after_toggle, unsigned i) { - if (!cheat_manager_state.cheats || cheat_manager_state.size == 0) + cheat_manager_t *cheat_st = &cheat_manager_state; + if (!cheat_st->cheats || cheat_st->size == 0) return; - cheat_manager_state.cheats[i].state = !cheat_manager_state.cheats[i].state; + cheat_st->cheats[i].state = !cheat_st->cheats[i].state; cheat_manager_update(&cheat_manager_state, i); if (apply_cheats_after_toggle) @@ -602,55 +625,61 @@ void cheat_manager_toggle_index(bool apply_cheats_after_toggle, void cheat_manager_toggle(void) { - if (!cheat_manager_state.cheats || cheat_manager_state.size == 0) + cheat_manager_t *cheat_st = &cheat_manager_state; + if (!cheat_st->cheats || cheat_st->size == 0) return; - cheat_manager_state.cheats[cheat_manager_state.ptr].state ^= true; + cheat_st->cheats[cheat_st->ptr].state ^= true; cheat_manager_apply_cheats(); - cheat_manager_update(&cheat_manager_state, cheat_manager_state.ptr); + cheat_manager_update(&cheat_manager_state, cheat_st->ptr); } void cheat_manager_index_next(void) { - if (!cheat_manager_state.cheats || cheat_manager_state.size == 0) + cheat_manager_t *cheat_st = &cheat_manager_state; + if (!cheat_st->cheats || cheat_st->size == 0) return; - cheat_manager_state.ptr = (cheat_manager_state.ptr + 1) % cheat_manager_state.size; - cheat_manager_update(&cheat_manager_state, cheat_manager_state.ptr); + cheat_st->ptr = (cheat_st->ptr + 1) % cheat_st->size; + cheat_manager_update(&cheat_manager_state, cheat_st->ptr); } void cheat_manager_index_prev(void) { - if (!cheat_manager_state.cheats || cheat_manager_state.size == 0) + cheat_manager_t *cheat_st = &cheat_manager_state; + if (!cheat_st->cheats || cheat_st->size == 0) return; - if (cheat_manager_state.ptr == 0) - cheat_manager_state.ptr = cheat_manager_state.size - 1; + if (cheat_st->ptr == 0) + cheat_st->ptr = cheat_st->size - 1; else - cheat_manager_state.ptr--; + cheat_st->ptr--; - cheat_manager_update(&cheat_manager_state, cheat_manager_state.ptr); + cheat_manager_update(&cheat_manager_state, cheat_st->ptr); } const char *cheat_manager_get_code(unsigned i) { - if (!cheat_manager_state.cheats) + cheat_manager_t *cheat_st = &cheat_manager_state; + if (!cheat_st->cheats) return NULL; - return cheat_manager_state.cheats[i].code; + return cheat_st->cheats[i].code; } const char *cheat_manager_get_desc(unsigned i) { - if (!cheat_manager_state.cheats) + cheat_manager_t *cheat_st = &cheat_manager_state; + if (!cheat_st->cheats) return NULL; - return cheat_manager_state.cheats[i].desc; + return cheat_st->cheats[i].desc; } bool cheat_manager_get_code_state(unsigned i) { - if (!cheat_manager_state.cheats) + cheat_manager_t *cheat_st = &cheat_manager_state; + if (!cheat_st->cheats) return false; - return cheat_manager_state.cheats[i].state; + return cheat_st->cheats[i].state; } static bool cheat_manager_get_game_specific_filename( @@ -730,7 +759,8 @@ void cheat_manager_state_free(void) bool cheat_manager_alloc_if_empty(void) { - if (!cheat_manager_state.cheats) + cheat_manager_t *cheat_st = &cheat_manager_state; + if (!cheat_st->cheats) cheat_manager_new(0); return true; @@ -744,63 +774,65 @@ int cheat_manager_initialize_memory(rarch_setting_t *setting, bool wraparound) bool is_search_initialization = (setting != NULL); rarch_system_info_t *system = runloop_get_system_info(); unsigned offset = 0; + cheat_manager_t *cheat_st = &cheat_manager_state; - cheat_manager_state.num_memory_buffers = 0; - cheat_manager_state.total_memory_size = 0; - cheat_manager_state.curr_memory_buf = NULL; + cheat_st->num_memory_buffers = 0; + cheat_st->total_memory_size = 0; + cheat_st->curr_memory_buf = NULL; - if (cheat_manager_state.memory_buf_list) + if (cheat_st->memory_buf_list) { - free(cheat_manager_state.memory_buf_list); - cheat_manager_state.memory_buf_list = NULL; + free(cheat_st->memory_buf_list); + cheat_st->memory_buf_list = NULL; } - if (cheat_manager_state.memory_size_list) + if (cheat_st->memory_size_list) { - free(cheat_manager_state.memory_size_list); - cheat_manager_state.memory_size_list = NULL; + free(cheat_st->memory_size_list); + cheat_st->memory_size_list = NULL; } if (system && system->mmaps.num_descriptors > 0) { for (i = 0; i < system->mmaps.num_descriptors; i++) { - if ((system->mmaps.descriptors[i].core.flags & RETRO_MEMDESC_SYSTEM_RAM) != 0 && + if ((system->mmaps.descriptors[i].core.flags + & RETRO_MEMDESC_SYSTEM_RAM) != 0 && system->mmaps.descriptors[i].core.ptr && system->mmaps.descriptors[i].core.len > 0) { - cheat_manager_state.num_memory_buffers++; + cheat_st->num_memory_buffers++; - if (!cheat_manager_state.memory_buf_list) - cheat_manager_state.memory_buf_list = (uint8_t**)calloc(1, sizeof(uint8_t *)); + if (!cheat_st->memory_buf_list) + cheat_st->memory_buf_list = (uint8_t**)calloc(1, sizeof(uint8_t *)); else - cheat_manager_state.memory_buf_list = (uint8_t**)realloc( - cheat_manager_state.memory_buf_list, sizeof(uint8_t *) * cheat_manager_state.num_memory_buffers); + cheat_st->memory_buf_list = (uint8_t**)realloc( + cheat_st->memory_buf_list, sizeof(uint8_t *) * cheat_st->num_memory_buffers); - if (!cheat_manager_state.memory_size_list) - cheat_manager_state.memory_size_list = (unsigned*)calloc(1, sizeof(unsigned)); + if (!cheat_st->memory_size_list) + cheat_st->memory_size_list = (unsigned*)calloc(1, sizeof(unsigned)); else { unsigned *val = (unsigned*)realloc( - cheat_manager_state.memory_size_list, + cheat_st->memory_size_list, sizeof(unsigned) * - cheat_manager_state.num_memory_buffers); + cheat_st->num_memory_buffers); if (val) - cheat_manager_state.memory_size_list = val; + cheat_st->memory_size_list = val; } - cheat_manager_state.memory_buf_list[cheat_manager_state.num_memory_buffers - 1] = (uint8_t*)system->mmaps.descriptors[i].core.ptr; - cheat_manager_state.memory_size_list[cheat_manager_state.num_memory_buffers - 1] = (unsigned)system->mmaps.descriptors[i].core.len; - cheat_manager_state.total_memory_size += system->mmaps.descriptors[i].core.len; + cheat_st->memory_buf_list[cheat_st->num_memory_buffers - 1] = (uint8_t*)system->mmaps.descriptors[i].core.ptr; + cheat_st->memory_size_list[cheat_st->num_memory_buffers - 1] = (unsigned)system->mmaps.descriptors[i].core.len; + cheat_st->total_memory_size += system->mmaps.descriptors[i].core.len; - if (!cheat_manager_state.curr_memory_buf) - cheat_manager_state.curr_memory_buf = (uint8_t*)system->mmaps.descriptors[i].core.ptr; + if (!cheat_st->curr_memory_buf) + cheat_st->curr_memory_buf = (uint8_t*)system->mmaps.descriptors[i].core.ptr; } } } - if (cheat_manager_state.num_memory_buffers == 0) + if (cheat_st->num_memory_buffers == 0) { meminfo.id = RETRO_MEMORY_SYSTEM_RAM; if (!core_get_memory(&meminfo)) @@ -812,70 +844,77 @@ int cheat_manager_initialize_memory(rarch_setting_t *setting, bool wraparound) if (meminfo.size == 0) return 0; - cheat_manager_state.memory_buf_list = (uint8_t**) + cheat_st->memory_buf_list = (uint8_t**) calloc(1, sizeof(uint8_t *)); - cheat_manager_state.memory_size_list = (unsigned*) + cheat_st->memory_size_list = (unsigned*) calloc(1, sizeof(unsigned)); - cheat_manager_state.num_memory_buffers = 1; - cheat_manager_state.memory_buf_list[0] = (uint8_t*)meminfo.data; - cheat_manager_state.memory_size_list[0] = (unsigned)meminfo.size; - cheat_manager_state.total_memory_size = (unsigned)meminfo.size; - cheat_manager_state.curr_memory_buf = (uint8_t*)meminfo.data; + cheat_st->num_memory_buffers = 1; + cheat_st->memory_buf_list[0] = (uint8_t*)meminfo.data; + cheat_st->memory_size_list[0] = (unsigned)meminfo.size; + cheat_st->total_memory_size = (unsigned)meminfo.size; + cheat_st->curr_memory_buf = (uint8_t*)meminfo.data; } - cheat_manager_state.num_matches = (cheat_manager_state.total_memory_size * 8) / ((int)pow(2, cheat_manager_state.search_bit_size)); + cheat_st->num_matches = (cheat_st->total_memory_size * 8) + / ((int)pow(2, cheat_st->search_bit_size)); - /* Ensure we're aligned on 4-byte boundary */ #if 0 + /* Ensure we're aligned on 4-byte boundary */ if (meminfo.size % 4 > 0) - cheat_manager_state.total_memory_size = cheat_manager_state.total_memory_size + (4 - (meminfo.size % 4)); + cheat_st->total_memory_size = cheat_st->total_memory_size + (4 - (meminfo.size % 4)); #endif if (is_search_initialization) { - if (cheat_manager_state.prev_memory_buf) + if (cheat_st->prev_memory_buf) { - free(cheat_manager_state.prev_memory_buf); - cheat_manager_state.prev_memory_buf = NULL; + free(cheat_st->prev_memory_buf); + cheat_st->prev_memory_buf = NULL; } - cheat_manager_state.prev_memory_buf = (uint8_t*)calloc(cheat_manager_state.total_memory_size, sizeof(uint8_t)); - if (!cheat_manager_state.prev_memory_buf) + cheat_st->prev_memory_buf = (uint8_t*)calloc( + cheat_st->total_memory_size, sizeof(uint8_t)); + + if (!cheat_st->prev_memory_buf) { runloop_msg_queue_push(msg_hash_to_str(MSG_CHEAT_INIT_FAIL), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); return 0; } - if (cheat_manager_state.matches) + if (cheat_st->matches) { - free(cheat_manager_state.matches); - cheat_manager_state.matches = NULL; + free(cheat_st->matches); + cheat_st->matches = NULL; } - cheat_manager_state.matches = (uint8_t*)calloc(cheat_manager_state.total_memory_size, sizeof(uint8_t)); - if (!cheat_manager_state.matches) + cheat_st->matches = (uint8_t*)calloc( + cheat_st->total_memory_size, sizeof(uint8_t)); + + if (!cheat_st->matches) { - free(cheat_manager_state.prev_memory_buf); - cheat_manager_state.prev_memory_buf = NULL; + free(cheat_st->prev_memory_buf); + cheat_st->prev_memory_buf = NULL; runloop_msg_queue_push(msg_hash_to_str(MSG_CHEAT_INIT_FAIL), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); return 0; } - memset(cheat_manager_state.matches, 0xFF, cheat_manager_state.total_memory_size); + memset(cheat_st->matches, 0xFF, cheat_st->total_memory_size); offset = 0; - for (i = 0; i < cheat_manager_state.num_memory_buffers; i++) + for (i = 0; i < cheat_st->num_memory_buffers; i++) { - memcpy(cheat_manager_state.prev_memory_buf + offset, cheat_manager_state.memory_buf_list[i], cheat_manager_state.memory_size_list[i]); - offset += cheat_manager_state.memory_size_list[i]; + memcpy(cheat_st->prev_memory_buf + offset, + cheat_st->memory_buf_list[i], + cheat_st->memory_size_list[i]); + offset += cheat_st->memory_size_list[i]; } - cheat_manager_state.memory_search_initialized = true; + cheat_st->memory_search_initialized = true; } - cheat_manager_state.memory_initialized = true; + cheat_st->memory_initialized = true; runloop_msg_queue_push(msg_hash_to_str(MSG_CHEAT_INIT_SUCCESS), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); @@ -892,56 +931,61 @@ int cheat_manager_initialize_memory(rarch_setting_t *setting, bool wraparound) static unsigned translate_address(unsigned address, unsigned char **curr) { - unsigned offset = 0; - unsigned i = 0; + unsigned offset = 0; + unsigned i = 0; + cheat_manager_t *cheat_st = &cheat_manager_state; - for (i = 0; i < cheat_manager_state.num_memory_buffers; i++) + for (i = 0; i < cheat_st->num_memory_buffers; i++) { - if ((address >= offset) && (address < offset + cheat_manager_state.memory_size_list[i])) + if ((address >= offset) && (address < offset + cheat_st->memory_size_list[i])) { - *curr = cheat_manager_state.memory_buf_list[i]; + *curr = cheat_st->memory_buf_list[i]; break; } else - offset += cheat_manager_state.memory_size_list[i]; + offset += cheat_st->memory_size_list[i]; } return offset; } -static void cheat_manager_setup_search_meta(unsigned int bitsize, unsigned int *bytes_per_item, unsigned int *mask, unsigned int *bits) +static void cheat_manager_setup_search_meta( + unsigned int bitsize, + unsigned int *bytes_per_item, + unsigned int *mask, + unsigned int *bits) { switch (bitsize) { case 0: *bytes_per_item = 1; - *bits = 1; - *mask = 0x01; + *bits = 1; + *mask = 0x01; break; case 1: *bytes_per_item = 1; - *bits = 2; - *mask = 0x03; + *bits = 2; + *mask = 0x03; break; case 2: *bytes_per_item = 1; - *bits = 4; - *mask = 0x0F; + *bits = 4; + *mask = 0x0F; break; case 3: *bytes_per_item = 1; - *bits = 8; - *mask = 0xFF; + *bits = 8; + *mask = 0xFF; break; case 4: *bytes_per_item = 2; - *bits = 8; - *mask = 0xFFFF; + *bits = 8; + *mask = 0xFFFF; break; case 5: *bytes_per_item = 4; - *bits = 8; - *mask = 0xFFFFFFFF; + *bits = 8; + *mask = 0xFFFFFFFF; break; } } @@ -949,8 +993,9 @@ static void cheat_manager_setup_search_meta(unsigned int bitsize, unsigned int * static int cheat_manager_search(enum cheat_search_type search_type) { char msg[100]; - unsigned char *curr = cheat_manager_state.curr_memory_buf; - unsigned char *prev = cheat_manager_state.prev_memory_buf; + cheat_manager_t *cheat_st = &cheat_manager_state; + unsigned char *curr = cheat_st->curr_memory_buf; + unsigned char *prev = cheat_st->prev_memory_buf; unsigned int idx = 0; unsigned int curr_val = 0; unsigned int prev_val = 0; @@ -961,16 +1006,16 @@ static int cheat_manager_search(enum cheat_search_type search_type) unsigned int i = 0; bool refresh = false; - if (cheat_manager_state.num_memory_buffers == 0) + if (cheat_st->num_memory_buffers == 0) { runloop_msg_queue_push(msg_hash_to_str(MSG_CHEAT_SEARCH_NOT_INITIALIZED), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); return 0; } - cheat_manager_setup_search_meta(cheat_manager_state.search_bit_size, &bytes_per_item, &mask, &bits); + cheat_manager_setup_search_meta(cheat_st->search_bit_size, &bytes_per_item, &mask, &bits); /* little endian FF000000 = 256 */ - for (idx = 0; idx < cheat_manager_state.total_memory_size; idx = idx + bytes_per_item) + for (idx = 0; idx < cheat_st->total_memory_size; idx = idx + bytes_per_item) { unsigned byte_part; @@ -979,18 +1024,18 @@ static int cheat_manager_search(enum cheat_search_type search_type) switch (bytes_per_item) { case 2: - curr_val = cheat_manager_state.big_endian ? + curr_val = cheat_st->big_endian ? (*(curr + idx - offset) * 256) + *(curr + idx + 1 - offset) : *(curr + idx - offset) + (*(curr + idx + 1 - offset) * 256); - prev_val = cheat_manager_state.big_endian ? + prev_val = cheat_st->big_endian ? (*(prev + idx) * 256) + *(prev + idx + 1) : *(prev + idx) + (*(prev + idx + 1) * 256); break; case 4: - curr_val = cheat_manager_state.big_endian ? + curr_val = cheat_st->big_endian ? (*(curr + idx - offset) * 256 * 256 * 256) + (*(curr + idx + 1 - offset) * 256 * 256) + (*(curr + idx + 2 - offset) * 256) + *(curr + idx + 3 - offset) : *(curr + idx - offset) + (*(curr + idx + 1 - offset) * 256) + (*(curr + idx + 2 - offset) * 256 * 256) + (*(curr + idx + 3 - offset) * 256 * 256 * 256); - prev_val = cheat_manager_state.big_endian ? + prev_val = cheat_st->big_endian ? (*(prev + idx) * 256 * 256 * 256) + (*(prev + idx + 1) * 256 * 256) + (*(prev + idx + 2) * 256) + *(prev + idx + 3) : *(prev + idx) + (*(prev + idx + 1) * 256) + (*(prev + idx + 2) * 256 * 256) + (*(prev + idx + 3) * 256 * 256 * 256); break; @@ -1008,9 +1053,9 @@ static int cheat_manager_search(enum cheat_search_type search_type) unsigned int prev_match; if (bits < 8) - prev_match = *(cheat_manager_state.matches + idx) & (mask << (byte_part * bits)); + prev_match = *(cheat_st->matches + idx) & (mask << (byte_part * bits)); else - prev_match = *(cheat_manager_state.matches + idx); + prev_match = *(cheat_st->matches + idx); if (prev_match > 0) { @@ -1018,7 +1063,7 @@ static int cheat_manager_search(enum cheat_search_type search_type) switch (search_type) { case CHEAT_SEARCH_TYPE_EXACT: - match = (curr_subval == cheat_manager_state.search_exact_value); + match = (curr_subval == cheat_st->search_exact_value); break; case CHEAT_SEARCH_TYPE_LT: match = (curr_subval < prev_subval); @@ -1039,22 +1084,22 @@ static int cheat_manager_search(enum cheat_search_type search_type) match = (curr_subval != prev_subval); break; case CHEAT_SEARCH_TYPE_EQPLUS: - match = (curr_subval == prev_subval + cheat_manager_state.search_eqplus_value); + match = (curr_subval == prev_subval + cheat_st->search_eqplus_value); break; case CHEAT_SEARCH_TYPE_EQMINUS: - match = (curr_subval == prev_subval - cheat_manager_state.search_eqminus_value); + match = (curr_subval == prev_subval - cheat_st->search_eqminus_value); break; } if (!match) { if (bits < 8) - *(cheat_manager_state.matches + idx) = *(cheat_manager_state.matches + idx) & + *(cheat_st->matches + idx) = *(cheat_st->matches + idx) & ((~(mask << (byte_part * bits))) & 0xFF); else - memset(cheat_manager_state.matches + idx, 0, bytes_per_item); - if (cheat_manager_state.num_matches > 0) - cheat_manager_state.num_matches--; + memset(cheat_st->matches + idx, 0, bytes_per_item); + if (cheat_st->num_matches > 0) + cheat_st->num_matches--; } } } @@ -1062,13 +1107,13 @@ static int cheat_manager_search(enum cheat_search_type search_type) offset = 0; - for (i = 0; i < cheat_manager_state.num_memory_buffers; i++) + for (i = 0; i < cheat_st->num_memory_buffers; i++) { - memcpy(cheat_manager_state.prev_memory_buf + offset, cheat_manager_state.memory_buf_list[i], cheat_manager_state.memory_size_list[i]); - offset += cheat_manager_state.memory_size_list[i]; + memcpy(cheat_st->prev_memory_buf + offset, cheat_st->memory_buf_list[i], cheat_st->memory_size_list[i]); + offset += cheat_st->memory_size_list[i]; } - snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEAT_SEARCH_FOUND_MATCHES), cheat_manager_state.num_matches); + snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEAT_SEARCH_FOUND_MATCHES), cheat_st->num_matches); msg[sizeof(msg) - 1] = 0; runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); @@ -1080,7 +1125,6 @@ static int cheat_manager_search(enum cheat_search_type search_type) return 0; } - int cheat_manager_search_exact(rarch_setting_t *setting, bool wraparound) { return cheat_manager_search(CHEAT_SEARCH_TYPE_EXACT); @@ -1129,61 +1173,64 @@ int cheat_manager_search_eqminus(rarch_setting_t *setting, bool wraparound) bool cheat_manager_add_new_code(unsigned int memory_search_size, unsigned int address, unsigned int address_mask, bool big_endian, unsigned int value) { - int new_size = cheat_manager_get_size() + 1; + cheat_manager_t *cheat_st = &cheat_manager_state; + int new_size = cheat_manager_get_size() + 1; if (!cheat_manager_realloc(new_size, CHEAT_HANDLER_TYPE_RETRO)) return false; - cheat_manager_state.cheats[cheat_manager_state.size - 1].address = address; - cheat_manager_state.cheats[cheat_manager_state.size - 1].address_mask = address_mask; - cheat_manager_state.cheats[cheat_manager_state.size - 1].memory_search_size = memory_search_size; - cheat_manager_state.cheats[cheat_manager_state.size - 1].value = value; - cheat_manager_state.cheats[cheat_manager_state.size - 1].big_endian = big_endian; + cheat_st->cheats[cheat_st->size - 1].address = address; + cheat_st->cheats[cheat_st->size - 1].address_mask = address_mask; + cheat_st->cheats[cheat_st->size - 1].memory_search_size = memory_search_size; + cheat_st->cheats[cheat_st->size - 1].value = value; + cheat_st->cheats[cheat_st->size - 1].big_endian = big_endian; return true; } + int cheat_manager_add_matches(const char *path, const char *label, unsigned type, size_t menuidx, size_t entry_idx) { char msg[100]; - bool refresh = false; - unsigned byte_part = 0; - unsigned int idx = 0; - unsigned int mask = 0; + bool refresh = false; + unsigned byte_part = 0; + unsigned int idx = 0; + unsigned int mask = 0; unsigned int bytes_per_item = 1; - unsigned int bits = 8; - unsigned int curr_val = 0; - unsigned int num_added = 0; - unsigned int offset = 0; - unsigned char *curr = cheat_manager_state.curr_memory_buf; + unsigned int bits = 8; + unsigned int curr_val = 0; + unsigned int num_added = 0; + unsigned int offset = 0; + cheat_manager_t *cheat_st = &cheat_manager_state; + unsigned char *curr = cheat_st->curr_memory_buf; - if (cheat_manager_state.num_matches + cheat_manager_state.size > 100) + if (cheat_st->num_matches + cheat_st->size > 100) { runloop_msg_queue_push(msg_hash_to_str(MSG_CHEAT_SEARCH_ADDED_MATCHES_TOO_MANY), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); return 0; } - cheat_manager_setup_search_meta(cheat_manager_state.search_bit_size, &bytes_per_item, &mask, &bits); + cheat_manager_setup_search_meta(cheat_st->search_bit_size, &bytes_per_item, &mask, &bits); - for (idx = 0; idx < cheat_manager_state.total_memory_size; idx = idx + bytes_per_item) + for (idx = 0; idx < cheat_st->total_memory_size; idx = idx + bytes_per_item) { offset = translate_address(idx, &curr); switch (bytes_per_item) { - case 2: - curr_val = cheat_manager_state.big_endian ? + case 2: + curr_val = cheat_st->big_endian ? (*(curr + idx - offset) * 256) + *(curr + idx + 1 - offset) : *(curr + idx - offset) + (*(curr + idx + 1 - offset) * 256); - break; - case 4: - curr_val = cheat_manager_state.big_endian ? + break; + case 4: + curr_val = cheat_st->big_endian ? (*(curr + idx - offset) * 256 * 256 * 256) + (*(curr + idx + 1 - offset) * 256 * 256) + (*(curr + idx + 2 - offset) * 256) + *(curr + idx + 3 - offset) : *(curr + idx - offset) + (*(curr + idx + 1 - offset) * 256) + (*(curr + idx + 2 - offset) * 256 * 256) + (*(curr + idx + 3 - offset) * 256 * 256 * 256); - break; - case 1: - default: - curr_val = *(curr - offset + idx); - break; + break; + case 1: + default: + curr_val = *(curr - offset + idx); + break; } for (byte_part = 0; byte_part < 8 / bits; byte_part++) { @@ -1191,11 +1238,11 @@ int cheat_manager_add_matches(const char *path, if (bits < 8) { - prev_match = *(cheat_manager_state.matches + idx) & (mask << (byte_part * bits)); + prev_match = *(cheat_st->matches + idx) & (mask << (byte_part * bits)); if (prev_match) { - if (!cheat_manager_add_new_code(cheat_manager_state.search_bit_size, idx, (mask << (byte_part * bits)), - cheat_manager_state.big_endian, curr_val)) + if (!cheat_manager_add_new_code(cheat_st->search_bit_size, idx, (mask << (byte_part * bits)), + cheat_st->big_endian, curr_val)) { runloop_msg_queue_push(msg_hash_to_str(MSG_CHEAT_SEARCH_ADDED_MATCHES_FAIL), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); return 0; @@ -1205,11 +1252,11 @@ int cheat_manager_add_matches(const char *path, } else { - prev_match = *(cheat_manager_state.matches + idx); + prev_match = *(cheat_st->matches + idx); if (prev_match) { - if (!cheat_manager_add_new_code(cheat_manager_state.search_bit_size, idx, 0xFF, - cheat_manager_state.big_endian, curr_val)) + if (!cheat_manager_add_new_code(cheat_st->search_bit_size, idx, 0xFF, + cheat_st->big_endian, curr_val)) { runloop_msg_queue_push(msg_hash_to_str(MSG_CHEAT_SEARCH_ADDED_MATCHES_FAIL), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); return 0; @@ -1221,7 +1268,7 @@ int cheat_manager_add_matches(const char *path, } } - snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEAT_SEARCH_ADDED_MATCHES_SUCCESS), cheat_manager_state.num_matches); + snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEAT_SEARCH_ADDED_MATCHES_SUCCESS), cheat_st->num_matches); msg[sizeof(msg) - 1] = 0; runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); @@ -1328,27 +1375,28 @@ void cheat_manager_apply_retro_cheats(void) unsigned int curr_val = 0; bool run_cheat = true; bool cheat_applied = false; + cheat_manager_t *cheat_st = &cheat_manager_state; - if ((!cheat_manager_state.cheats)) + if ((!cheat_st->cheats)) return; - for (i = 0; i < cheat_manager_state.size; i++) + for (i = 0; i < cheat_st->size; i++) { unsigned char *curr = NULL; bool set_value = false; unsigned int idx = 0; unsigned int value_to_set = 0; unsigned int repeat_iter = 0; - unsigned int address_mask = cheat_manager_state.cheats[i].address_mask; + unsigned int address_mask = cheat_st->cheats[i].address_mask; - if (cheat_manager_state.cheats[i].handler != CHEAT_HANDLER_TYPE_RETRO || !cheat_manager_state.cheats[i].state) + if (cheat_st->cheats[i].handler != CHEAT_HANDLER_TYPE_RETRO || !cheat_st->cheats[i].state) continue; - if (!cheat_manager_state.memory_initialized) + if (!cheat_st->memory_initialized) cheat_manager_initialize_memory(NULL, false); /* If we're still not initialized, something * must have gone wrong - just bail */ - if (!cheat_manager_state.memory_initialized) + if (!cheat_st->memory_initialized) return; if (!run_cheat) @@ -1356,22 +1404,22 @@ void cheat_manager_apply_retro_cheats(void) run_cheat = true; continue; } - cheat_manager_setup_search_meta(cheat_manager_state.cheats[i].memory_search_size, &bytes_per_item, &mask, &bits); + cheat_manager_setup_search_meta(cheat_st->cheats[i].memory_search_size, &bytes_per_item, &mask, &bits); - curr = cheat_manager_state.curr_memory_buf; - idx = cheat_manager_state.cheats[i].address; + curr = cheat_st->curr_memory_buf; + idx = cheat_st->cheats[i].address; offset = translate_address(idx, &curr); switch (bytes_per_item) { case 2: - curr_val = cheat_manager_state.big_endian ? + curr_val = cheat_st->big_endian ? (*(curr + idx - offset) * 256) + *(curr + idx + 1 - offset) : *(curr + idx - offset) + (*(curr + idx + 1 - offset) * 256); break; case 4: - curr_val = cheat_manager_state.big_endian ? + curr_val = cheat_st->big_endian ? (*(curr + idx - offset) * 256 * 256 * 256) + (*(curr + idx + 1 - offset) * 256 * 256) + (*(curr + idx + 2 - offset) * 256) + *(curr + idx + 3 - offset) : *(curr + idx - offset) + (*(curr + idx + 1 - offset) * 256) + (*(curr + idx + 2 - offset) * 256 * 256) + (*(curr + idx + 3 - offset) * 256 * 256 * 256); break; @@ -1381,36 +1429,36 @@ void cheat_manager_apply_retro_cheats(void) break; } - cheat_manager_apply_rumble(&cheat_manager_state.cheats[i], curr_val); + cheat_manager_apply_rumble(&cheat_st->cheats[i], curr_val); - switch (cheat_manager_state.cheats[i].cheat_type) + switch (cheat_st->cheats[i].cheat_type) { case CHEAT_TYPE_SET_TO_VALUE: set_value = true; - value_to_set = cheat_manager_state.cheats[i].value; + value_to_set = cheat_st->cheats[i].value; break; case CHEAT_TYPE_INCREASE_VALUE: set_value = true; - value_to_set = curr_val + cheat_manager_state.cheats[i].value; + value_to_set = curr_val + cheat_st->cheats[i].value; break; case CHEAT_TYPE_DECREASE_VALUE: set_value = true; - value_to_set = curr_val - cheat_manager_state.cheats[i].value; + value_to_set = curr_val - cheat_st->cheats[i].value; break; case CHEAT_TYPE_RUN_NEXT_IF_EQ: - if (!(curr_val == cheat_manager_state.cheats[i].value)) + if (!(curr_val == cheat_st->cheats[i].value)) run_cheat = false; break; case CHEAT_TYPE_RUN_NEXT_IF_NEQ: - if (!(curr_val != cheat_manager_state.cheats[i].value)) + if (!(curr_val != cheat_st->cheats[i].value)) run_cheat = false; break; case CHEAT_TYPE_RUN_NEXT_IF_LT: - if (!(cheat_manager_state.cheats[i].value < curr_val)) + if (!(cheat_st->cheats[i].value < curr_val)) run_cheat = false; break; case CHEAT_TYPE_RUN_NEXT_IF_GT: - if (!(cheat_manager_state.cheats[i].value > curr_val)) + if (!(cheat_st->cheats[i].value > curr_val)) run_cheat = false; break; } @@ -1418,12 +1466,12 @@ void cheat_manager_apply_retro_cheats(void) if (set_value) { cheat_applied = true; - for (repeat_iter = 1; repeat_iter <= cheat_manager_state.cheats[i].repeat_count; repeat_iter++) + for (repeat_iter = 1; repeat_iter <= cheat_st->cheats[i].repeat_count; repeat_iter++) { switch (bytes_per_item) { case 2: - if (cheat_manager_state.cheats[i].big_endian) + if (cheat_st->cheats[i].big_endian) { *(curr + idx - offset) = (value_to_set >> 8) & 0xFF; *(curr + idx + 1 - offset) = value_to_set & 0xFF; @@ -1435,7 +1483,7 @@ void cheat_manager_apply_retro_cheats(void) } break; case 4: - if (cheat_manager_state.cheats[i].big_endian) + if (cheat_st->cheats[i].big_endian) { *(curr + idx - offset) = (value_to_set >> 24) & 0xFF; *(curr + idx + 1 - offset) = (value_to_set >> 16) & 0xFF; @@ -1478,7 +1526,7 @@ void cheat_manager_apply_retro_cheats(void) break; } - value_to_set += cheat_manager_state.cheats[i].repeat_add_to_value; + value_to_set += cheat_st->cheats[i].repeat_add_to_value; if (mask != 0) value_to_set = value_to_set % mask; @@ -1486,7 +1534,7 @@ void cheat_manager_apply_retro_cheats(void) if (bits < 8) { unsigned int bit_iter; - for (bit_iter = 0; bit_iter < cheat_manager_state.cheats[i].repeat_add_to_address; bit_iter++) + for (bit_iter = 0; bit_iter < cheat_st->cheats[i].repeat_add_to_address; bit_iter++) { address_mask = (address_mask << mask) & 0xFF; @@ -1498,9 +1546,9 @@ void cheat_manager_apply_retro_cheats(void) } } else - idx += (cheat_manager_state.cheats[i].repeat_add_to_address * bytes_per_item); + idx += (cheat_st->cheats[i].repeat_add_to_address * bytes_per_item); - idx = idx % cheat_manager_state.total_memory_size; + idx = idx % cheat_st->total_memory_size; offset = translate_address(idx, &curr); } @@ -1509,7 +1557,10 @@ void cheat_manager_apply_retro_cheats(void) #ifdef HAVE_CHEEVOS if (cheat_applied) - cheat_manager_pause_cheevos(); + if ( rcheevos_hardcore_active + && rcheevos_loaded + && !rcheevos_hardcore_paused) + cheat_manager_pause_cheevos(); #endif } @@ -1519,50 +1570,51 @@ void cheat_manager_match_action(enum cheat_match_action_type match_action, unsig unsigned int byte_part; unsigned int idx; unsigned int start_idx; - unsigned int mask = 0; + unsigned int mask = 0; unsigned int bytes_per_item = 1; - unsigned int bits = 8; - unsigned int curr_val = 0; - unsigned int prev_val = 0; - unsigned int offset = 0; - unsigned char *curr = cheat_manager_state.curr_memory_buf; - unsigned char *prev = cheat_manager_state.prev_memory_buf; + unsigned int bits = 8; + unsigned int curr_val = 0; + unsigned int prev_val = 0; + unsigned int offset = 0; + cheat_manager_t *cheat_st = &cheat_manager_state; + unsigned char *curr = cheat_st->curr_memory_buf; + unsigned char *prev = cheat_st->prev_memory_buf; unsigned int curr_match_idx = 0; - if (target_match_idx > cheat_manager_state.num_matches - 1) + if (target_match_idx > cheat_st->num_matches - 1) return; - if (cheat_manager_state.num_memory_buffers == 0) + if (cheat_st->num_memory_buffers == 0) return; - cheat_manager_setup_search_meta(cheat_manager_state.search_bit_size, &bytes_per_item, &mask, &bits); + cheat_manager_setup_search_meta(cheat_st->search_bit_size, &bytes_per_item, &mask, &bits); if (match_action == CHEAT_MATCH_ACTION_TYPE_BROWSE) start_idx = *address; else start_idx = 0; - for (idx = start_idx; idx < cheat_manager_state.total_memory_size; idx = idx + bytes_per_item) + for (idx = start_idx; idx < cheat_st->total_memory_size; idx = idx + bytes_per_item) { offset = translate_address(idx, &curr); switch (bytes_per_item) { case 2: - curr_val = cheat_manager_state.big_endian ? + curr_val = cheat_st->big_endian ? (*(curr + idx - offset) * 256) + *(curr + idx + 1 - offset) : *(curr + idx - offset) + (*(curr + idx + 1 - offset) * 256); if (prev) - prev_val = cheat_manager_state.big_endian ? + prev_val = cheat_st->big_endian ? (*(prev + idx) * 256) + *(prev + idx + 1) : *(prev + idx) + (*(prev + idx + 1) * 256); break; case 4: - curr_val = cheat_manager_state.big_endian ? + curr_val = cheat_st->big_endian ? (*(curr + idx - offset) * 256 * 256 * 256) + (*(curr + idx + 1 - offset) * 256 * 256) + (*(curr + idx + 2 - offset) * 256) + *(curr + idx + 3 - offset) : *(curr + idx - offset) + (*(curr + idx + 1 - offset) * 256) + (*(curr + idx + 2 - offset) * 256 * 256) + (*(curr + idx + 3 - offset) * 256 * 256 * 256); if (prev) - prev_val = cheat_manager_state.big_endian ? + prev_val = cheat_st->big_endian ? (*(prev + idx) * 256 * 256 * 256) + (*(prev + idx + 1) * 256 * 256) + (*(prev + idx + 2) * 256) + *(prev + idx + 3) : *(prev + idx) + (*(prev + idx + 1) * 256) + (*(prev + idx + 2) * 256 * 256) + (*(prev + idx + 3) * 256 * 256 * 256); break; @@ -1590,7 +1642,7 @@ void cheat_manager_match_action(enum cheat_match_action_type match_action, unsig if (bits < 8) { - prev_match = *(cheat_manager_state.matches + idx) & (mask << (byte_part * bits)); + prev_match = *(cheat_st->matches + idx) & (mask << (byte_part * bits)); if (prev_match) { if (target_match_idx == curr_match_idx) @@ -1606,20 +1658,20 @@ void cheat_manager_match_action(enum cheat_match_action_type match_action, unsig *prev_value = prev_val; return; case CHEAT_MATCH_ACTION_TYPE_COPY: - if (!cheat_manager_add_new_code(cheat_manager_state.search_bit_size, idx, (mask << (byte_part * bits)), - cheat_manager_state.big_endian, curr_val)) + if (!cheat_manager_add_new_code(cheat_st->search_bit_size, idx, (mask << (byte_part * bits)), + cheat_st->big_endian, curr_val)) runloop_msg_queue_push(msg_hash_to_str(MSG_CHEAT_SEARCH_ADD_MATCH_FAIL), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); else runloop_msg_queue_push(msg_hash_to_str(MSG_CHEAT_SEARCH_ADD_MATCH_SUCCESS), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); return; case CHEAT_MATCH_ACTION_TYPE_DELETE: if (bits < 8) - *(cheat_manager_state.matches + idx) = *(cheat_manager_state.matches + idx) & + *(cheat_st->matches + idx) = *(cheat_st->matches + idx) & ((~(mask << (byte_part * bits))) & 0xFF); else - memset(cheat_manager_state.matches + idx, 0, bytes_per_item); - if (cheat_manager_state.num_matches > 0) - cheat_manager_state.num_matches--; + memset(cheat_st->matches + idx, 0, bytes_per_item); + if (cheat_st->num_matches > 0) + cheat_st->num_matches--; runloop_msg_queue_push(msg_hash_to_str(MSG_CHEAT_SEARCH_DELETE_MATCH_SUCCESS), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); return; } @@ -1630,7 +1682,7 @@ void cheat_manager_match_action(enum cheat_match_action_type match_action, unsig } else { - prev_match = *(cheat_manager_state.matches + idx); + prev_match = *(cheat_st->matches + idx); if (prev_match) { if (target_match_idx == curr_match_idx) @@ -1646,20 +1698,20 @@ void cheat_manager_match_action(enum cheat_match_action_type match_action, unsig *prev_value = prev_val; return; case CHEAT_MATCH_ACTION_TYPE_COPY: - if (!cheat_manager_add_new_code(cheat_manager_state.search_bit_size, idx, 0xFF, - cheat_manager_state.big_endian, curr_val)) + if (!cheat_manager_add_new_code(cheat_st->search_bit_size, idx, 0xFF, + cheat_st->big_endian, curr_val)) runloop_msg_queue_push(msg_hash_to_str(MSG_CHEAT_SEARCH_ADD_MATCH_FAIL), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); else runloop_msg_queue_push(msg_hash_to_str(MSG_CHEAT_SEARCH_ADD_MATCH_SUCCESS), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); return; case CHEAT_MATCH_ACTION_TYPE_DELETE: if (bits < 8) - *(cheat_manager_state.matches + idx) = *(cheat_manager_state.matches + idx) & + *(cheat_st->matches + idx) = *(cheat_st->matches + idx) & ((~(mask << (byte_part * bits))) & 0xFF); else - memset(cheat_manager_state.matches + idx, 0, bytes_per_item); - if (cheat_manager_state.num_matches > 0) - cheat_manager_state.num_matches--; + memset(cheat_st->matches + idx, 0, bytes_per_item); + if (cheat_st->num_matches > 0) + cheat_st->num_matches--; runloop_msg_queue_push(msg_hash_to_str(MSG_CHEAT_SEARCH_DELETE_MATCH_SUCCESS), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); return; } @@ -1670,20 +1722,23 @@ void cheat_manager_match_action(enum cheat_match_action_type match_action, unsig } } } - } + int cheat_manager_copy_match(rarch_setting_t *setting, bool wraparound) { + cheat_manager_t *cheat_st = &cheat_manager_state; cheat_manager_match_action(CHEAT_MATCH_ACTION_TYPE_COPY, - cheat_manager_state.match_idx, NULL, NULL, NULL, NULL); + cheat_st->match_idx, NULL, NULL, NULL, NULL); return 0; } int cheat_manager_delete_match(rarch_setting_t *setting, bool wraparound) { - bool refresh = false; + bool refresh = false; + cheat_manager_t *cheat_st = &cheat_manager_state; + cheat_manager_match_action(CHEAT_MATCH_ACTION_TYPE_DELETE, - cheat_manager_state.match_idx, NULL, NULL, NULL, NULL); + cheat_st->match_idx, NULL, NULL, NULL, NULL); #ifdef HAVE_MENU menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL); From 1c4cb37e613ef31341ca0f7a01eb523d970cad31 Mon Sep 17 00:00:00 2001 From: im4potato Date: Thu, 21 May 2020 16:26:06 -0700 Subject: [PATCH 178/192] Unify timedate ENUMs and cleanup --- intl/msg_hash_chs.h | 70 +++++------ intl/msg_hash_el.h | 68 +++++------ intl/msg_hash_es.h | 159 ++++++------------------ intl/msg_hash_fr.h | 158 ++++++------------------ intl/msg_hash_it.h | 70 +++++------ intl/msg_hash_ja.h | 68 +++++------ intl/msg_hash_ko.h | 70 +++++------ intl/msg_hash_pt_br.h | 158 ++++++------------------ intl/msg_hash_tr.h | 68 +++++------ intl/msg_hash_us.h | 158 ++++++------------------ menu/menu_defines.h | 20 ++-- menu/menu_driver.c | 78 ++++++------ menu/menu_setting.c | 132 ++++++++++---------- msg_hash.h | 75 ++++-------- runtime_file.c | 272 +++++++++++++++++++++--------------------- runtime_file.h | 16 +-- 16 files changed, 632 insertions(+), 1008 deletions(-) diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index ac7b7503ce..767d306283 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -2648,107 +2648,107 @@ MSG_HASH( "更改菜单中当前日期/时间显示格式。" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS, "YYYY-MM-DD HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM, "YYYY-MM-DD HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD, "YYYY-MM-DD" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YM, "YYYY-MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS, "MM-DD-YYYY HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM, "MM-DD-YYYY HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM, "MM-DD HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY, "MM-DD-YYYY" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD, "MM-DD" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS, - "DD/MM/YYYY HH:MM:SS" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS, + "DD-MM-YYYY HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM, - "DD/MM/YYYY HH:MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM, + "DD-MM-YYYY HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM, - "DD/MM HH:MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM, + "DD-MM HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY, - "DD/MM/YYYY" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY, + "DD-MM-YYYY" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM, - "DD/MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM, + "DD-MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS, "HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM, "HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS_AMPM, "YYYY-MM-DD HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM_AMPM, "YYYY-MM-DD HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS_AMPM, "MM-DD-YYYY HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM_AMPM, "MM-DD-YYYY HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM_AM_PM, - "MM/DD HH: (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM_AMPM, + "MM-DD HH: (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS_AM_PM, - "DD/MM/YYYY HH:MM:SS (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS_AMPM, + "DD-MM-YYYY HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM_AM_PM, - "DD/MM/YYYY HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM_AMPM, + "DD-MM-YYYY HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM_AM_PM, - "DD/MM HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM_AMPM, + "DD-MM HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS_AMPM, "HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM_AMPM, "HH:MM (AM/PM)" ) MSG_HASH( diff --git a/intl/msg_hash_el.h b/intl/msg_hash_el.h index d60800a2fa..5264a5f602 100644 --- a/intl/msg_hash_el.h +++ b/intl/msg_hash_el.h @@ -2383,107 +2383,107 @@ MSG_HASH( "Αλλάζει το στυλ της τρέχουσας ημερομηνίας ή και ώρας που φαίνεται μέσα στο μενού." ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS, "ΧΧΧΧ-ΜΜ-ΗΗ ΩΩ:ΛΛ:ΔΔ" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM, "ΧΧΧΧ-ΜΜ-ΗΗ ΩΩ:ΛΛ" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD, "ΧΧΧΧ-ΜΜ-ΗΗ" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YM, "ΧΧΧΧ-ΜΜ" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS, "ΜΜ-ΗΗ-ΧΧΧΧ ΩΩ:ΛΛ:ΔΔ" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM, "ΜΜ-ΗΗ-ΧΧΧΧ ΩΩ:ΛΛ" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM, "ΜΜ-ΗΗ ΩΩ:ΛΛ" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY, "ΜΜ-ΗΗ-ΧΧΧΧ" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD, "ΜΜ-ΗΗ" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS, - "HH/MM/ΧΧΧΧ ΩΩ:ΛΛ:ΔΔ" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS, + "HH-MM-ΧΧΧΧ ΩΩ:ΛΛ:ΔΔ" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM, - "HH/MM/ΧΧΧΧ ΩΩ:ΛΛ" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM, + "HH-MM-ΧΧΧΧ ΩΩ:ΛΛ" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM, - "HH/MM ΩΩ:ΛΛ" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM, + "HH-MM ΩΩ:ΛΛ" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY, - "HH/MM/ΧΧΧΧ" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY, + "HH-MM/ΧΧΧΧ" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM, - "HH/MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM, + "HH-MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS, "ΩΩ:ΛΛ:ΔΔ" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM, "ΩΩ:ΛΛ" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS_AMPM, "ΧΧΧΧ-ΜΜ-ΗΗ ΩΩ:ΛΛ:ΔΔ (ΠΜ/ΜΜ)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM_AMPM, "ΧΧΧΧ-ΜΜ-ΗΗ ΩΩ:ΛΛ (ΠΜ/ΜΜ)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS_AMPM, "ΜΜ-ΗΗ-ΧΧΧΧ ΩΩ:ΛΛ:ΔΔ (ΠΜ/ΜΜ)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM_AMPM, "ΜΜ-ΗΗ-ΧΧΧΧ ΩΩ:ΛΛ (ΠΜ/ΜΜ)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM_AMPM, "ΜΜ-ΗΗ ΩΩ:ΛΛ (ΠΜ/ΜΜ)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS_AM_PM, - "HH/MM/XXXX ΩΩ:ΛΛ:ΔΔ (ΠΜ/ΜΜ)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS_AMPM, + "HH-MM-XXXX ΩΩ:ΛΛ:ΔΔ (ΠΜ/ΜΜ)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM_AM_PM, - "HH/MM/XXXX ΩΩ:ΛΛ (ΠΜ/ΜΜ)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM_AMPM, + "HH-MM-XXXX ΩΩ:ΛΛ (ΠΜ/ΜΜ)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM_AM_PM, - "HH/MM ΩΩ:ΛΛ (ΠΜ/ΜΜ)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM_AMPM, + "HH-MM ΩΩ:ΛΛ (ΠΜ/ΜΜ)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS_AMPM, "ΩΩ:ΛΛ:ΔΔ (ΠΜ/ΜΜ)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM_AMPM, "ΩΩ:ΛΛ (ΠΜ/ΜΜ)" ) MSG_HASH( diff --git a/intl/msg_hash_es.h b/intl/msg_hash_es.h index 800521a92f..f837d2874f 100644 --- a/intl/msg_hash_es.h +++ b/intl/msg_hash_es.h @@ -3698,107 +3698,107 @@ MSG_HASH( "Cambia la forma en que se muestra la fecha y hora." ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS, "AAAA-MM-DD HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM, "AAAA-MM-DD HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD, "AAAA-MM-DD" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YM, "AAAA-MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS, "MM-DD-AAAA HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM, "MM-DD-AAAA HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM, "MM-DD HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY, "MM-DD-AAAA" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD, "MM-DD" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS, - "DD/MM/AAAA HH:MM:SS" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS, + "DD-MM-AAAA HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM, - "DD/MM/AAAA HH:MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM, + "DD-MM-AAAA HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM, - "DD/MM HH:MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM, + "DD-MM HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY, - "DD/MM/AAAA" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY, + "DD-MM-AAAA" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM, - "DD/MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM, + "DD-MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS, "HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM, "HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS_AMPM, "AAAA-MM-DD HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM_AMPM, "AAAA-MM-DD HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS_AMPM, "MM-DD-AAAA HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM_AMPM, "MM-DD-AAAA HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM_AM_PM, - "MM/DD HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM_AMPM, + "MM-DD HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS_AM_PM, - "DD/MM/AAAA HH:MM:SS (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS_AMPM, + "DD-MM-AAAA HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM_AM_PM, - "DD/MM/AAAA HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM_AMPM, + "DD-MM-AAAA HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM_AM_PM, - "DD/MM HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM_AMPM, + "DD-MM HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS_AMPM, "HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM_AMPM, "HH:MM (AM/PM)" ) MSG_HASH( @@ -9511,94 +9511,6 @@ MSG_HASH( MENU_ENUM_SUBLABEL_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE, "Selecciona el formato de fecha y hora para la información de la última partida jugada al mostrar el registro de ejecución. Nota: Las opciones AM/PM afectarán levemente al rendimiento en algunas plataformas." ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HMS, - "AAAA/MM/DD - HH:MM:SS" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HM, - "AAAA/MM/DD - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD, - "AAAA/MM/DD" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YM, - "AAAA/MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HMS, - "MM/DD/AAAA - HH:MM:SS" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HM, - "MM/DD/AAAA - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MD_HM, - "MM/DD - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY, - "MM/DD/AAAA" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MD, - "MM/DD" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HMS, - "DD/MM/AAAA - HH:MM:SS" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HM, - "DD/MM/AAAA - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMM_HM, - "DD/MM - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY, - "DD/MM/AAAA" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMM, - "DD/MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HMS_AM_PM, - "AAAA/MM/DD - HH:MM:SS (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HM_AM_PM, - "AAAA/MM/DD - HH:MM (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HMS_AM_PM, - "MM/DD/AAAA - HH:MM:SS (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HM_AM_PM, - "MM/DD/AAAA - HH:MM (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MD_HM_AM_PM, - "MM/DD - HH:MM (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HMS_AM_PM, - "DD/MM/AAAA - HH:MM:SS (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HM_AM_PM, - "DD/MM/AAAA - HH:MM (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMM_HM_AM_PM, - "DD/MM - HH:MM (AM/PM)" - ) MSG_HASH( MENU_ENUM_LABEL_VALUE_PLAYLIST_FUZZY_ARCHIVE_MATCH, "Búsqueda difusa de archivos" @@ -10581,4 +10493,3 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_START_GONG, "Iniciar gong" ) - diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index 2e42719a10..f7d0e32030 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -6910,197 +6910,109 @@ MSG_HASH( "Tardive" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS, "AAAA-MM-JJ HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM, "AAAA-MM-JJ HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD, "AAAA-MM-JJ" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YM, "AAAA-MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS, "MM-JJ-AAAA HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM, "MM-JJ-AAAA HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM, "MM-JJ HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY, "MM-JJ-AAAA" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD, "MM-JJ" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS, - "JJ/MM/AAAA HH:MM:SS" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS, + "JJ-MM-AAAA HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM, - "JJ/MM/AAAA HH:MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM, + "JJ-MM-AAAA HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM, - "JJ/MM HH:MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM, + "JJ-MM HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY, - "JJ/MM/AAAA" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY, + "JJ-MM/AAAA" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM, - "JJ/MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM, + "JJ-MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS, "HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM, "HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS_AMPM, "AAAA-MM-JJ HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM_AMPM, "AAAA-MM-JJ HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS_AMPM, "MM-JJ-AAAA HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM_AMPM, "MM-JJ-AAAA HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM_AM_PM, - "MM/JJ HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM_AMPM, + "MM-JJ HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS_AM_PM, - "JJ/MM/AAAA HH:MM:SS (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS_AMPM, + "JJ-MM-AAAA HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM_AM_PM, - "JJ/MM/AAAA HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM_AMPM, + "JJ-MM-AAAA HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM_AM_PM, - "JJ/MM HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM_AMPM, + "JJ-MM HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS_AMPM, "HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM_AMPM, "HH:MM (AM/PM)" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HMS, - "AAAA/MM/JJ - HH:MM:SS" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HM, - "AAAA/MM/JJ - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD, - "AAAA/MM/JJ" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YM, - "AAAA/MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HMS, - "MM/JJ/AAAA - HH:MM:SS" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HM, - "MM/JJ/AAAA - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MD_HM, - "MM/JJ - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY, - "MM/JJ/AAAA" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MD, - "MM/JJ" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HMS, - "JJ/MM/AAAA - HH:MM:SS" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HM, - "JJ/MM/AAAA - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMM_HM, - "JJ/MM - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY, - "JJ/MM/AAAA" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMM, - "JJ/MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HMS_AM_PM, - "AAAA/MM/JJ - HH:MM:SS (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HM_AM_PM, - "AAAA/MM/JJ - HH:MM (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HMS_AM_PM, - "MM/JJ/AAAA - HH:MM:SS (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HM_AM_PM, - "MM/JJ/AAAA - HH:MM (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MD_HM_AM_PM, - "MM/JJ - HH:MM (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HMS_AM_PM, - "JJ/MM/AAAA - HH:MM:SS (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HM_AM_PM, - "JJ/MM/AAAA - HH:MM (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMM_HM_AM_PM, - "JJ/MM - HH:MM (AM/PM)" - ) /* RGUI: Settings > User Interface > Appearance */ diff --git a/intl/msg_hash_it.h b/intl/msg_hash_it.h index 1b26471901..1c002004e9 100644 --- a/intl/msg_hash_it.h +++ b/intl/msg_hash_it.h @@ -2622,107 +2622,107 @@ MSG_HASH( "Modifica il modo in cui vengono visualizzate data e ora nel menu" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS, "AAAA-MM-GG HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM, "AAAA-MM-GG HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD, "AAAA-MM-GG" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YM, "AAAA-MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS, "MM-GG-AAAA HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM, "MM-GG-AAAA HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM, "MM-GG HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY, "MM-GG-AAAA" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD, "MM-GG" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS, - "GG/MM/AAAA HH:MM:SS" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS, + "GG-MM-AAAA HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM, - "GG/MM/AAAA HH:MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM, + "GG-MM-AAAA HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM, - "GG/MM HH:MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM, + "GG-MM HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY, - "GG/MM/AAAA" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY, + "GG-MM-AAAA" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM, - "GG/MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM, + "GG-MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS, "HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM, "HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS_AMPM, "AAAA-MM-GG HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM_AMPM, "AAAA-MM-GG HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS_AMPM, "MM-GG-AAAA HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM_AMPM, "MM-GG-AAAA HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM_AM_PM, - "MM/GG HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM_AMPM, + "MM-GG HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS_AM_PM, - "GG/MM/AAAA HH:MM:SS (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS_AMPM, + "GG-MM-AAAA HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM_AM_PM, - "GG/MM/AAAA HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM_AMPM, + "GG-MM-AAAA HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM_AM_PM, - "GG/MM HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM_AMPM, + "GG-MM HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS_AMPM, "HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM_AMPM, "HH:MM (AM/PM)" ) MSG_HASH( diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index f503b52baf..be03117643 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -3124,107 +3124,107 @@ MSG_HASH( "メニュー内での日付/時刻の表示形式を変更します。" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS, "年-月-日 時:分:秒" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM, "年-月-日 時:分" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD, "年-月-日" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YM, "年-月" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS, "月-日-年 時:分:秒" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM, "月-日-年 時:分" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM, "月-日 時:分" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY, "月-日-年" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD, "月-日" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS, - "日/月/年 時:分:秒" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS, + "日-月-年 時:分:秒" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM, - "日/月/年 時:分" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM, + "日-月-年 時:分" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM, - "日/月 時:分" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM, + "日-月 時:分" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY, - "日/月/年" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY, + "日-月-年" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM, - "日/月" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM, + "日-月" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS, "時:分:秒" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM, "時:分" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS_AMPM, "年-月-日 時:分:秒 (午前/午後)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM_AMPM, "年-月-日 時:分 (午前/午後)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS_AMPM, "月-日-年 時:分:秒 (午前/午後)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM_AMPM, "月-日-年 時:分 (午前/午後)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM_AMPM, "月-日 時:分 (午前/午後)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS_AM_PM, - "日/月/年 時:分:秒 (午前/午後)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS_AMPM, + "日-月-年 時:分:秒 (午前/午後)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM_AM_PM, - "日/月/年 時:分 (午前/午後)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM_AMPM, + "日-月-年 時:分 (午前/午後)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM_AM_PM, - "日/月 時:分 (午前/午後)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM_AMPM, + "日-月 時:分 (午前/午後)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS_AMPM, "時:分:秒 (午前/午後)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM_AMPM, "時:分 (午前/午後)" ) MSG_HASH( diff --git a/intl/msg_hash_ko.h b/intl/msg_hash_ko.h index 262b7dde85..3f6702adde 100644 --- a/intl/msg_hash_ko.h +++ b/intl/msg_hash_ko.h @@ -3578,107 +3578,107 @@ MSG_HASH( "메뉴에 표시될 시간/날짜 스타일을 변경합니다." ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS, "YYYY-MM-DD HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM, "YYYY-MM-DD HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD, "YYYY-MM-DD" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YM, "YYYY-MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS, "MM-DD-YYYY HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM, "MM-DD-YYYY HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM, "MM-DD HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY, "MM-DD-YYYY" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD, "MM-DD" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS, - "DD/MM/YYYY HH:MM:SS" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS, + "DD-MM-YYYY HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM, - "DD/MM/YYYY HH:MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM, + "DD-MM-YYYY HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM, - "DD/MM HH:MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM, + "DD-MM HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY, - "DD/MM/YYYY" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY, + "DD-MM-YYYY" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM, - "DD/MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM, + "DD-MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS, "HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM, "HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS_AMPM, "YYYY-MM-DD HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM_AMPM, "YYYY-MM-DD HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS_AMPM, "MM-DD-YYYY HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM_AMPM, "MM-DD-YYYY HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM_AM_PM, - "MM/DD HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM_AMPM, + "MM-DD HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS_AM_PM, - "DD/MM/YYYY HH:MM:SS (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS_AMPM, + "DD-MM-YYYY HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM_AM_PM, - "DD/MM/YYYY HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM_AMPM, + "DD-MM-YYYY HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM_AM_PM, - "DD/MM HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM_AMPM, + "DD-MM HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS_AMPM, "HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM_AMPM, "HH:MM (AM/PM)" ) MSG_HASH( diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index 1687d1b895..c893cd5be2 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -3718,107 +3718,107 @@ MSG_HASH( "Altera o estilo da data atual ou como a hora é mostrada dentro do menu." ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS, "AAAA-MM-DD HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM, "AAAA-MM-DD HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD, "AAAA-MM-DD" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YM, "AAAA-MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS, "MM-DD-AAAA HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM, "MM-DD-AAAA HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM, "MM-DD HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY, "MM-DD-AAAA" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD, "MM-DD" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS, - "DD/MM/AAAA HH:MM:SS" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS, + "DD-MM-AAAA HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM, - "DD/MM/AAAA HH:MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM, + "DD-MM-AAAA HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM, - "DD/MM HH:MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM, + "DD-MM HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY, - "DD/MM/AAAA" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY, + "DD-MM-AAAA" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM, - "DD/MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM, + "DD-MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS, "HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM, "HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS_AMPM, "AAAA-MM-DD HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM_AMPM, "AAAA-MM-DD HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS_AMPM, "MM-DD-AAAA HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM_AMPM, "MM-DD-AAAA HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM_AM_PM, - "MM/DD HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM_AMPM, + "MM-DD HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS_AM_PM, - "DD/MM/AAAA HH:MM:SS (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS_AMPM, + "DD-MM-AAAA HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM_AM_PM, - "DD/MM/AAAA HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM_AMPM, + "DD-MM-AAAA HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM_AM_PM, - "DD/MM HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM_AMPM, + "DD-MM HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS_AMPM, "HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM_AMPM, "HH:MM (AM/PM)" ) MSG_HASH( @@ -9586,94 +9586,6 @@ MSG_HASH( MENU_ENUM_SUBLABEL_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE, "Seleciona o formato de data e hora da último partida, mostrando o registro de execução. NOTA: As opções AM/PM afetam ligeiramente o desempenho em algumas plataformas." ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HMS, - "AAAA/MM/DD - HH:MM:SS" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HM, - "AAAA/MM/DD - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD, - "AAAA/MM/DD" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YM, - "AAAA/MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HMS, - "MM/DD/AAAA - HH:MM:SS" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HM, - "MM/DD/AAAA - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MD_HM, - "MM/DD - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY, - "MM/DD/AAAA" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MD, - "MM/DD" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HMS, - "DD/MM/AAAA - HH:MM:SS" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HM, - "DD/MM/AAAA - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMM_HM, - "DD/MM - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY, - "DD/MM/AAAA" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMM, - "DD/MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HMS_AM_PM, - "AAAA/MM/DD - HH:MM:SS (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HM_AM_PM, - "AAAA/MM/DD - HH:MM (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HMS_AM_PM, - "MM/DD/AAAA - HH:MM:SS (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HM_AM_PM, - "MM/DD/AAAA - HH:MM (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MD_HM_AM_PM, - "MM/DD - HH:MM (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HMS_AM_PM, - "DD/MM/AAAA - HH:MM:SS (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HM_AM_PM, - "DD/MM/AAAA - HH:MM (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMM_HM_AM_PM, - "DD/MM - HH:MM (AM/PM)" - ) MSG_HASH( MENU_ENUM_LABEL_VALUE_PLAYLIST_FUZZY_ARCHIVE_MATCH, "Correspondência de arquivos difusos" diff --git a/intl/msg_hash_tr.h b/intl/msg_hash_tr.h index 5f6dcb3a33..488390c06e 100644 --- a/intl/msg_hash_tr.h +++ b/intl/msg_hash_tr.h @@ -3160,107 +3160,107 @@ MSG_HASH( "Menü içindeki tarih ve/veya saatin stilini değiştir." ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS, "YYYY-AA-GG SS:DD:SN" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM, "YYYY-AA-GG SS:DD" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD, "YYYY-AA-GG" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YM, "YYYY-AA" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS, "AA-GG-YYYY SS:DD:SN" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM, "AA-GG-YYYY SS:DD" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM, "AA-GG SS:DD" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY, "AA-GG-YYYY" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD, "AA-GG" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS, - "GG/AA/YYYY SS:DD:SN" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS, + "GG-AA-YYYY SS:DD:SN" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM, - "GG/AA/YYYY SS:DD" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM, + "GG-AA-YYYY SS:DD" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM, - "GG/AA SS:DD" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM, + "GG-AA SS:DD" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY, - "GG/AA/YYYY" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY, + "GG-AA-YYYY" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM, - "GG/AA" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM, + "GG-AA" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS, "SS:DD:SN" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM, "SS:DD" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS_AMPM, "YYYY-AA-GG SS:DD:SN (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM_AMPM, "YYYY-AA-GG SS:DD (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS_AMPM, "AA-GG-YYYY SS:DD:SN (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM_AMPM, "AA-GG-YYYY SS:DD (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM_AMPM, "AA-GG SS:DD (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS_AM_PM, - "GG/AA/YYYY SS:DD:SN (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS_AMPM, + "GG-AA-YYYY SS:DD:SN (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM_AM_PM, - "GG/AA/YYYY SS:DD (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM_AMPM, + "GG-AA-YYYY SS:DD (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM_AM_PM, - "GG/AA SS:DD (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM_AMPM, + "GG-AA SS:DD (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS_AMPM, "SS:DD:SN (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM_AMPM, "SS:DD (AM/PM)" ) MSG_HASH( diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 39294e8038..c4d394aa38 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -6926,197 +6926,109 @@ MSG_HASH( "Late" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS, "YYYY-MM-DD HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM, "YYYY-MM-DD HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD, "YYYY-MM-DD" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YM, "YYYY-MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS, "MM-DD-YYYY HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM, "MM-DD-YYYY HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM, "MM-DD HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY, "MM-DD-YYYY" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD, "MM-DD" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS, - "DD/MM/YYYY HH:MM:SS" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS, + "DD-MM-YYYY HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM, - "DD/MM/YYYY HH:MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM, + "DD-MM-YYYY HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM, - "DD/MM HH:MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM, + "DD-MM HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY, - "DD/MM/YYYY" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY, + "DD-MM-YYYY" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM, - "DD/MM" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM, + "DD-MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS, "HH:MM:SS" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM, "HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS_AMPM, "YYYY-MM-DD HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM_AMPM, "YYYY-MM-DD HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS_AMPM, "MM-DD-YYYY HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM_AMPM, "MM-DD-YYYY HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM_AM_PM, - "MM/DD HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM_AMPM, + "MM-DD HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS_AM_PM, - "DD/MM/YYYY HH:MM:SS (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS_AMPM, + "DD-MM-YYYY HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM_AM_PM, - "DD/MM/YYYY HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM_AMPM, + "DD-MM-YYYY HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM_AM_PM, - "DD/MM HH:MM (AM/PM)" + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM_AMPM, + "DD-MM HH:MM (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS_AMPM, "HH:MM:SS (AM/PM)" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM_AMPM, "HH:MM (AM/PM)" ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HMS, - "YYYY/MM/DD - HH:MM:SS" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HM, - "YYYY/MM/DD - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD, - "YYYY/MM/DD" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YM, - "YYYY/MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HMS, - "MM/DD/YYYY - HH:MM:SS" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HM, - "MM/DD/YYYY - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MD_HM, - "MM/DD - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY, - "MM/DD/YYYY" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MD, - "MM/DD" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HMS, - "DD/MM/YYYY - HH:MM:SS" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HM, - "DD/MM/YYYY - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMM_HM, - "DD/MM - HH:MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY, - "DD/MM/YYYY" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMM, - "DD/MM" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HMS_AM_PM, - "YYYY/MM/DD - HH:MM:SS (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HM_AM_PM, - "YYYY/MM/DD - HH:MM (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HMS_AM_PM, - "MM/DD/YYYY - HH:MM:SS (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HM_AM_PM, - "MM/DD/YYYY - HH:MM (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MD_HM_AM_PM, - "MM/DD - HH:MM (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HMS_AM_PM, - "DD/MM/YYYY - HH:MM:SS (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HM_AM_PM, - "DD/MM/YYYY - HH:MM (AM/PM)" - ) -MSG_HASH( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMM_HM_AM_PM, - "DD/MM - HH:MM (AM/PM)" - ) /* RGUI: Settings > User Interface > Appearance */ diff --git a/menu/menu_defines.h b/menu/menu_defines.h index 77972fb22d..cb24aed99e 100644 --- a/menu/menu_defines.h +++ b/menu/menu_defines.h @@ -103,16 +103,16 @@ enum menu_timedate_style_type MENU_TIMEDATE_STYLE_DDMM, MENU_TIMEDATE_STYLE_HMS, MENU_TIMEDATE_STYLE_HM, - MENU_TIMEDATE_STYLE_YMD_HMS_AM_PM, - MENU_TIMEDATE_STYLE_YMD_HM_AM_PM, - MENU_TIMEDATE_STYLE_MDYYYY_HMS_AM_PM, - MENU_TIMEDATE_STYLE_MDYYYY_HM_AM_PM, - MENU_TIMEDATE_STYLE_MD_HM_AM_PM, - MENU_TIMEDATE_STYLE_DDMMYYYY_HMS_AM_PM, - MENU_TIMEDATE_STYLE_DDMMYYYY_HM_AM_PM, - MENU_TIMEDATE_STYLE_DDMM_HM_AM_PM, - MENU_TIMEDATE_STYLE_HMS_AM_PM, - MENU_TIMEDATE_STYLE_HM_AM_PM, + MENU_TIMEDATE_STYLE_YMD_HMS_AMPM, + MENU_TIMEDATE_STYLE_YMD_HM_AMPM, + MENU_TIMEDATE_STYLE_MDYYYY_HMS_AMPM, + MENU_TIMEDATE_STYLE_MDYYYY_HM_AMPM, + MENU_TIMEDATE_STYLE_MD_HM_AMPM, + MENU_TIMEDATE_STYLE_DDMMYYYY_HMS_AMPM, + MENU_TIMEDATE_STYLE_DDMMYYYY_HM_AMPM, + MENU_TIMEDATE_STYLE_DDMM_HM_AMPM, + MENU_TIMEDATE_STYLE_HMS_AMPM, + MENU_TIMEDATE_STYLE_HM_AMPM, MENU_TIMEDATE_STYLE_LAST }; diff --git a/menu/menu_driver.c b/menu/menu_driver.c index f6083484ed..88c840e20c 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -195,7 +195,7 @@ static void get_current_menu_sublabel(char* retstr, size_t max) menu_entry_init(&entry); menu_entry_get(&entry, 0, menu_navigation_get_selection(), NULL, true); - + menu_entry_get_sublabel(&entry, &entry_sublabel); strlcpy(retstr, entry_sublabel, max); } @@ -217,7 +217,7 @@ static int generic_menu_iterate(void *data, retro_time_t current_time) { #ifdef HAVE_ACCESSIBILITY - static enum action_iterate_type + static enum action_iterate_type last_iterate_type = ITERATE_TYPE_DEFAULT; #endif enum action_iterate_type iterate_type; @@ -260,7 +260,7 @@ static int generic_menu_iterate(void *data, { bool pop_stack = false; - if ( ret == 1 || + if ( ret == 1 || action == MENU_ACTION_OK || action == MENU_ACTION_CANCEL ) @@ -541,8 +541,8 @@ int generic_menu_entry_action( } #ifdef HAVE_ACCESSIBILITY - if ( action != 0 - && is_accessibility_enabled() + if ( action != 0 + && is_accessibility_enabled() && !is_input_keyboard_display_on()) { char current_label[255]; @@ -747,8 +747,8 @@ enum menu_entry_type menu_entry_get_type(uint32_t i) file_list_t *selection_buf = menu_entries_get_selection_buf_ptr_internal(0); menu_file_list_cbs_t *cbs = NULL; rarch_setting_t *setting = NULL; - - /* FIXME/TODO - XXX Really a special kind of ST_ACTION, + + /* FIXME/TODO - XXX Really a special kind of ST_ACTION, * but this should be changed */ if (menu_setting_ctl(MENU_SETTING_CTL_IS_OF_PATH_TYPE, (void*)setting)) return MENU_ENTRY_PATH; @@ -1396,8 +1396,8 @@ void menu_entries_get_at_offset(const file_list_t *list, size_t idx, { file_list_get_at_offset(list, idx, path, label, file_type, entry_idx); if (list && alt) - *alt = list->list[idx].alt - ? list->list[idx].alt + *alt = list->list[idx].alt + ? list->list[idx].alt : list->list[idx].path; } @@ -1419,7 +1419,7 @@ static int menu_entries_elem_get_first_char( if (list) if ((path = list->list[offset].alt - ? list->list[offset].alt + ? list->list[offset].alt : list->list[offset].path)) ret = tolower((int)*path); @@ -1532,9 +1532,9 @@ int menu_entries_get_title(char *s, size_t len) const char *path = NULL; const char *label = NULL; struct menu_state *menu_st = &menu_driver_state; - const file_list_t *list = menu_st->entries.list ? + const file_list_t *list = menu_st->entries.list ? menu_list_get(menu_st->entries.list, 0) : NULL; - menu_file_list_cbs_t *cbs = list + menu_file_list_cbs_t *cbs = list ? (menu_file_list_cbs_t*)list->list[list->size - 1].actiondata : NULL; @@ -2302,9 +2302,9 @@ void menu_display_timedate(gfx_display_ctx_datetime_t *datetime) strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%m-%d-%Y %H:%M", tm_); break; - case MENU_TIMEDATE_STYLE_MD_HM: /* MM/DD HH:MM */ + case MENU_TIMEDATE_STYLE_MD_HM: /* MM-DD HH:MM */ strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), - "%m/%d %H:%M", tm_); + "%m-%d %H:%M", tm_); break; case MENU_TIMEDATE_STYLE_MDYYYY: /* MM-DD-YYYY */ strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), @@ -2314,25 +2314,25 @@ void menu_display_timedate(gfx_display_ctx_datetime_t *datetime) strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%m-%d", tm_); break; - case MENU_TIMEDATE_STYLE_DDMMYYYY_HMS: /* DD/MM/YYYY HH:MM:SS */ + case MENU_TIMEDATE_STYLE_DDMMYYYY_HMS: /* DD-MM-YYYY HH:MM:SS */ strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), - "%d/%m/%Y %H:%M:%S", tm_); + "%d-%m-%Y %H:%M:%S", tm_); break; - case MENU_TIMEDATE_STYLE_DDMMYYYY_HM: /* DD/MM/YYYY HH:MM */ + case MENU_TIMEDATE_STYLE_DDMMYYYY_HM: /* DD-MM-YYYY HH:MM */ strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), - "%d/%m/%Y %H:%M", tm_); + "%d-%m-%Y %H:%M", tm_); break; - case MENU_TIMEDATE_STYLE_DDMM_HM: /* DD/MM HH:MM */ + case MENU_TIMEDATE_STYLE_DDMM_HM: /* DD-MM HH:MM */ strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), - "%d/%m %H:%M", tm_); + "%d-%m %H:%M", tm_); break; - case MENU_TIMEDATE_STYLE_DDMMYYYY: /* DD/MM/YYYY */ + case MENU_TIMEDATE_STYLE_DDMMYYYY: /* DD-MM-YYYY */ strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), - "%d/%m/%Y", tm_); + "%d-%m-%Y", tm_); break; - case MENU_TIMEDATE_STYLE_DDMM: /* DD/MM */ + case MENU_TIMEDATE_STYLE_DDMM: /* DD-MM */ strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), - "%d/%m", tm_); + "%d-%m", tm_); break; case MENU_TIMEDATE_STYLE_HMS: /* HH:MM:SS */ strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), @@ -2342,43 +2342,43 @@ void menu_display_timedate(gfx_display_ctx_datetime_t *datetime) strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%H:%M", tm_); break; - case MENU_TIMEDATE_STYLE_YMD_HMS_AM_PM: /* YYYY-MM-DD HH:MM:SS (am/pm) */ + case MENU_TIMEDATE_STYLE_YMD_HMS_AMPM: /* YYYY-MM-DD HH:MM:SS (AM/PM) */ strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%Y-%m-%d %I:%M:%S %p", tm_); break; - case MENU_TIMEDATE_STYLE_YMD_HM_AM_PM: /* YYYY-MM-DD HH:MM (am/pm) */ + case MENU_TIMEDATE_STYLE_YMD_HM_AMPM: /* YYYY-MM-DD HH:MM (AM/PM) */ strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%Y-%m-%d %I:%M %p", tm_); break; - case MENU_TIMEDATE_STYLE_MDYYYY_HMS_AM_PM: /* MM-DD-YYYY HH:MM:SS (am/pm) */ + case MENU_TIMEDATE_STYLE_MDYYYY_HMS_AMPM: /* MM-DD-YYYY HH:MM:SS (AM/PM) */ strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%m-%d-%Y %I:%M:%S %p", tm_); break; - case MENU_TIMEDATE_STYLE_MDYYYY_HM_AM_PM: /* MM-DD-YYYY HH:MM (am/pm) */ + case MENU_TIMEDATE_STYLE_MDYYYY_HM_AMPM: /* MM-DD-YYYY HH:MM (AM/PM) */ strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%m-%d-%Y %I:%M %p", tm_); break; - case MENU_TIMEDATE_STYLE_MD_HM_AM_PM: /* MM/DD HH:MM (am/pm) */ + case MENU_TIMEDATE_STYLE_MD_HM_AMPM: /* MM-DD HH:MM (AM/PM) */ strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), - "%m/%d %I:%M %p", tm_); + "%m-%d %I:%M %p", tm_); break; - case MENU_TIMEDATE_STYLE_DDMMYYYY_HMS_AM_PM: /* DD/MM/YYYY HH:MM:SS (am/pm) */ + case MENU_TIMEDATE_STYLE_DDMMYYYY_HMS_AMPM: /* DD-MM-YYYY HH:MM:SS (AM/PM) */ strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), - "%d/%m/%Y %I:%M:%S %p", tm_); + "%d-%m-%Y %I:%M:%S %p", tm_); break; - case MENU_TIMEDATE_STYLE_DDMMYYYY_HM_AM_PM: /* DD/MM/YYYY HH:MM (am/pm) */ + case MENU_TIMEDATE_STYLE_DDMMYYYY_HM_AMPM: /* DD-MM-YYYY HH:MM (AM/PM) */ strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), - "%d/%m/%Y %I:%M %p", tm_); + "%d-%m-%Y %I:%M %p", tm_); break; - case MENU_TIMEDATE_STYLE_DDMM_HM_AM_PM: /* DD/MM HH:MM (am/pm) */ + case MENU_TIMEDATE_STYLE_DDMM_HM_AMPM: /* DD-MM HH:MM (AM/PM) */ strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), - "%d/%m %I:%M %p", tm_); + "%d-%m %I:%M %p", tm_); break; - case MENU_TIMEDATE_STYLE_HMS_AM_PM: /* HH:MM:SS (am/pm) */ + case MENU_TIMEDATE_STYLE_HMS_AMPM: /* HH:MM:SS (AM/PM) */ strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%I:%M:%S %p", tm_); break; - case MENU_TIMEDATE_STYLE_HM_AM_PM: /* HH:MM (am/pm) */ + case MENU_TIMEDATE_STYLE_HM_AMPM: /* HH:MM (AM/PM) */ strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache), "%I:%M %p", tm_); break; @@ -2615,7 +2615,7 @@ bool menu_driver_init(bool video_is_threaded) command_event(CMD_EVENT_CORE_INFO_INIT, NULL); command_event(CMD_EVENT_LOAD_CORE_PERSIST, NULL); - if ( menu_driver_data || + if ( menu_driver_data || menu_driver_init_internal(video_is_threaded)) { if (menu_driver_ctx && menu_driver_ctx->context_reset) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index cb989d0d57..86b7e8beea 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3193,129 +3193,129 @@ static void setting_get_string_representation_uint_menu_timedate_style( { case MENU_TIMEDATE_STYLE_YMD_HMS: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS), len); break; case MENU_TIMEDATE_STYLE_YMD_HM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM), len); break; case MENU_TIMEDATE_STYLE_YMD: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD), len); break; case MENU_TIMEDATE_STYLE_YM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YM), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_YM), len); break; case MENU_TIMEDATE_STYLE_MDYYYY_HMS: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS), len); break; case MENU_TIMEDATE_STYLE_MDYYYY_HM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM), len); break; case MENU_TIMEDATE_STYLE_MD_HM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM), len); break; case MENU_TIMEDATE_STYLE_MDYYYY: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY), len); break; case MENU_TIMEDATE_STYLE_MD: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD), len); break; case MENU_TIMEDATE_STYLE_DDMMYYYY_HMS: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS), len); break; case MENU_TIMEDATE_STYLE_DDMMYYYY_HM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM), len); break; case MENU_TIMEDATE_STYLE_DDMM_HM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM), len); break; case MENU_TIMEDATE_STYLE_DDMMYYYY: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY), len); break; case MENU_TIMEDATE_STYLE_DDMM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM), len); break; case MENU_TIMEDATE_STYLE_HMS: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS), len); break; case MENU_TIMEDATE_STYLE_HM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM), len); break; - case MENU_TIMEDATE_STYLE_YMD_HMS_AM_PM: + case MENU_TIMEDATE_STYLE_YMD_HMS_AMPM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS_AM_PM), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS_AMPM), len); break; - case MENU_TIMEDATE_STYLE_YMD_HM_AM_PM: + case MENU_TIMEDATE_STYLE_YMD_HM_AMPM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM_AM_PM), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM_AMPM), len); break; - case MENU_TIMEDATE_STYLE_MDYYYY_HMS_AM_PM: + case MENU_TIMEDATE_STYLE_MDYYYY_HMS_AMPM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS_AM_PM), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS_AMPM), len); break; - case MENU_TIMEDATE_STYLE_MDYYYY_HM_AM_PM: + case MENU_TIMEDATE_STYLE_MDYYYY_HM_AMPM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM_AM_PM), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM_AMPM), len); break; - case MENU_TIMEDATE_STYLE_MD_HM_AM_PM: + case MENU_TIMEDATE_STYLE_MD_HM_AMPM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM_AM_PM), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM_AMPM), len); break; - case MENU_TIMEDATE_STYLE_DDMMYYYY_HMS_AM_PM: + case MENU_TIMEDATE_STYLE_DDMMYYYY_HMS_AMPM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS_AM_PM), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS_AMPM), len); break; - case MENU_TIMEDATE_STYLE_DDMMYYYY_HM_AM_PM: + case MENU_TIMEDATE_STYLE_DDMMYYYY_HM_AMPM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM_AM_PM), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM_AMPM), len); break; - case MENU_TIMEDATE_STYLE_DDMM_HM_AM_PM: + case MENU_TIMEDATE_STYLE_DDMM_HM_AMPM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM_AM_PM), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM_AMPM), len); break; - case MENU_TIMEDATE_STYLE_HMS_AM_PM: + case MENU_TIMEDATE_STYLE_HMS_AMPM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS_AMPM), len); break; - case MENU_TIMEDATE_STYLE_HM_AM_PM: + case MENU_TIMEDATE_STYLE_HM_AMPM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM_AM_PM), len); + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM_AMPM), len); break; } } @@ -4547,133 +4547,133 @@ static void setting_get_string_representation_uint_playlist_sublabel_last_played case PLAYLIST_LAST_PLAYED_STYLE_YMD_HMS: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HMS), + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS), len); break; case PLAYLIST_LAST_PLAYED_STYLE_YMD_HM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HM), + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM), len); break; case PLAYLIST_LAST_PLAYED_STYLE_YMD: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD), + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD), len); break; case PLAYLIST_LAST_PLAYED_STYLE_YM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YM), + MENU_ENUM_LABEL_VALUE_TIMEDATE_YM), len); break; case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HMS: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HMS), + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS), len); break; case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HM), + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM), len); break; case PLAYLIST_LAST_PLAYED_STYLE_MD_HM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MD_HM), + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM), len); break; case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY), + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY), len); break; case PLAYLIST_LAST_PLAYED_STYLE_MD: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MD), + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD), len); break; case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HMS: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HMS), + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS), len); break; case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HM), + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM), len); break; case PLAYLIST_LAST_PLAYED_STYLE_DDMM_HM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMM_HM), + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM), len); break; case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY), + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY), len); break; case PLAYLIST_LAST_PLAYED_STYLE_DDMM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMM), + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM), len); break; - case PLAYLIST_LAST_PLAYED_STYLE_YMD_HMS_AM_PM: + case PLAYLIST_LAST_PLAYED_STYLE_YMD_HMS_AMPM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HMS_AM_PM), + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS_AMPM), len); break; - case PLAYLIST_LAST_PLAYED_STYLE_YMD_HM_AM_PM: + case PLAYLIST_LAST_PLAYED_STYLE_YMD_HM_AMPM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HM_AM_PM), + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM_AMPM), len); break; - case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HMS_AM_PM: + case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HMS_AMPM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HMS_AM_PM), + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS_AMPM), len); break; - case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HM_AM_PM: + case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HM_AMPM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HM_AM_PM), + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM_AMPM), len); break; - case PLAYLIST_LAST_PLAYED_STYLE_MD_HM_AM_PM: + case PLAYLIST_LAST_PLAYED_STYLE_MD_HM_AMPM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MD_HM_AM_PM), + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM_AMPM), len); break; - case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HMS_AM_PM: + case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HMS_AMPM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HMS_AM_PM), + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS_AMPM), len); break; - case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HM_AM_PM: + case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HM_AMPM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HM_AM_PM), + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM_AMPM), len); break; - case PLAYLIST_LAST_PLAYED_STYLE_DDMM_HM_AM_PM: + case PLAYLIST_LAST_PLAYED_STYLE_DDMM_HM_AMPM: strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMM_HM_AM_PM), + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM_AMPM), len); break; } diff --git a/msg_hash.h b/msg_hash.h index df6d0ef7da..b2d09750d1 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -2662,32 +2662,32 @@ enum msg_hash_enums MSG_CHEAT_SEARCH_DELETE_MATCH_SUCCESS, MSG_CHEEVOS_HARDCORE_MODE_DISABLED, MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YM, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS_AM_PM, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM_AM_PM, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HMS_AM_PM, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_HM_AM_PM, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM_AM_PM, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HMS_AM_PM, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMMYYYY_HM_AM_PM, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DDMM_HM_AM_PM, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD, + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY, + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS_AMPM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM_AMPM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HMS_AMPM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MDYYYY_HM_AMPM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_MD_HM_AMPM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HMS_AMPM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMMYYYY_HM_AMPM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM_AMPM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS_AMPM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_HM_AMPM, MENU_ENUM_LABEL_SWITCH_GPU_PROFILE, MENU_ENUM_LABEL_VALUE_SWITCH_GPU_PROFILE, @@ -2735,29 +2735,6 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_PLAYLIST_RUNTIME_PER_CORE, MENU_ENUM_LABEL_VALUE_PLAYLIST_RUNTIME_AGGREGATE, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HMS, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HM, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YM, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HMS, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HM, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MD_HM, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MD, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HMS, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HM, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMM_HM, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMM, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HMS_AM_PM, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_YMD_HM_AM_PM, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HMS_AM_PM, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MDYYYY_HM_AM_PM, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_MD_HM_AM_PM, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HMS_AM_PM, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMMYYYY_HM_AM_PM, - MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED_STYLE_DDMM_HM_AM_PM, - MENU_LABEL(HELP_SEND_DEBUG_INFO), MENU_ENUM_LABEL_VALUE_HELP_SEND_DEBUG_INFO_DESC, diff --git a/runtime_file.c b/runtime_file.c index db17eace70..98edd6d4f9 100644 --- a/runtime_file.c +++ b/runtime_file.c @@ -64,14 +64,14 @@ static JSON_Parser_HandlerResult RtlJSONObjectMemberHandler(JSON_Parser parser, { RtlJSONContext *pCtx = (RtlJSONContext*)JSON_Parser_GetUserData(parser); (void)attributes; /* unused */ - + if (pCtx->current_entry_val) { /* something went wrong */ RARCH_ERR("JSON parsing failed at line %d.\n", __LINE__); return JSON_Parser_Abort; } - + if (length) { if (string_is_equal(pValue, "runtime")) @@ -80,7 +80,7 @@ static JSON_Parser_HandlerResult RtlJSONObjectMemberHandler(JSON_Parser parser, pCtx->current_entry_val = &pCtx->last_played_string; /* ignore unknown members */ } - + return JSON_Parser_Continue; } @@ -88,18 +88,18 @@ static JSON_Parser_HandlerResult RtlJSONStringHandler(JSON_Parser parser, char * { RtlJSONContext *pCtx = (RtlJSONContext*)JSON_Parser_GetUserData(parser); (void)attributes; /* unused */ - + if (pCtx->current_entry_val && length && !string_is_empty(pValue)) { if (*pCtx->current_entry_val) free(*pCtx->current_entry_val); - + *pCtx->current_entry_val = strdup(pValue); } /* ignore unknown members */ - + pCtx->current_entry_val = NULL; - + return JSON_Parser_Continue; } @@ -107,7 +107,7 @@ static JSON_Writer_HandlerResult RtlJSONOutputHandler(JSON_Writer writer, const { RtlJSONContext *context = (RtlJSONContext*)JSON_Writer_GetUserData(writer); (void)writer; /* unused */ - + return filestream_write(context->file, pBytes, length) == length ? JSON_Writer_Continue : JSON_Writer_Abort; } @@ -140,50 +140,50 @@ static void runtime_log_read_file(runtime_log_t *runtime_log) unsigned runtime_hours = 0; unsigned runtime_minutes = 0; unsigned runtime_seconds = 0; - + unsigned last_played_year = 0; unsigned last_played_month = 0; unsigned last_played_day = 0; unsigned last_played_hour = 0; unsigned last_played_minute = 0; unsigned last_played_second = 0; - + RtlJSONContext context = {0}; /* Attempt to open log file */ RFILE *file = filestream_open(runtime_log->path, RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); - + if (!file) { RARCH_ERR("Failed to open runtime log file: %s\n", runtime_log->path); return; } - + /* Initialise JSON parser */ context.runtime_string = NULL; context.last_played_string = NULL; context.parser = JSON_Parser_Create(NULL); context.file = file; - + if (!context.parser) { RARCH_ERR("Failed to create JSON parser.\n"); goto end; } - + /* Configure parser */ JSON_Parser_SetAllowBOM(context.parser, JSON_True); JSON_Parser_SetStringHandler(context.parser, &RtlJSONStringHandler); JSON_Parser_SetObjectMemberHandler(context.parser, &RtlJSONObjectMemberHandler); JSON_Parser_SetUserData(context.parser, &context); - + /* Read file */ while (!filestream_eof(file)) { /* Runtime log files are tiny - use small chunk size */ char chunk[128] = {0}; int64_t length = filestream_read(file, chunk, sizeof(chunk)); - + /* Error checking... */ if (!length && !filestream_eof(file)) { @@ -191,7 +191,7 @@ static void runtime_log_read_file(runtime_log_t *runtime_log) JSON_Parser_Free(context.parser); goto end; } - + /* Parse chunk */ if (!JSON_Parser_Parse(context.parser, chunk, length, JSON_False)) { @@ -201,7 +201,7 @@ static void runtime_log_read_file(runtime_log_t *runtime_log) goto end; } } - + /* Finalise parsing */ if (!JSON_Parser_Parse(context.parser, NULL, 0, JSON_True)) { @@ -210,12 +210,12 @@ static void runtime_log_read_file(runtime_log_t *runtime_log) JSON_Parser_Free(context.parser); goto end; } - + /* Free parser */ JSON_Parser_Free(context.parser); - + /* Process string values read from JSON file */ - + /* Runtime */ if (!string_is_empty(context.runtime_string)) { @@ -226,7 +226,7 @@ static void runtime_log_read_file(runtime_log_t *runtime_log) goto end; } } - + /* Last played */ if (!string_is_empty(context.last_played_string)) { @@ -238,28 +238,28 @@ static void runtime_log_read_file(runtime_log_t *runtime_log) goto end; } } - + /* If we reach this point then all is well * > Assign values to runtime_log object */ runtime_log->runtime.hours = runtime_hours; runtime_log->runtime.minutes = runtime_minutes; runtime_log->runtime.seconds = runtime_seconds; - + runtime_log->last_played.year = last_played_year; runtime_log->last_played.month = last_played_month; runtime_log->last_played.day = last_played_day; runtime_log->last_played.hour = last_played_hour; runtime_log->last_played.minute = last_played_minute; runtime_log->last_played.second = last_played_second; - + end: - + /* Clean up leftover strings */ if (context.runtime_string) free(context.runtime_string); if (context.last_played_string) free(context.last_played_string); - + /* Close log file */ filestream_close(file); } @@ -283,14 +283,14 @@ runtime_log_t *runtime_log_init( core_info_list_t *core_info = NULL; runtime_log_t *runtime_log = NULL; const char *core_path_basename = NULL; - + content_name[0] = '\0'; core_name[0] = '\0'; log_file_dir[0] = '\0'; log_file_path[0] = '\0'; tmp_buf[0] = '\0'; - - if ( string_is_empty(dir_runtime_log) && + + if ( string_is_empty(dir_runtime_log) && string_is_empty(dir_playlist)) { RARCH_ERR("Runtime log directory is undefined - cannot save" @@ -304,21 +304,21 @@ runtime_log_t *runtime_log_init( return NULL; core_path_basename = path_basename(core_path); - - if ( string_is_empty(content_path) || + + if ( string_is_empty(content_path) || string_is_empty(core_path_basename)) return NULL; - + /* Get core name * Note: An annoyance - this is required even when * we are performing aggregate (not per core) logging, * since content name is sometimes dependent upon core * (e.g. see TyrQuake below) */ core_info_get_list(&core_info); - + if (!core_info) return NULL; - + for (i = 0; i < core_info->count; i++) { const char *entry_core_name = core_info->list[i].core_name; @@ -332,10 +332,10 @@ runtime_log_t *runtime_log_init( strlcpy(core_name, entry_core_name, sizeof(core_name)); break; } - + if (string_is_empty(core_name)) return NULL; - + /* Get runtime log directory */ if (string_is_empty(dir_runtime_log)) { @@ -349,10 +349,10 @@ runtime_log_t *runtime_log_init( } else strlcpy(tmp_buf, dir_runtime_log, sizeof(tmp_buf)); - + if (string_is_empty(tmp_buf)) return NULL; - + if (log_per_core) fill_pathname_join( log_file_dir, @@ -361,10 +361,10 @@ runtime_log_t *runtime_log_init( sizeof(log_file_dir)); else strlcpy(log_file_dir, tmp_buf, sizeof(log_file_dir)); - + if (string_is_empty(log_file_dir)) return NULL; - + /* Create directory, if required */ if (!path_is_directory(log_file_dir)) { @@ -375,7 +375,7 @@ runtime_log_t *runtime_log_init( return NULL; } } - + /* Get content name * Note: TyrQuake requires a specific hack, since all * content has the same name... */ @@ -407,14 +407,14 @@ runtime_log_t *runtime_log_init( strlcpy(content_name, tmp_buf_no_ext, sizeof(content_name)); } - + if (string_is_empty(content_name)) return NULL; - + /* Build final log file path */ fill_pathname_join(log_file_path, log_file_dir, content_name, sizeof(log_file_path)); strlcat(log_file_path, file_path_str(FILE_PATH_RUNTIME_EXTENSION), sizeof(log_file_path)); - + if (string_is_empty(log_file_path)) return NULL; @@ -423,25 +423,25 @@ runtime_log_t *runtime_log_init( runtime_log = (runtime_log_t*)calloc(1, sizeof(*runtime_log)); if (!runtime_log) return NULL; - + /* > Populate default values */ runtime_log->runtime.hours = 0; runtime_log->runtime.minutes = 0; runtime_log->runtime.seconds = 0; - + runtime_log->last_played.year = 0; runtime_log->last_played.month = 0; runtime_log->last_played.day = 0; runtime_log->last_played.hour = 0; runtime_log->last_played.minute = 0; runtime_log->last_played.second = 0; - + strlcpy(runtime_log->path, log_file_path, sizeof(runtime_log->path)); - + /* Load existing log file, if it exists */ if (path_is_valid(runtime_log->path)) runtime_log_read_file(runtime_log); - + return runtime_log; } @@ -451,17 +451,17 @@ runtime_log_t *runtime_log_init( void runtime_log_set_runtime_hms(runtime_log_t *runtime_log, unsigned hours, unsigned minutes, unsigned seconds) { retro_time_t usec; - + if (!runtime_log) return; - + /* Converting to usec and back again may be considered a * waste of CPU cycles, but this allows us to handle any * kind of broken input without issue - i.e. user can enter * minutes and seconds values > 59, and everything still * works correctly */ runtime_log_convert_hms2usec(hours, minutes, seconds, &usec); - + runtime_log_convert_usec2hms(usec, &runtime_log->runtime.hours, &runtime_log->runtime.minutes, &runtime_log->runtime.seconds); } @@ -471,7 +471,7 @@ void runtime_log_set_runtime_usec(runtime_log_t *runtime_log, retro_time_t usec) { if (!runtime_log) return; - + runtime_log_convert_usec2hms(usec, &runtime_log->runtime.hours, &runtime_log->runtime.minutes, &runtime_log->runtime.seconds); } @@ -481,16 +481,16 @@ void runtime_log_add_runtime_hms(runtime_log_t *runtime_log, unsigned hours, uns { retro_time_t usec_old; retro_time_t usec_new; - + if (!runtime_log) return; - + runtime_log_convert_hms2usec( runtime_log->runtime.hours, runtime_log->runtime.minutes, runtime_log->runtime.seconds, &usec_old); - + runtime_log_convert_hms2usec(hours, minutes, seconds, &usec_new); - + runtime_log_convert_usec2hms(usec_old + usec_new, &runtime_log->runtime.hours, &runtime_log->runtime.minutes, &runtime_log->runtime.seconds); } @@ -499,14 +499,14 @@ void runtime_log_add_runtime_hms(runtime_log_t *runtime_log, unsigned hours, uns void runtime_log_add_runtime_usec(runtime_log_t *runtime_log, retro_time_t usec) { retro_time_t usec_old; - + if (!runtime_log) return; - + runtime_log_convert_hms2usec( runtime_log->runtime.hours, runtime_log->runtime.minutes, runtime_log->runtime.seconds, &usec_old); - + runtime_log_convert_usec2hms(usec_old + usec, &runtime_log->runtime.hours, &runtime_log->runtime.minutes, &runtime_log->runtime.seconds); } @@ -518,7 +518,7 @@ void runtime_log_set_last_played(runtime_log_t *runtime_log, { if (!runtime_log) return; - + /* This function should never be needed, so just * perform dumb value assignment (i.e. no validation * using mktime()) */ @@ -535,14 +535,14 @@ void runtime_log_set_last_played_now(runtime_log_t *runtime_log) { time_t current_time; struct tm *time_info; - + if (!runtime_log) return; - + /* Get current time */ time(¤t_time); time_info = localtime(¤t_time); - + /* This can actually happen, but if does we probably * have bigger problems to worry about... */ if(!time_info) @@ -550,7 +550,7 @@ void runtime_log_set_last_played_now(runtime_log_t *runtime_log) RARCH_ERR("Failed to get current time.\n"); return; } - + /* Extract values */ runtime_log->last_played.year = (unsigned)time_info->tm_year + 1900; runtime_log->last_played.month = (unsigned)time_info->tm_mon + 1; @@ -565,11 +565,11 @@ void runtime_log_reset(runtime_log_t *runtime_log) { if (!runtime_log) return; - + runtime_log->runtime.hours = 0; runtime_log->runtime.minutes = 0; runtime_log->runtime.seconds = 0; - + runtime_log->last_played.year = 0; runtime_log->last_played.month = 0; runtime_log->last_played.day = 0; @@ -586,7 +586,7 @@ void runtime_log_get_runtime_hms(runtime_log_t *runtime_log, { if (!runtime_log) return; - + *hours = runtime_log->runtime.hours; *minutes = runtime_log->runtime.minutes; *seconds = runtime_log->runtime.seconds; @@ -630,7 +630,7 @@ void runtime_log_get_last_played(runtime_log_t *runtime_log, { if (!runtime_log) return; - + *year = runtime_log->last_played.year; *month = runtime_log->last_played.month; *day = runtime_log->last_played.day; @@ -645,7 +645,7 @@ void runtime_log_get_last_played_time(runtime_log_t *runtime_log, struct tm *tim { if (!runtime_log || !time_info) return; - + /* Set tm values */ time_info->tm_year = (int)runtime_log->last_played.year - 1900; time_info->tm_mon = (int)runtime_log->last_played.month - 1; @@ -654,7 +654,7 @@ void runtime_log_get_last_played_time(runtime_log_t *runtime_log, struct tm *tim time_info->tm_min = (int)runtime_log->last_played.minute; time_info->tm_sec = (int)runtime_log->last_played.second; time_info->tm_isdst = -1; - + /* Perform any required range adjustment + populate * missing entries */ mktime(time_info); @@ -707,43 +707,43 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log, * > These require extra work, due to AM/PM localisation */ switch (timedate_style) { - case PLAYLIST_LAST_PLAYED_STYLE_YMD_HMS_AM_PM: - last_played_strftime(runtime_log, tmp, sizeof(tmp), " %Y/%m/%d - %I:%M:%S %p"); + case PLAYLIST_LAST_PLAYED_STYLE_YMD_HMS_AMPM: + last_played_strftime(runtime_log, tmp, sizeof(tmp), " %Y-%m-%d %I:%M:%S %p"); strlcpy(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len); strlcat(str, tmp, len); return; - case PLAYLIST_LAST_PLAYED_STYLE_YMD_HM_AM_PM: - last_played_strftime(runtime_log, tmp, sizeof(tmp), " %Y/%m/%d - %I:%M %p"); + case PLAYLIST_LAST_PLAYED_STYLE_YMD_HM_AMPM: + last_played_strftime(runtime_log, tmp, sizeof(tmp), " %Y-%m-%d %I:%M %p"); strlcpy(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len); strlcat(str, tmp, len); return; - case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HMS_AM_PM: - last_played_strftime(runtime_log, tmp, sizeof(tmp), " %m/%d/%Y - %I:%M:%S %p"); + case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HMS_AMPM: + last_played_strftime(runtime_log, tmp, sizeof(tmp), " %m-%d-%Y %I:%M:%S %p"); strlcpy(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len); strlcat(str, tmp, len); return; - case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HM_AM_PM: - last_played_strftime(runtime_log, tmp, sizeof(tmp), " %m/%d/%Y - %I:%M %p"); + case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HM_AMPM: + last_played_strftime(runtime_log, tmp, sizeof(tmp), " %m-%d-%Y %I:%M %p"); strlcpy(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len); strlcat(str, tmp, len); return; - case PLAYLIST_LAST_PLAYED_STYLE_MD_HM_AM_PM: - last_played_strftime(runtime_log, tmp, sizeof(tmp), " %m/%d - %I:%M %p"); + case PLAYLIST_LAST_PLAYED_STYLE_MD_HM_AMPM: + last_played_strftime(runtime_log, tmp, sizeof(tmp), " %m-%d %I:%M %p"); strlcpy(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len); strlcat(str, tmp, len); return; - case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HMS_AM_PM: - last_played_strftime(runtime_log, tmp, sizeof(tmp), " %d/%m/%Y - %I:%M:%S %p"); + case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HMS_AMPM: + last_played_strftime(runtime_log, tmp, sizeof(tmp), " %d-%m-%Y %I:%M:%S %p"); strlcpy(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len); strlcat(str, tmp, len); return; - case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HM_AM_PM: - last_played_strftime(runtime_log, tmp, sizeof(tmp), " %d/%m/%Y - %I:%M %p"); + case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HM_AMPM: + last_played_strftime(runtime_log, tmp, sizeof(tmp), " %d-%m-%Y %I:%M %p"); strlcpy(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len); strlcat(str, tmp, len); return; - case PLAYLIST_LAST_PLAYED_STYLE_DDMM_HM_AM_PM: - last_played_strftime(runtime_log, tmp, sizeof(tmp), " %d/%m - %I:%M %p"); + case PLAYLIST_LAST_PLAYED_STYLE_DDMM_HM_AMPM: + last_played_strftime(runtime_log, tmp, sizeof(tmp), " %d-%m %I:%M %p"); strlcpy(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len); strlcat(str, tmp, len); return; @@ -755,80 +755,80 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log, switch (timedate_style) { case PLAYLIST_LAST_PLAYED_STYLE_YMD_HM: - n = snprintf(str, len, "%s %04u/%02u/%02u - %02u:%02u", + n = snprintf(str, len, "%s %04u-%02u-%02u %02u:%02u", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), runtime_log->last_played.year, runtime_log->last_played.month, runtime_log->last_played.day, runtime_log->last_played.hour, runtime_log->last_played.minute); return; case PLAYLIST_LAST_PLAYED_STYLE_YMD: - n = snprintf(str, len, "%s %04u/%02u/%02u", + n = snprintf(str, len, "%s %04u-%02u-%02u", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), runtime_log->last_played.year, runtime_log->last_played.month, runtime_log->last_played.day); return; case PLAYLIST_LAST_PLAYED_STYLE_YM: - n = snprintf(str, len, "%s %04u/%02u", + n = snprintf(str, len, "%s %04u-%02u", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), runtime_log->last_played.year, runtime_log->last_played.month); return; case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HMS: - n = snprintf(str, len, "%s %02u/%02u/%04u - %02u:%02u:%02u", + n = snprintf(str, len, "%s %02u-%02u-%04u %02u:%02u:%02u", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), runtime_log->last_played.month, runtime_log->last_played.day, runtime_log->last_played.year, runtime_log->last_played.hour, runtime_log->last_played.minute, runtime_log->last_played.second); return; case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HM: - n = snprintf(str, len, "%s %02u/%02u/%04u - %02u:%02u", + n = snprintf(str, len, "%s %02u-%02u-%04u %02u:%02u", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), runtime_log->last_played.month, runtime_log->last_played.day, runtime_log->last_played.year, runtime_log->last_played.hour, runtime_log->last_played.minute); return; case PLAYLIST_LAST_PLAYED_STYLE_MD_HM: - n = snprintf(str, len, "%s %02u/%02u - %02u:%02u", + n = snprintf(str, len, "%s %02u-%02u %02u:%02u", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), runtime_log->last_played.month, runtime_log->last_played.day, runtime_log->last_played.hour, runtime_log->last_played.minute); return; case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY: - n = snprintf(str, len, "%s %02u/%02u/%04u", + n = snprintf(str, len, "%s %02u-%02u-%04u", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), runtime_log->last_played.month, runtime_log->last_played.day, runtime_log->last_played.year); return; case PLAYLIST_LAST_PLAYED_STYLE_MD: - n = snprintf(str, len, "%s %02u/%02u", + n = snprintf(str, len, "%s %02u-%02u", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), runtime_log->last_played.month, runtime_log->last_played.day); return; case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HMS: - n = snprintf(str, len, "%s %02u/%02u/%04u - %02u:%02u:%02u", + n = snprintf(str, len, "%s %02u-%02u-%04u %02u:%02u:%02u", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), runtime_log->last_played.day, runtime_log->last_played.month, runtime_log->last_played.year, runtime_log->last_played.hour, runtime_log->last_played.minute, runtime_log->last_played.second); return; case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HM: - n = snprintf(str, len, "%s %02u/%02u/%04u - %02u:%02u", + n = snprintf(str, len, "%s %02u-%02u-%04u %02u:%02u", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), runtime_log->last_played.day, runtime_log->last_played.month, runtime_log->last_played.year, runtime_log->last_played.hour, runtime_log->last_played.minute); return; case PLAYLIST_LAST_PLAYED_STYLE_DDMM_HM: - n = snprintf(str, len, "%s %02u/%02u - %02u:%02u", + n = snprintf(str, len, "%s %02u-%02u %02u:%02u", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), runtime_log->last_played.day, runtime_log->last_played.month, runtime_log->last_played.hour, runtime_log->last_played.minute); return; case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY: - n = snprintf(str, len, "%s %02u/%02u/%04u", + n = snprintf(str, len, "%s %02u-%02u-%04u", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), runtime_log->last_played.day, runtime_log->last_played.month, runtime_log->last_played.year); return; case PLAYLIST_LAST_PLAYED_STYLE_DDMM: - n = snprintf(str, len, "%s %02u/%02u", + n = snprintf(str, len, "%s %02u-%02u", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), runtime_log->last_played.day, runtime_log->last_played.month); return; case PLAYLIST_LAST_PLAYED_STYLE_YMD_HMS: default: - n = snprintf(str, len, "%s %04u/%02u/%02u - %02u:%02u:%02u", + n = snprintf(str, len, "%s %04u-%02u-%02u %02u:%02u:%02u", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), runtime_log->last_played.year, runtime_log->last_played.month, runtime_log->last_played.day, runtime_log->last_played.hour, runtime_log->last_played.minute, runtime_log->last_played.second); @@ -854,7 +854,7 @@ bool runtime_log_has_runtime(runtime_log_t *runtime_log) { if (!runtime_log) return false; - + return !((runtime_log->runtime.hours == 0) && (runtime_log->runtime.minutes == 0) && (runtime_log->runtime.seconds == 0)); @@ -865,7 +865,7 @@ bool runtime_log_has_last_played(runtime_log_t *runtime_log) { if (!runtime_log) return false; - + return !((runtime_log->last_played.year == 0) && (runtime_log->last_played.month == 0) && (runtime_log->last_played.day == 0) && @@ -880,45 +880,45 @@ bool runtime_log_has_last_played(runtime_log_t *runtime_log) void runtime_log_save(runtime_log_t *runtime_log) { int n; - char value_string[64]; /* 64 characters should be + char value_string[64]; /* 64 characters should be enough for a very long runtime... :) */ RtlJSONContext context = {0}; RFILE *file = NULL; - + if (!runtime_log) return; - + RARCH_LOG("Saving runtime log file: %s\n", runtime_log->path); - + /* Attempt to open log file */ file = filestream_open(runtime_log->path, RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE); - + if (!file) { RARCH_ERR("Failed to open runtime log file: %s\n", runtime_log->path); return; } - + /* Initialise JSON writer */ context.writer = JSON_Writer_Create(NULL); context.file = file; - + if (!context.writer) { RARCH_ERR("Failed to create JSON writer.\n"); goto end; } - + /* Configure JSON writer */ JSON_Writer_SetOutputEncoding(context.writer, JSON_UTF8); JSON_Writer_SetOutputHandler(context.writer, &RtlJSONOutputHandler); JSON_Writer_SetUserData(context.writer, &context); - + /* Write output file */ JSON_Writer_WriteStartObject(context.writer); JSON_Writer_WriteNewLine(context.writer); - + /* > Version entry */ JSON_Writer_WriteSpace(context.writer, 2); JSON_Writer_WriteString(context.writer, "version", @@ -929,7 +929,7 @@ void runtime_log_save(runtime_log_t *runtime_log) STRLEN_CONST("1.0"), JSON_UTF8); JSON_Writer_WriteComma(context.writer); JSON_Writer_WriteNewLine(context.writer); - + /* > Runtime entry */ value_string[0] = '\0'; n = snprintf(value_string, @@ -938,7 +938,7 @@ void runtime_log_save(runtime_log_t *runtime_log) runtime_log->runtime.seconds); if ((n < 0) || (n >= 64)) n = 0; /* Silence GCC warnings... */ - + JSON_Writer_WriteSpace(context.writer, 2); JSON_Writer_WriteString(context.writer, "runtime", STRLEN_CONST("runtime"), JSON_UTF8); @@ -948,7 +948,7 @@ void runtime_log_save(runtime_log_t *runtime_log) strlen(value_string), JSON_UTF8); JSON_Writer_WriteComma(context.writer); JSON_Writer_WriteNewLine(context.writer); - + /* > Last played entry */ value_string[0] = '\0'; n = snprintf(value_string, sizeof(value_string), @@ -959,7 +959,7 @@ void runtime_log_save(runtime_log_t *runtime_log) runtime_log->last_played.second); if ((n < 0) || (n >= 64)) n = 0; /* Silence GCC warnings... */ - + JSON_Writer_WriteSpace(context.writer, 2); JSON_Writer_WriteString(context.writer, "last_played", STRLEN_CONST("last_played"), JSON_UTF8); @@ -968,14 +968,14 @@ void runtime_log_save(runtime_log_t *runtime_log) JSON_Writer_WriteString(context.writer, value_string, strlen(value_string), JSON_UTF8); JSON_Writer_WriteNewLine(context.writer); - + /* > Finalise */ JSON_Writer_WriteEndObject(context.writer); JSON_Writer_WriteNewLine(context.writer); - + /* Free JSON writer */ JSON_Writer_Free(context.writer); - + end: /* Close log file */ filestream_close(file); @@ -999,7 +999,7 @@ void runtime_log_convert_usec2hms(retro_time_t usec, *seconds = (unsigned)(usec / 1000000); *minutes = *seconds / 60; *hours = *minutes / 60; - + *seconds -= *minutes * 60; *minutes -= *hours * 60; } @@ -1023,27 +1023,27 @@ void runtime_update_playlist( #if defined(HAVE_MENU) && (defined(HAVE_OZONE) || defined(HAVE_MATERIALUI)) const char *menu_ident = menu_driver_ident(); #endif - + /* Sanity check */ if (!playlist) return; - + if (idx >= playlist_get_size(playlist)) return; - + /* Set fallback playlist 'runtime_status' * (saves 'if' checks later...) */ update_entry.runtime_status = PLAYLIST_RUNTIME_MISSING; - + /* 'Attach' runtime/last played strings */ runtime_str[0] = '\0'; last_played_str[0] = '\0'; update_entry.runtime_str = runtime_str; update_entry.last_played_str = last_played_str; - + /* Read current playlist entry */ playlist_get_index(playlist, idx, &entry); - + /* Attempt to open log file */ runtime_log = runtime_log_init( entry->path, @@ -1051,7 +1051,7 @@ void runtime_update_playlist( dir_runtime_log, dir_playlist, log_per_core); - + if (runtime_log) { /* Check whether a non-zero runtime has been recorded */ @@ -1060,24 +1060,24 @@ void runtime_update_playlist( /* Read current runtime */ runtime_log_get_runtime_hms(runtime_log, &update_entry.runtime_hours, &update_entry.runtime_minutes, &update_entry.runtime_seconds); - + runtime_log_get_runtime_str(runtime_log, runtime_str, sizeof(runtime_str)); - + /* Read last played timestamp */ runtime_log_get_last_played(runtime_log, &update_entry.last_played_year, &update_entry.last_played_month, &update_entry.last_played_day, &update_entry.last_played_hour, &update_entry.last_played_minute, &update_entry.last_played_second); - + runtime_log_get_last_played_str(runtime_log, last_played_str, sizeof(last_played_str), timedate_style); - + /* Playlist entry now contains valid runtime data */ update_entry.runtime_status = PLAYLIST_RUNTIME_VALID; } - + /* Clean up */ free(runtime_log); } - + #if defined(HAVE_MENU) && (defined(HAVE_OZONE) || defined(HAVE_MATERIALUI)) /* Ozone and GLUI require runtime/last played strings * to be populated even when no runtime is recorded */ @@ -1095,7 +1095,7 @@ void runtime_update_playlist( } } #endif - + /* Update playlist */ playlist_update_runtime(playlist, idx, &update_entry, false); } diff --git a/runtime_file.h b/runtime_file.h index 3733085456..2f396c72a8 100644 --- a/runtime_file.h +++ b/runtime_file.h @@ -73,14 +73,14 @@ enum playlist_sublabel_last_played_style_type PLAYLIST_LAST_PLAYED_STYLE_DDMM_HM, PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY, PLAYLIST_LAST_PLAYED_STYLE_DDMM, - PLAYLIST_LAST_PLAYED_STYLE_YMD_HMS_AM_PM, - PLAYLIST_LAST_PLAYED_STYLE_YMD_HM_AM_PM, - PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HMS_AM_PM, - PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HM_AM_PM, - PLAYLIST_LAST_PLAYED_STYLE_MD_HM_AM_PM, - PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HMS_AM_PM, - PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HM_AM_PM, - PLAYLIST_LAST_PLAYED_STYLE_DDMM_HM_AM_PM, + PLAYLIST_LAST_PLAYED_STYLE_YMD_HMS_AMPM, + PLAYLIST_LAST_PLAYED_STYLE_YMD_HM_AMPM, + PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HMS_AMPM, + PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HM_AMPM, + PLAYLIST_LAST_PLAYED_STYLE_MD_HM_AMPM, + PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HMS_AMPM, + PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HM_AMPM, + PLAYLIST_LAST_PLAYED_STYLE_DDMM_HM_AMPM, PLAYLIST_LAST_PLAYED_STYLE_LAST }; From 70957aa52a87556009186fa3ba5ac654a1c18585 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 22 May 2020 01:45:52 +0200 Subject: [PATCH 179/192] (Ozone) Move these static variables outside of the header --- menu/drivers/ozone/ozone.c | 17 +++++++++++++++ menu/drivers/ozone/ozone_texture.c | 8 +++++++ menu/drivers/ozone/ozone_texture.h | 34 ++++++------------------------ 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index af435345ec..e044337fcb 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -46,6 +46,23 @@ #include "../../../core_info.h" #include "../../../verbosity.h" +static const char *OZONE_TEXTURES_FILES[OZONE_TEXTURE_LAST] = { + "retroarch", + "cursor_border" +}; + +static const char *OZONE_TAB_TEXTURES_FILES[OZONE_TAB_TEXTURE_LAST] = { + "retroarch", + "settings", + "history", + "favorites", + "music", + "video", + "image", + "netplay", + "add" +}; + ozone_node_t *ozone_alloc_node(void) { ozone_node_t *node = (ozone_node_t*)malloc(sizeof(*node)); diff --git a/menu/drivers/ozone/ozone_texture.c b/menu/drivers/ozone/ozone_texture.c index 15a0d0e2b3..e258632e04 100644 --- a/menu/drivers/ozone/ozone_texture.c +++ b/menu/drivers/ozone/ozone_texture.c @@ -29,6 +29,14 @@ #include "../../../verbosity.h" +static const char *OZONE_THEME_TEXTURES_FILES[OZONE_THEME_TEXTURE_LAST] = { + "switch", + "check", + + "cursor_noborder", + "cursor_static" +}; + uintptr_t ozone_entries_icon_get_texture(ozone_handle_t *ozone, enum msg_hash_enums enum_idx, unsigned type, bool active) { diff --git a/menu/drivers/ozone/ozone_texture.h b/menu/drivers/ozone/ozone_texture.h index 73ecc39681..68c727b3f1 100644 --- a/menu/drivers/ozone/ozone_texture.h +++ b/menu/drivers/ozone/ozone_texture.h @@ -25,7 +25,8 @@ #include "../../menu_driver.h" -enum OZONE_TEXTURE { +enum OZONE_TEXTURE +{ OZONE_TEXTURE_RETROARCH = 0, OZONE_TEXTURE_CURSOR_BORDER, #if 0 @@ -34,12 +35,8 @@ enum OZONE_TEXTURE { OZONE_TEXTURE_LAST }; -static const char *OZONE_TEXTURES_FILES[OZONE_TEXTURE_LAST] = { - "retroarch", - "cursor_border" -}; - -enum OZONE_THEME_TEXTURES { +enum OZONE_THEME_TEXTURES +{ OZONE_THEME_TEXTURE_SWITCH = 0, OZONE_THEME_TEXTURE_CHECK, @@ -49,15 +46,8 @@ enum OZONE_THEME_TEXTURES { OZONE_THEME_TEXTURE_LAST }; -static const char *OZONE_THEME_TEXTURES_FILES[OZONE_THEME_TEXTURE_LAST] = { - "switch", - "check", - - "cursor_noborder", - "cursor_static" -}; - -enum OZONE_TAB_TEXTURES { +enum OZONE_TAB_TEXTURES +{ OZONE_TAB_TEXTURE_MAIN_MENU = 0, OZONE_TAB_TEXTURE_SETTINGS, OZONE_TAB_TEXTURE_HISTORY, @@ -71,18 +61,6 @@ enum OZONE_TAB_TEXTURES { OZONE_TAB_TEXTURE_LAST }; -static const char *OZONE_TAB_TEXTURES_FILES[OZONE_TAB_TEXTURE_LAST] = { - "retroarch", - "settings", - "history", - "favorites", - "music", - "video", - "image", - "netplay", - "add" -}; - enum { OZONE_ENTRIES_ICONS_TEXTURE_MAIN_MENU = 0, From 6dcaa04a934301c815f0f361db21b9ca139cb235 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 22 May 2020 01:54:57 +0200 Subject: [PATCH 180/192] (Ozone) Move static variables outside of the header file --- menu/drivers/ozone/ozone_display.c | 14 +++ menu/drivers/ozone/ozone_theme.c | 126 ++++++++++++++++++++++++++ menu/drivers/ozone/ozone_theme.h | 138 ----------------------------- 3 files changed, 140 insertions(+), 138 deletions(-) diff --git a/menu/drivers/ozone/ozone_display.c b/menu/drivers/ozone/ozone_display.c index 2ce3263d30..5bbf9f6f88 100644 --- a/menu/drivers/ozone/ozone_display.c +++ b/menu/drivers/ozone/ozone_display.c @@ -30,6 +30,20 @@ #include "../../../input/input_osk.h" +static float ozone_backdrop[16] = { + 0.00, 0.00, 0.00, 0.75, + 0.00, 0.00, 0.00, 0.75, + 0.00, 0.00, 0.00, 0.75, + 0.00, 0.00, 0.00, 0.75, +}; + +static float ozone_osk_backdrop[16] = { + 0.00, 0.00, 0.00, 0.15, + 0.00, 0.00, 0.00, 0.15, + 0.00, 0.00, 0.00, 0.15, + 0.00, 0.00, 0.00, 0.15, +}; + static void ozone_cursor_animation_cb(void *userdata); static void ozone_animate_cursor(ozone_handle_t *ozone, float *dst, float *target) diff --git a/menu/drivers/ozone/ozone_theme.c b/menu/drivers/ozone/ozone_theme.c index ab118fcc23..e5fe4d203e 100644 --- a/menu/drivers/ozone/ozone_theme.c +++ b/menu/drivers/ozone/ozone_theme.c @@ -21,6 +21,132 @@ #include "ozone_theme.h" #include "ozone_display.h" +static float ozone_sidebar_gradient_top_light[16] = { + 0.94, 0.94, 0.94, 1.00, + 0.94, 0.94, 0.94, 1.00, + 0.922, 0.922, 0.922, 1.00, + 0.922, 0.922, 0.922, 1.00, +}; + +static float ozone_sidebar_gradient_bottom_light[16] = { + 0.922, 0.922, 0.922, 1.00, + 0.922, 0.922, 0.922, 1.00, + 0.94, 0.94, 0.94, 1.00, + 0.94, 0.94, 0.94, 1.00, +}; + +static float ozone_sidebar_gradient_top_dark[16] = { + 0.2, 0.2, 0.2, 1.00, + 0.2, 0.2, 0.2, 1.00, + 0.18, 0.18, 0.18, 1.00, + 0.18, 0.18, 0.18, 1.00, +}; + +static float ozone_sidebar_gradient_bottom_dark[16] = { + 0.18, 0.18, 0.18, 1.00, + 0.18, 0.18, 0.18, 1.00, + 0.2, 0.2, 0.2, 1.00, + 0.2, 0.2, 0.2, 1.00, +}; + +static float ozone_sidebar_gradient_top_nord[16] = { + 0.2078431f, 0.2352941f, 0.2901961f, 1.0f, + 0.2078431f, 0.2352941f, 0.2901961f, 1.0f, + 0.1921569f, 0.2196078f, 0.2705882f, 0.9f, + 0.1921569f, 0.2196078f, 0.2705882f, 0.9f, +}; + +static float ozone_sidebar_gradient_bottom_nord[16] = { + 0.1921569f, 0.2196078f, 0.2705882f, 0.9f, + 0.1921569f, 0.2196078f, 0.2705882f, 0.9f, + 0.2078431f, 0.2352941f, 0.2901961f, 1.0f, + 0.2078431f, 0.2352941f, 0.2901961f, 1.0f, +}; + +static float ozone_sidebar_gradient_top_gruvbox_dark[16] = { + 0.1960784f, 0.1882353f, 0.1843137f, 1.0f, + 0.1960784f, 0.1882353f, 0.1843137f, 1.0f, + 0.1686275f, 0.1686275f, 0.1686275f, 0.9f, + 0.1686275f, 0.1686275f, 0.1686275f, 0.9f, +}; + +static float ozone_sidebar_gradient_bottom_gruvbox_dark[16] = { + 0.1686275f, 0.1686275f, 0.1686275f, 0.9f, + 0.1686275f, 0.1686275f, 0.1686275f, 0.9f, + 0.1960784f, 0.1882353f, 0.1843137f, 1.0f, + 0.1960784f, 0.1882353f, 0.1843137f, 1.0f, +}; + +static float ozone_sidebar_background_light[16] = { + 0.94, 0.94, 0.94, 1.00, + 0.94, 0.94, 0.94, 1.00, + 0.94, 0.94, 0.94, 1.00, + 0.94, 0.94, 0.94, 1.00, +}; + +static float ozone_sidebar_background_dark[16] = { + 0.2, 0.2, 0.2, 1.00, + 0.2, 0.2, 0.2, 1.00, + 0.2, 0.2, 0.2, 1.00, + 0.2, 0.2, 0.2, 1.00, +}; + +static float ozone_sidebar_background_nord[16] = { + 0.2078431f, 0.2352941f, 0.2901961f, 1.0f, + 0.2078431f, 0.2352941f, 0.2901961f, 1.0f, + 0.2078431f, 0.2352941f, 0.2901961f, 1.0f, + 0.2078431f, 0.2352941f, 0.2901961f, 1.0f, +}; + +static float ozone_sidebar_background_gruvbox_dark[16] = { + 0.1960784f, 0.1882353f, 0.1843137f, 1.0f, + 0.1960784f, 0.1882353f, 0.1843137f, 1.0f, + 0.1960784f, 0.1882353f, 0.1843137f, 1.0f, + 0.1960784f, 0.1882353f, 0.1843137f, 1.0f, +}; + +static float ozone_background_libretro_running_light[16] = { + 0.690, 0.690, 0.690, 0.75, + 0.690, 0.690, 0.690, 0.75, + 0.922, 0.922, 0.922, 1.0, + 0.922, 0.922, 0.922, 1.0 +}; + +static float ozone_background_libretro_running_dark[16] = { + 0.176, 0.176, 0.176, 0.75, + 0.176, 0.176, 0.176, 0.75, + 0.178, 0.178, 0.178, 1.0, + 0.178, 0.178, 0.178, 1.0, +}; + +static float ozone_background_libretro_running_nord[16] = { + 0.1803922f, 0.2039216f, 0.2509804f, 0.75f, + 0.1803922f, 0.2039216f, 0.2509804f, 0.75f, + 0.1803922f, 0.2039216f, 0.2509804f, 1.0f, + 0.1803922f, 0.2039216f, 0.2509804f, 1.0f, +}; + +static float ozone_background_libretro_running_gruvbox_dark[16] = { + 0.1568627f, 0.1568627f, 0.1568627f, 0.75f, + 0.1568627f, 0.1568627f, 0.1568627f, 0.75f, + 0.1568627f, 0.1568627f, 0.1568627f, 1.0f, + 0.1568627f, 0.1568627f, 0.1568627f, 1.0f, +}; + + +static float ozone_border_0_light[16] = COLOR_HEX_TO_FLOAT(0x50EFD9, 1.00); +static float ozone_border_1_light[16] = COLOR_HEX_TO_FLOAT(0x0DB6D5, 1.00); + +static float ozone_border_0_dark[16] = COLOR_HEX_TO_FLOAT(0x198AC6, 1.00); +static float ozone_border_1_dark[16] = COLOR_HEX_TO_FLOAT(0x89F1F2, 1.00); + +static float ozone_border_0_nord[16] = COLOR_HEX_TO_FLOAT(0x5E81AC, 1.0f); +static float ozone_border_1_nord[16] = COLOR_HEX_TO_FLOAT(0x88C0D0, 1.0f); + +static float ozone_border_0_gruvbox_dark[16] = COLOR_HEX_TO_FLOAT(0xAF3A03, 1.0f); +static float ozone_border_1_gruvbox_dark[16] = COLOR_HEX_TO_FLOAT(0xFE8019, 1.0f); + + ozone_theme_t ozone_theme_light = { COLOR_HEX_TO_FLOAT(0xEBEBEB, 1.00), ozone_background_libretro_running_light, diff --git a/menu/drivers/ozone/ozone_theme.h b/menu/drivers/ozone/ozone_theme.h index 97caba5350..df1cac1683 100644 --- a/menu/drivers/ozone/ozone_theme.h +++ b/menu/drivers/ozone/ozone_theme.h @@ -27,144 +27,6 @@ static float ozone_pure_white[16] = { 1.00, 1.00, 1.00, 1.00, }; -static float ozone_backdrop[16] = { - 0.00, 0.00, 0.00, 0.75, - 0.00, 0.00, 0.00, 0.75, - 0.00, 0.00, 0.00, 0.75, - 0.00, 0.00, 0.00, 0.75, -}; - -static float ozone_osk_backdrop[16] = { - 0.00, 0.00, 0.00, 0.15, - 0.00, 0.00, 0.00, 0.15, - 0.00, 0.00, 0.00, 0.15, - 0.00, 0.00, 0.00, 0.15, -}; - -static float ozone_sidebar_background_light[16] = { - 0.94, 0.94, 0.94, 1.00, - 0.94, 0.94, 0.94, 1.00, - 0.94, 0.94, 0.94, 1.00, - 0.94, 0.94, 0.94, 1.00, -}; - -static float ozone_sidebar_gradient_top_light[16] = { - 0.94, 0.94, 0.94, 1.00, - 0.94, 0.94, 0.94, 1.00, - 0.922, 0.922, 0.922, 1.00, - 0.922, 0.922, 0.922, 1.00, -}; - -static float ozone_sidebar_gradient_bottom_light[16] = { - 0.922, 0.922, 0.922, 1.00, - 0.922, 0.922, 0.922, 1.00, - 0.94, 0.94, 0.94, 1.00, - 0.94, 0.94, 0.94, 1.00, -}; - -static float ozone_sidebar_background_dark[16] = { - 0.2, 0.2, 0.2, 1.00, - 0.2, 0.2, 0.2, 1.00, - 0.2, 0.2, 0.2, 1.00, - 0.2, 0.2, 0.2, 1.00, -}; - -static float ozone_sidebar_gradient_top_dark[16] = { - 0.2, 0.2, 0.2, 1.00, - 0.2, 0.2, 0.2, 1.00, - 0.18, 0.18, 0.18, 1.00, - 0.18, 0.18, 0.18, 1.00, -}; - -static float ozone_sidebar_gradient_bottom_dark[16] = { - 0.18, 0.18, 0.18, 1.00, - 0.18, 0.18, 0.18, 1.00, - 0.2, 0.2, 0.2, 1.00, - 0.2, 0.2, 0.2, 1.00, -}; - -static float ozone_sidebar_background_nord[16] = { - 0.2078431f, 0.2352941f, 0.2901961f, 1.0f, - 0.2078431f, 0.2352941f, 0.2901961f, 1.0f, - 0.2078431f, 0.2352941f, 0.2901961f, 1.0f, - 0.2078431f, 0.2352941f, 0.2901961f, 1.0f, -}; - -static float ozone_sidebar_gradient_top_nord[16] = { - 0.2078431f, 0.2352941f, 0.2901961f, 1.0f, - 0.2078431f, 0.2352941f, 0.2901961f, 1.0f, - 0.1921569f, 0.2196078f, 0.2705882f, 0.9f, - 0.1921569f, 0.2196078f, 0.2705882f, 0.9f, -}; - -static float ozone_sidebar_gradient_bottom_nord[16] = { - 0.1921569f, 0.2196078f, 0.2705882f, 0.9f, - 0.1921569f, 0.2196078f, 0.2705882f, 0.9f, - 0.2078431f, 0.2352941f, 0.2901961f, 1.0f, - 0.2078431f, 0.2352941f, 0.2901961f, 1.0f, -}; - -static float ozone_sidebar_background_gruvbox_dark[16] = { - 0.1960784f, 0.1882353f, 0.1843137f, 1.0f, - 0.1960784f, 0.1882353f, 0.1843137f, 1.0f, - 0.1960784f, 0.1882353f, 0.1843137f, 1.0f, - 0.1960784f, 0.1882353f, 0.1843137f, 1.0f, -}; - -static float ozone_sidebar_gradient_top_gruvbox_dark[16] = { - 0.1960784f, 0.1882353f, 0.1843137f, 1.0f, - 0.1960784f, 0.1882353f, 0.1843137f, 1.0f, - 0.1686275f, 0.1686275f, 0.1686275f, 0.9f, - 0.1686275f, 0.1686275f, 0.1686275f, 0.9f, -}; - -static float ozone_sidebar_gradient_bottom_gruvbox_dark[16] = { - 0.1686275f, 0.1686275f, 0.1686275f, 0.9f, - 0.1686275f, 0.1686275f, 0.1686275f, 0.9f, - 0.1960784f, 0.1882353f, 0.1843137f, 1.0f, - 0.1960784f, 0.1882353f, 0.1843137f, 1.0f, -}; - -static float ozone_border_0_light[16] = COLOR_HEX_TO_FLOAT(0x50EFD9, 1.00); -static float ozone_border_1_light[16] = COLOR_HEX_TO_FLOAT(0x0DB6D5, 1.00); - -static float ozone_border_0_dark[16] = COLOR_HEX_TO_FLOAT(0x198AC6, 1.00); -static float ozone_border_1_dark[16] = COLOR_HEX_TO_FLOAT(0x89F1F2, 1.00); - -static float ozone_border_0_nord[16] = COLOR_HEX_TO_FLOAT(0x5E81AC, 1.0f); -static float ozone_border_1_nord[16] = COLOR_HEX_TO_FLOAT(0x88C0D0, 1.0f); - -static float ozone_border_0_gruvbox_dark[16] = COLOR_HEX_TO_FLOAT(0xAF3A03, 1.0f); -static float ozone_border_1_gruvbox_dark[16] = COLOR_HEX_TO_FLOAT(0xFE8019, 1.0f); - -static float ozone_background_libretro_running_light[16] = { - 0.690, 0.690, 0.690, 0.75, - 0.690, 0.690, 0.690, 0.75, - 0.922, 0.922, 0.922, 1.0, - 0.922, 0.922, 0.922, 1.0 -}; - -static float ozone_background_libretro_running_dark[16] = { - 0.176, 0.176, 0.176, 0.75, - 0.176, 0.176, 0.176, 0.75, - 0.178, 0.178, 0.178, 1.0, - 0.178, 0.178, 0.178, 1.0, -}; - -static float ozone_background_libretro_running_nord[16] = { - 0.1803922f, 0.2039216f, 0.2509804f, 0.75f, - 0.1803922f, 0.2039216f, 0.2509804f, 0.75f, - 0.1803922f, 0.2039216f, 0.2509804f, 1.0f, - 0.1803922f, 0.2039216f, 0.2509804f, 1.0f, -}; - -static float ozone_background_libretro_running_gruvbox_dark[16] = { - 0.1568627f, 0.1568627f, 0.1568627f, 0.75f, - 0.1568627f, 0.1568627f, 0.1568627f, 0.75f, - 0.1568627f, 0.1568627f, 0.1568627f, 1.0f, - 0.1568627f, 0.1568627f, 0.1568627f, 1.0f, -}; - typedef struct ozone_theme { /* Background color */ From ec9efcb4b095ef3068ee60947dc4ca944bbcdbf3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 22 May 2020 02:32:36 +0200 Subject: [PATCH 181/192] C89_BUILD buildfix --- managers/cheat_manager.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/managers/cheat_manager.c b/managers/cheat_manager.c index 5a6d111721..6da76ca819 100644 --- a/managers/cheat_manager.c +++ b/managers/cheat_manager.c @@ -371,9 +371,10 @@ static void cheat_manager_new(unsigned size) static void cheat_manager_load_cb_first_pass(char *key, char *value) { - errno = 0; cheat_manager_t *cheat_st = &cheat_manager_state; + errno = 0; + if (string_is_equal(key, "cheats")) { cheat_st->loading_cheat_size = (unsigned)strtoul(value, NULL, 0); From a6030f89fe79e0f08d3c2ebece133144f95ff449 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 22 May 2020 04:56:53 +0200 Subject: [PATCH 182/192] (Discord RPC) Update --- deps/discord-rpc/include/discord_rpc.h | 6 +- deps/discord-rpc/src/backoff.h | 55 +++--- deps/discord-rpc/src/connection.h | 19 +-- deps/discord-rpc/src/discord_register_linux.c | 10 +- deps/discord-rpc/src/discord_register_osx.m | 76 +++++---- deps/discord-rpc/src/discord_register_win.c | 150 ++++++++-------- deps/discord-rpc/src/discord_rpc.cpp | 161 ++++++++---------- deps/discord-rpc/src/rpc_connection.cpp | 4 +- deps/discord-rpc/src/rpc_connection.h | 4 +- 9 files changed, 236 insertions(+), 249 deletions(-) diff --git a/deps/discord-rpc/include/discord_rpc.h b/deps/discord-rpc/include/discord_rpc.h index f66eca87f1..05c562911f 100644 --- a/deps/discord-rpc/include/discord_rpc.h +++ b/deps/discord-rpc/include/discord_rpc.h @@ -53,9 +53,9 @@ typedef struct DiscordEventHandlers #define DISCORD_REPLY_IGNORE 2 DISCORD_EXPORT void Discord_Initialize(const char* applicationId, - DiscordEventHandlers* handlers, - int autoRegister, - const char* optionalSteamId); + DiscordEventHandlers* handlers, + int autoRegister, + const char* optionalSteamId); DISCORD_EXPORT void Discord_Shutdown(void); /* checks for incoming messages, dispatches callbacks */ diff --git a/deps/discord-rpc/src/backoff.h b/deps/discord-rpc/src/backoff.h index db89a50893..a3e736fb7b 100644 --- a/deps/discord-rpc/src/backoff.h +++ b/deps/discord-rpc/src/backoff.h @@ -5,37 +5,36 @@ #include #include -struct Backoff -{ - int64_t minAmount; - int64_t maxAmount; - int64_t current; - int fails; - std::mt19937_64 randGenerator; - std::uniform_real_distribution<> randDistribution; +struct Backoff { + int64_t minAmount; + int64_t maxAmount; + int64_t current; + int fails; + std::mt19937_64 randGenerator; + std::uniform_real_distribution<> randDistribution; - double rand01() { return randDistribution(randGenerator); } + double rand01() { return randDistribution(randGenerator); } - Backoff(int64_t min, int64_t max) + Backoff(int64_t min, int64_t max) : minAmount(min) - , maxAmount(max) - , current(min) - , fails(0) - , randGenerator((uint64_t)time(0)) - { - } + , maxAmount(max) + , current(min) + , fails(0) + , randGenerator((uint64_t)time(0)) + { + } - void reset() - { - fails = 0; - current = minAmount; - } + void reset() + { + fails = 0; + current = minAmount; + } - int64_t nextDelay() - { - ++fails; - int64_t delay = (int64_t)((double)current * 2.0 * rand01()); - current = std::min(current + delay, maxAmount); - return current; - } + int64_t nextDelay() + { + ++fails; + int64_t delay = (int64_t)((double)current * 2.0 * rand01()); + current = std::min(current + delay, maxAmount); + return current; + } }; diff --git a/deps/discord-rpc/src/connection.h b/deps/discord-rpc/src/connection.h index 4502fa2dd4..d3fa231d5e 100644 --- a/deps/discord-rpc/src/connection.h +++ b/deps/discord-rpc/src/connection.h @@ -6,15 +6,14 @@ #include /* not really connectiony, but need per-platform */ -int GetProcessId(void); +int GetProcessId(); -struct BaseConnection -{ - static BaseConnection* Create(); - static void Destroy(BaseConnection*&); - bool isOpen{false}; - bool Open(); - bool Close(); - bool Write(const void* data, size_t length); - bool Read(void* data, size_t length); +struct BaseConnection { + static BaseConnection* Create(); + static void Destroy(BaseConnection*&); + bool isOpen{false}; + bool Open(); + bool Close(); + bool Write(const void* data, size_t length); + bool Read(void* data, size_t length); }; diff --git a/deps/discord-rpc/src/discord_register_linux.c b/deps/discord-rpc/src/discord_register_linux.c index 7fc42ebd0d..8eec618cb3 100644 --- a/deps/discord-rpc/src/discord_register_linux.c +++ b/deps/discord-rpc/src/discord_register_linux.c @@ -1,3 +1,5 @@ +#include "discord_rpc.h" +#include "discord_register.h" #include #include @@ -11,11 +13,9 @@ #include #include -#include - /* we want to register games so we can run them from * Discord client as discord-:// */ -void Discord_Register(const char *applicationId, const char *command) +void Discord_Register(const char* applicationId, const char* command) { FILE* fp; int fileLen; @@ -82,7 +82,9 @@ void Discord_Register(const char *applicationId, const char *command) fprintf(stderr, "Failed to register mime handler\n"); } -void Discord_RegisterSteamGame(const char *applicationId, const char *steamId) +void Discord_RegisterSteamGame( + const char* applicationId, + const char* steamId) { char command[256]; snprintf(command, sizeof(command), "xdg-open steam://rungameid/%s", steamId); diff --git a/deps/discord-rpc/src/discord_register_osx.m b/deps/discord-rpc/src/discord_register_osx.m index 0973e15108..4975565296 100644 --- a/deps/discord-rpc/src/discord_register_osx.m +++ b/deps/discord-rpc/src/discord_register_osx.m @@ -3,6 +3,8 @@ #import +#include "../include/discord_register.h" + static void RegisterCommand(const char* applicationId, const char* command) { /* There does not appear to be a way to register arbitrary commands on OSX, so instead we'll save the command @@ -29,52 +31,54 @@ static void RegisterCommand(const char* applicationId, const char* command) static void RegisterURL(const char* applicationId) { - char url[256]; - snprintf(url, sizeof(url), "discord-%s", applicationId); - CFStringRef cfURL = CFStringCreateWithCString(NULL, url, kCFStringEncodingUTF8); - NSString* myBundleId = [[NSBundle mainBundle] bundleIdentifier]; + char url[256]; + snprintf(url, sizeof(url), "discord-%s", applicationId); + CFStringRef cfURL = CFStringCreateWithCString(NULL, url, kCFStringEncodingUTF8); + NSString* myBundleId = [[NSBundle mainBundle] bundleIdentifier]; - if (!myBundleId) - { - fprintf(stderr, "No bundle id found\n"); - return; - } + if (!myBundleId) + { + fprintf(stderr, "No bundle id found\n"); + return; + } - NSURL* myURL = [[NSBundle mainBundle] bundleURL]; - if (!myURL) - { - fprintf(stderr, "No bundle url found\n"); - return; - } + NSURL* myURL = [[NSBundle mainBundle] bundleURL]; + if (!myURL) + { + fprintf(stderr, "No bundle url found\n"); + return; + } - OSStatus status = LSSetDefaultHandlerForURLScheme(cfURL, (__bridge CFStringRef)myBundleId); - if (status != noErr) - { - fprintf(stderr, "Error in LSSetDefaultHandlerForURLScheme: %d\n", (int)status); - return; - } + OSStatus status = LSSetDefaultHandlerForURLScheme(cfURL, (__bridge CFStringRef)myBundleId); + if (status != noErr) + { + fprintf(stderr, "Error in LSSetDefaultHandlerForURLScheme: %d\n", (int)status); + return; + } - status = LSRegisterURL((__bridge CFURLRef)myURL, true); - if (status != noErr) - fprintf(stderr, "Error in LSRegisterURL: %d\n", (int)status); + status = LSRegisterURL((__bridge CFURLRef)myURL, true); + if (status != noErr) + { + fprintf(stderr, "Error in LSRegisterURL: %d\n", (int)status); + } } void Discord_Register(const char* applicationId, const char* command) { - if (command) - RegisterCommand(applicationId, command); - else - { - /* RAII Lite */ - @autoreleasepool { - RegisterURL(applicationId); - } - } + if (command) + RegisterCommand(applicationId, command); + else + { + /* RAII Lite */ + @autoreleasepool { + RegisterURL(applicationId); + } + } } void Discord_RegisterSteamGame(const char* applicationId, const char* steamId) { - char command[256]; - snprintf(command, sizeof(command), "steam://rungameid/%s", steamId); - Discord_Register(applicationId, command); + char command[256]; + snprintf(command, sizeof(command), "steam://rungameid/%s", steamId); + Discord_Register(applicationId, command); } diff --git a/deps/discord-rpc/src/discord_register_win.c b/deps/discord-rpc/src/discord_register_win.c index 992ff58ce3..1a03603b80 100644 --- a/deps/discord-rpc/src/discord_register_win.c +++ b/deps/discord-rpc/src/discord_register_win.c @@ -1,4 +1,5 @@ #include "discord_rpc.h" +#include "discord_register.h" #define WIN32_LEAN_AND_MEAN #define NOMCX @@ -52,99 +53,99 @@ static LSTATUS regset(HKEY hkey, const void* data, DWORD len) { - LSTATUS ret; - HKEY htkey = hkey, hsubkey = NULL; - if (subkey && subkey[0]) - { - if ((ret = RegCreateKeyExW(hkey, subkey, 0, 0, 0, KEY_ALL_ACCESS, 0, &hsubkey, 0)) != + HKEY htkey = hkey, hsubkey = NULL; + LSTATUS ret; + if (subkey && subkey[0]) + { + if ((ret = RegCreateKeyExW(hkey, subkey, 0, 0, 0, KEY_ALL_ACCESS, 0, &hsubkey, 0)) != ERROR_SUCCESS) - return ret; - htkey = hsubkey; - } - ret = RegSetValueExW(htkey, name, 0, type, (const BYTE*)data, len); - if (hsubkey && hsubkey != hkey) - RegCloseKey(hsubkey); - return ret; + return ret; + htkey = hsubkey; + } + ret = RegSetValueExW(htkey, name, 0, type, (const BYTE*)data, len); + if (hsubkey && hsubkey != hkey) + RegCloseKey(hsubkey); + return ret; } static void Discord_RegisterW( const wchar_t* applicationId, const wchar_t* command) { - /* https://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx - * we want to register games so we can run them as discord-:// - * Update the HKEY_CURRENT_USER, because it doesn't seem to require special permissions. */ + /* https://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx + * we want to register games so we can run them as discord-:// + * Update the HKEY_CURRENT_USER, because it doesn't seem to require special permissions. */ - DWORD len; - LSTATUS result; - wchar_t urlProtocol = 0; - wchar_t keyName[256]; - wchar_t protocolName[64]; - wchar_t protocolDescription[128]; - wchar_t exeFilePath[MAX_PATH]; - DWORD exeLen = GetModuleFileNameW(NULL, exeFilePath, MAX_PATH); - wchar_t openCommand[1024]; + DWORD len; + LSTATUS result; + wchar_t urlProtocol = 0; + wchar_t keyName[256]; + wchar_t protocolName[64]; + wchar_t protocolDescription[128]; + wchar_t exeFilePath[MAX_PATH]; + DWORD exeLen = GetModuleFileNameW(NULL, exeFilePath, MAX_PATH); + wchar_t openCommand[1024]; - if (command && command[0]) - StringCbPrintfW(openCommand, sizeof(openCommand), L"%S", command); - else - StringCbPrintfW(openCommand, sizeof(openCommand), L"%S", exeFilePath); + if (command && command[0]) + StringCbPrintfW(openCommand, sizeof(openCommand), L"%S", command); + else + StringCbPrintfW(openCommand, sizeof(openCommand), L"%S", exeFilePath); - StringCbPrintfW(protocolName, sizeof(protocolName), - L"discord-%S", applicationId); - StringCbPrintfW( - protocolDescription, sizeof(protocolDescription), - L"URL:Run game %S protocol", applicationId); - StringCbPrintfW(keyName, sizeof(keyName), L"Software\\Classes\\%S", protocolName); - HKEY key; - LSTATUS status = + StringCbPrintfW(protocolName, sizeof(protocolName), + L"discord-%S", applicationId); + StringCbPrintfW( + protocolDescription, sizeof(protocolDescription), + L"URL:Run game %S protocol", applicationId); + StringCbPrintfW(keyName, sizeof(keyName), L"Software\\Classes\\%S", protocolName); + HKEY key; + LSTATUS status = RegCreateKeyExW(HKEY_CURRENT_USER, keyName, 0, NULL, 0, KEY_WRITE, NULL, &key, NULL); - if (status != ERROR_SUCCESS) - { - fprintf(stderr, "Error creating key\n"); - return; - } - len = (DWORD)lstrlenW(protocolDescription) + 1; - result = + if (status != ERROR_SUCCESS) + { + fprintf(stderr, "Error creating key\n"); + return; + } + len = (DWORD)lstrlenW(protocolDescription) + 1; + result = RegSetKeyValueW(key, NULL, NULL, REG_SZ, protocolDescription, len * sizeof(wchar_t)); - if (FAILED(result)) - fprintf(stderr, "Error writing description\n"); + if (FAILED(result)) { + fprintf(stderr, "Error writing description\n"); + } - len = (DWORD)lstrlenW(protocolDescription) + 1; - result = RegSetKeyValueW(key, NULL, L"URL Protocol", REG_SZ, &urlProtocol, sizeof(wchar_t)); - if (FAILED(result)) - fprintf(stderr, "Error writing description\n"); + len = (DWORD)lstrlenW(protocolDescription) + 1; + result = RegSetKeyValueW(key, NULL, L"URL Protocol", REG_SZ, &urlProtocol, sizeof(wchar_t)); + if (FAILED(result)) + fprintf(stderr, "Error writing description\n"); - result = RegSetKeyValueW( - key, L"DefaultIcon", NULL, REG_SZ, exeFilePath, (exeLen + 1) * sizeof(wchar_t)); - if (FAILED(result)) - fprintf(stderr, "Error writing icon\n"); + result = RegSetKeyValueW( + key, L"DefaultIcon", NULL, REG_SZ, exeFilePath, (exeLen + 1) * sizeof(wchar_t)); + if (FAILED(result)) + fprintf(stderr, "Error writing icon\n"); - len = (DWORD)lstrlenW(openCommand) + 1; - result = RegSetKeyValueW( - key, L"shell\\open\\command", NULL, REG_SZ, openCommand, len * sizeof(wchar_t)); - if (FAILED(result)) - fprintf(stderr, "Error writing command\n"); - RegCloseKey(key); + len = (DWORD)lstrlenW(openCommand) + 1; + result = RegSetKeyValueW( + key, L"shell\\open\\command", NULL, REG_SZ, openCommand, len * sizeof(wchar_t)); + if (FAILED(result)) + fprintf(stderr, "Error writing command\n"); + RegCloseKey(key); } void Discord_Register(const char* applicationId, const char* command) { - wchar_t appId[32]; - wchar_t openCommand[1024]; - const wchar_t* wcommand = NULL; + wchar_t openCommand[1024]; + const wchar_t* wcommand = NULL; + wchar_t appId[32]; - MultiByteToWideChar(CP_UTF8, 0, applicationId, -1, appId, 32); + MultiByteToWideChar(CP_UTF8, 0, applicationId, -1, appId, 32); + if (command && command[0]) + { + const int commandBufferLen = + sizeof(openCommand) / sizeof(*openCommand); + MultiByteToWideChar(CP_UTF8, 0, command, -1, + openCommand, commandBufferLen); + wcommand = openCommand; + } - if (command && command[0]) - { - const int commandBufferLen = - sizeof(openCommand) / sizeof(*openCommand); - MultiByteToWideChar(CP_UTF8, 0, command, -1, - openCommand, commandBufferLen); - wcommand = openCommand; - } - - Discord_RegisterW(appId, wcommand); + Discord_RegisterW(appId, wcommand); } void Discord_RegisterSteamGame( @@ -171,8 +172,7 @@ void Discord_RegisterSteamGame( status = RegQueryValueExW(key, L"SteamExe", NULL, NULL, (BYTE*)steamPath, &pathBytes); RegCloseKey(key); - if (status != ERROR_SUCCESS || pathBytes < 1) - { + if (status != ERROR_SUCCESS || pathBytes < 1) { fprintf(stderr, "Error reading SteamExe key\n"); return; } diff --git a/deps/discord-rpc/src/discord_rpc.cpp b/deps/discord-rpc/src/discord_rpc.cpp index 3f430bed16..f430746e83 100644 --- a/deps/discord-rpc/src/discord_rpc.cpp +++ b/deps/discord-rpc/src/discord_rpc.cpp @@ -1,7 +1,7 @@ -#include #include "discord_rpc.h" #include "backoff.h" +#include "discord_register.h" #include "msg_queue.h" #include "rpc_connection.h" #include "serialization.h" @@ -15,23 +15,14 @@ #include #endif - -/* Forward declarations */ -#if defined(__cplusplus) && !defined(CXX_BUILD) -extern "C" { -#endif - -void Discord_Register(const char *a, const char *b); -void Discord_RegisterSteamGame(const char *a, const char *b); - -#if defined(__cplusplus) && !defined(CXX_BUILD) -} -#endif +constexpr size_t MaxMessageSize{16 * 1024}; +constexpr size_t MessageQueueSize{8}; +constexpr size_t JoinQueueSize{8}; struct QueuedMessage { size_t length; - char buffer[16384]; + char buffer[MaxMessageSize]; void Copy(const QueuedMessage& other) { @@ -59,32 +50,25 @@ struct User * from future changes in these sizes */ }; -static int Pid{0}; -static int Nonce{1}; -static int LastErrorCode{0}; -static int LastDisconnectErrorCode{0}; - -static char JoinGameSecret[256]; -static char SpectateGameSecret[256]; -static char LastErrorMessage[256]; -static char LastDisconnectErrorMessage[256]; - static RpcConnection* Connection{nullptr}; - static DiscordEventHandlers QueuedHandlers{}; static DiscordEventHandlers Handlers{}; - static std::atomic_bool WasJustConnected{false}; static std::atomic_bool WasJustDisconnected{false}; static std::atomic_bool GotErrorMessage{false}; static std::atomic_bool WasJoinGame{false}; static std::atomic_bool WasSpectateGame{false}; - +static char JoinGameSecret[256]; +static char SpectateGameSecret[256]; +static int LastErrorCode{0}; +static char LastErrorMessage[256]; +static int LastDisconnectErrorCode{0}; +static char LastDisconnectErrorMessage[256]; static std::mutex PresenceMutex; static std::mutex HandlerMutex; static QueuedMessage QueuedPresence{}; -static MsgQueue SendQueue; -static MsgQueue JoinAskQueue; +static MsgQueue SendQueue; +static MsgQueue JoinAskQueue; static User connectedUser; /* We want to auto connect, and retry on failure, @@ -92,57 +76,57 @@ static User connectedUser; * backoff from 0.5 seconds to 1 minute */ static Backoff ReconnectTimeMs(500, 60 * 1000); static auto NextConnect = std::chrono::system_clock::now(); +static int Pid{0}; +static int Nonce{1}; #ifndef DISCORD_DISABLE_IO_THREAD static void Discord_UpdateConnection(void); -class IoThreadHolder -{ - private: - std::atomic_bool keepRunning{true}; - std::mutex waitForIOMutex; - std::condition_variable waitForIOActivity; - std::thread ioThread; +class IoThreadHolder { +private: + std::atomic_bool keepRunning{true}; + std::mutex waitForIOMutex; + std::condition_variable waitForIOActivity; + std::thread ioThread; - public: - void Start() - { - keepRunning.store(true); - ioThread = std::thread([&]() { - const std::chrono::duration maxWait{500LL}; - Discord_UpdateConnection(); - while (keepRunning.load()) { - std::unique_lock lock(waitForIOMutex); - waitForIOActivity.wait_for(lock, maxWait); - Discord_UpdateConnection(); - } - }); - } +public: + void Start() + { + keepRunning.store(true); + ioThread = std::thread([&]() { + const std::chrono::duration maxWait{500LL}; + Discord_UpdateConnection(); + while (keepRunning.load()) { + std::unique_lock lock(waitForIOMutex); + waitForIOActivity.wait_for(lock, maxWait); + Discord_UpdateConnection(); + } + }); + } - void Notify() { waitForIOActivity.notify_all(); } + void Notify() { waitForIOActivity.notify_all(); } - void Stop() - { - keepRunning.exchange(false); - Notify(); - if (ioThread.joinable()) + void Stop() + { + keepRunning.exchange(false); + Notify(); + if (ioThread.joinable()) ioThread.join(); - } + } - ~IoThreadHolder() { Stop(); } + ~IoThreadHolder() { Stop(); } }; #else -class IoThreadHolder -{ - public: - void Start() {} - void Stop() {} - void Notify() {} +class IoThreadHolder { +public: + void Start() {} + void Stop() {} + void Notify() {} }; #endif /* DISCORD_DISABLE_IO_THREAD */ static IoThreadHolder* IoThread{nullptr}; -static void UpdateReconnectTime(void) +static void UpdateReconnectTime() { NextConnect = std::chrono::system_clock::now() + std::chrono::duration{ReconnectTimeMs.nextDelay()}; @@ -176,18 +160,18 @@ static void Discord_UpdateConnection(void) if (!Connection->Read(message)) break; - const char *evtName = GetStrMember(&message, "evt"); - const char *nonce = GetStrMember(&message, "nonce"); + const char* evtName = GetStrMember(&message, "evt"); + const char* nonce = GetStrMember(&message, "nonce"); if (nonce) { /* in responses only -- * should use to match up response when needed. */ - if (evtName && !strcmp(evtName, "ERROR")) + if (evtName && strcmp(evtName, "ERROR") == 0) { - JsonValue *data = GetObjMember(&message, "data"); - LastErrorCode = GetIntMember(data, "code"); + auto data = GetObjMember(&message, "data"); + LastErrorCode = GetIntMember(data, "code"); StringCopy(LastErrorMessage, GetStrMember(data, "message", "")); GotErrorMessage.store(true); } @@ -198,40 +182,39 @@ static void Discord_UpdateConnection(void) if (!evtName) continue; - JsonValue *data = GetObjMember(&message, "data"); + auto data = GetObjMember(&message, "data"); - if (!strcmp(evtName, "ACTIVITY_JOIN")) + if (strcmp(evtName, "ACTIVITY_JOIN") == 0) { - const char *secret = GetStrMember(data, "secret"); + auto secret = GetStrMember(data, "secret"); if (secret) { StringCopy(JoinGameSecret, secret); WasJoinGame.store(true); } } - else if (!strcmp(evtName, "ACTIVITY_SPECTATE")) + else if (strcmp(evtName, "ACTIVITY_SPECTATE") == 0) { - const char *secret = GetStrMember(data, "secret"); + auto secret = GetStrMember(data, "secret"); if (secret) { StringCopy(SpectateGameSecret, secret); WasSpectateGame.store(true); } } - else if (!strcmp(evtName, "ACTIVITY_JOIN_REQUEST")) + else if (strcmp(evtName, "ACTIVITY_JOIN_REQUEST") == 0) { - JsonValue *user = GetObjMember(data, "user"); - const char *userId = GetStrMember(user, "id"); - const char *username = GetStrMember(user, "username"); - const char *avatar = GetStrMember(user, "avatar"); - auto joinReq = JoinAskQueue.GetNextAddMessage(); + auto user = GetObjMember(data, "user"); + auto userId = GetStrMember(user, "id"); + auto username = GetStrMember(user, "username"); + auto avatar = GetStrMember(user, "avatar"); + auto joinReq = JoinAskQueue.GetNextAddMessage(); if (userId && username && joinReq) { StringCopy(joinReq->userId, userId); StringCopy(joinReq->username, username); - const char *discriminator = GetStrMember(user, - "discriminator"); + auto discriminator = GetStrMember(user, "discriminator"); if (discriminator) StringCopy(joinReq->discriminator, discriminator); if (avatar) @@ -338,16 +321,16 @@ extern "C" DISCORD_EXPORT void Discord_Initialize( Connection->onConnect = [](JsonDocument& readyMessage) { Discord_UpdateHandlers(&QueuedHandlers); - JsonValue *data = GetObjMember(&readyMessage, "data"); - JsonValue *user = GetObjMember(data, "user"); - const char *userId = GetStrMember(user, "id"); - const char *username = GetStrMember(user, "username"); - const char *avatar = GetStrMember(user, "avatar"); + auto data = GetObjMember(&readyMessage, "data"); + auto user = GetObjMember(data, "user"); + auto userId = GetStrMember(user, "id"); + auto username = GetStrMember(user, "username"); + auto avatar = GetStrMember(user, "avatar"); if (userId && username) { StringCopy(connectedUser.userId, userId); StringCopy(connectedUser.username, username); - const char *discriminator = GetStrMember(user, "discriminator"); + auto discriminator = GetStrMember(user, "discriminator"); if (discriminator) StringCopy(connectedUser.discriminator, discriminator); if (avatar) diff --git a/deps/discord-rpc/src/rpc_connection.cpp b/deps/discord-rpc/src/rpc_connection.cpp index 6904b32249..f93cb66278 100644 --- a/deps/discord-rpc/src/rpc_connection.cpp +++ b/deps/discord-rpc/src/rpc_connection.cpp @@ -36,8 +36,8 @@ void RpcConnection::Open() JsonDocument message; if (Read(message)) { - const char *cmd = GetStrMember(&message, "cmd"); - const char *evt = GetStrMember(&message, "evt"); + auto cmd = GetStrMember(&message, "cmd"); + auto evt = GetStrMember(&message, "evt"); if (cmd && evt && !strcmp(cmd, "DISPATCH") && !strcmp(evt, "READY")) diff --git a/deps/discord-rpc/src/rpc_connection.h b/deps/discord-rpc/src/rpc_connection.h index 6fb69c9ee0..a4ccb82638 100644 --- a/deps/discord-rpc/src/rpc_connection.h +++ b/deps/discord-rpc/src/rpc_connection.h @@ -5,7 +5,7 @@ /* I took this from the buffer size libuv uses for named pipes; * I suspect ours would usually be much smaller. */ -#define MAX_RPC_FRAMESIZE 65536 +constexpr size_t MaxRpcFrameSize = 64 * 1024; struct RpcConnection { @@ -33,7 +33,7 @@ struct RpcConnection struct MessageFrame : public MessageFrameHeader { - char message[MAX_RPC_FRAMESIZE - sizeof(MessageFrameHeader)]; + char message[MaxRpcFrameSize - sizeof(MessageFrameHeader)]; }; enum class State : uint32_t From f2bb7e29a4938064eb8d253af87210ae90b9906f Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 22 May 2020 05:37:01 +0200 Subject: [PATCH 183/192] Revert "(Discord RPC) Update" This reverts commit a6030f89fe79e0f08d3c2ebece133144f95ff449. --- deps/discord-rpc/include/discord_rpc.h | 6 +- deps/discord-rpc/src/backoff.h | 55 +++--- deps/discord-rpc/src/connection.h | 19 ++- deps/discord-rpc/src/discord_register_linux.c | 10 +- deps/discord-rpc/src/discord_register_osx.m | 76 ++++----- deps/discord-rpc/src/discord_register_win.c | 150 ++++++++-------- deps/discord-rpc/src/discord_rpc.cpp | 161 ++++++++++-------- deps/discord-rpc/src/rpc_connection.cpp | 4 +- deps/discord-rpc/src/rpc_connection.h | 4 +- 9 files changed, 249 insertions(+), 236 deletions(-) diff --git a/deps/discord-rpc/include/discord_rpc.h b/deps/discord-rpc/include/discord_rpc.h index 05c562911f..f66eca87f1 100644 --- a/deps/discord-rpc/include/discord_rpc.h +++ b/deps/discord-rpc/include/discord_rpc.h @@ -53,9 +53,9 @@ typedef struct DiscordEventHandlers #define DISCORD_REPLY_IGNORE 2 DISCORD_EXPORT void Discord_Initialize(const char* applicationId, - DiscordEventHandlers* handlers, - int autoRegister, - const char* optionalSteamId); + DiscordEventHandlers* handlers, + int autoRegister, + const char* optionalSteamId); DISCORD_EXPORT void Discord_Shutdown(void); /* checks for incoming messages, dispatches callbacks */ diff --git a/deps/discord-rpc/src/backoff.h b/deps/discord-rpc/src/backoff.h index a3e736fb7b..db89a50893 100644 --- a/deps/discord-rpc/src/backoff.h +++ b/deps/discord-rpc/src/backoff.h @@ -5,36 +5,37 @@ #include #include -struct Backoff { - int64_t minAmount; - int64_t maxAmount; - int64_t current; - int fails; - std::mt19937_64 randGenerator; - std::uniform_real_distribution<> randDistribution; +struct Backoff +{ + int64_t minAmount; + int64_t maxAmount; + int64_t current; + int fails; + std::mt19937_64 randGenerator; + std::uniform_real_distribution<> randDistribution; - double rand01() { return randDistribution(randGenerator); } + double rand01() { return randDistribution(randGenerator); } - Backoff(int64_t min, int64_t max) + Backoff(int64_t min, int64_t max) : minAmount(min) - , maxAmount(max) - , current(min) - , fails(0) - , randGenerator((uint64_t)time(0)) - { - } + , maxAmount(max) + , current(min) + , fails(0) + , randGenerator((uint64_t)time(0)) + { + } - void reset() - { - fails = 0; - current = minAmount; - } + void reset() + { + fails = 0; + current = minAmount; + } - int64_t nextDelay() - { - ++fails; - int64_t delay = (int64_t)((double)current * 2.0 * rand01()); - current = std::min(current + delay, maxAmount); - return current; - } + int64_t nextDelay() + { + ++fails; + int64_t delay = (int64_t)((double)current * 2.0 * rand01()); + current = std::min(current + delay, maxAmount); + return current; + } }; diff --git a/deps/discord-rpc/src/connection.h b/deps/discord-rpc/src/connection.h index d3fa231d5e..4502fa2dd4 100644 --- a/deps/discord-rpc/src/connection.h +++ b/deps/discord-rpc/src/connection.h @@ -6,14 +6,15 @@ #include /* not really connectiony, but need per-platform */ -int GetProcessId(); +int GetProcessId(void); -struct BaseConnection { - static BaseConnection* Create(); - static void Destroy(BaseConnection*&); - bool isOpen{false}; - bool Open(); - bool Close(); - bool Write(const void* data, size_t length); - bool Read(void* data, size_t length); +struct BaseConnection +{ + static BaseConnection* Create(); + static void Destroy(BaseConnection*&); + bool isOpen{false}; + bool Open(); + bool Close(); + bool Write(const void* data, size_t length); + bool Read(void* data, size_t length); }; diff --git a/deps/discord-rpc/src/discord_register_linux.c b/deps/discord-rpc/src/discord_register_linux.c index 8eec618cb3..7fc42ebd0d 100644 --- a/deps/discord-rpc/src/discord_register_linux.c +++ b/deps/discord-rpc/src/discord_register_linux.c @@ -1,5 +1,3 @@ -#include "discord_rpc.h" -#include "discord_register.h" #include #include @@ -13,9 +11,11 @@ #include #include +#include + /* we want to register games so we can run them from * Discord client as discord-:// */ -void Discord_Register(const char* applicationId, const char* command) +void Discord_Register(const char *applicationId, const char *command) { FILE* fp; int fileLen; @@ -82,9 +82,7 @@ void Discord_Register(const char* applicationId, const char* command) fprintf(stderr, "Failed to register mime handler\n"); } -void Discord_RegisterSteamGame( - const char* applicationId, - const char* steamId) +void Discord_RegisterSteamGame(const char *applicationId, const char *steamId) { char command[256]; snprintf(command, sizeof(command), "xdg-open steam://rungameid/%s", steamId); diff --git a/deps/discord-rpc/src/discord_register_osx.m b/deps/discord-rpc/src/discord_register_osx.m index 4975565296..0973e15108 100644 --- a/deps/discord-rpc/src/discord_register_osx.m +++ b/deps/discord-rpc/src/discord_register_osx.m @@ -3,8 +3,6 @@ #import -#include "../include/discord_register.h" - static void RegisterCommand(const char* applicationId, const char* command) { /* There does not appear to be a way to register arbitrary commands on OSX, so instead we'll save the command @@ -31,54 +29,52 @@ static void RegisterCommand(const char* applicationId, const char* command) static void RegisterURL(const char* applicationId) { - char url[256]; - snprintf(url, sizeof(url), "discord-%s", applicationId); - CFStringRef cfURL = CFStringCreateWithCString(NULL, url, kCFStringEncodingUTF8); - NSString* myBundleId = [[NSBundle mainBundle] bundleIdentifier]; + char url[256]; + snprintf(url, sizeof(url), "discord-%s", applicationId); + CFStringRef cfURL = CFStringCreateWithCString(NULL, url, kCFStringEncodingUTF8); + NSString* myBundleId = [[NSBundle mainBundle] bundleIdentifier]; - if (!myBundleId) - { - fprintf(stderr, "No bundle id found\n"); - return; - } + if (!myBundleId) + { + fprintf(stderr, "No bundle id found\n"); + return; + } - NSURL* myURL = [[NSBundle mainBundle] bundleURL]; - if (!myURL) - { - fprintf(stderr, "No bundle url found\n"); - return; - } + NSURL* myURL = [[NSBundle mainBundle] bundleURL]; + if (!myURL) + { + fprintf(stderr, "No bundle url found\n"); + return; + } - OSStatus status = LSSetDefaultHandlerForURLScheme(cfURL, (__bridge CFStringRef)myBundleId); - if (status != noErr) - { - fprintf(stderr, "Error in LSSetDefaultHandlerForURLScheme: %d\n", (int)status); - return; - } + OSStatus status = LSSetDefaultHandlerForURLScheme(cfURL, (__bridge CFStringRef)myBundleId); + if (status != noErr) + { + fprintf(stderr, "Error in LSSetDefaultHandlerForURLScheme: %d\n", (int)status); + return; + } - status = LSRegisterURL((__bridge CFURLRef)myURL, true); - if (status != noErr) - { - fprintf(stderr, "Error in LSRegisterURL: %d\n", (int)status); - } + status = LSRegisterURL((__bridge CFURLRef)myURL, true); + if (status != noErr) + fprintf(stderr, "Error in LSRegisterURL: %d\n", (int)status); } void Discord_Register(const char* applicationId, const char* command) { - if (command) - RegisterCommand(applicationId, command); - else - { - /* RAII Lite */ - @autoreleasepool { - RegisterURL(applicationId); - } - } + if (command) + RegisterCommand(applicationId, command); + else + { + /* RAII Lite */ + @autoreleasepool { + RegisterURL(applicationId); + } + } } void Discord_RegisterSteamGame(const char* applicationId, const char* steamId) { - char command[256]; - snprintf(command, sizeof(command), "steam://rungameid/%s", steamId); - Discord_Register(applicationId, command); + char command[256]; + snprintf(command, sizeof(command), "steam://rungameid/%s", steamId); + Discord_Register(applicationId, command); } diff --git a/deps/discord-rpc/src/discord_register_win.c b/deps/discord-rpc/src/discord_register_win.c index 1a03603b80..992ff58ce3 100644 --- a/deps/discord-rpc/src/discord_register_win.c +++ b/deps/discord-rpc/src/discord_register_win.c @@ -1,5 +1,4 @@ #include "discord_rpc.h" -#include "discord_register.h" #define WIN32_LEAN_AND_MEAN #define NOMCX @@ -53,99 +52,99 @@ static LSTATUS regset(HKEY hkey, const void* data, DWORD len) { - HKEY htkey = hkey, hsubkey = NULL; - LSTATUS ret; - if (subkey && subkey[0]) - { - if ((ret = RegCreateKeyExW(hkey, subkey, 0, 0, 0, KEY_ALL_ACCESS, 0, &hsubkey, 0)) != + LSTATUS ret; + HKEY htkey = hkey, hsubkey = NULL; + if (subkey && subkey[0]) + { + if ((ret = RegCreateKeyExW(hkey, subkey, 0, 0, 0, KEY_ALL_ACCESS, 0, &hsubkey, 0)) != ERROR_SUCCESS) - return ret; - htkey = hsubkey; - } - ret = RegSetValueExW(htkey, name, 0, type, (const BYTE*)data, len); - if (hsubkey && hsubkey != hkey) - RegCloseKey(hsubkey); - return ret; + return ret; + htkey = hsubkey; + } + ret = RegSetValueExW(htkey, name, 0, type, (const BYTE*)data, len); + if (hsubkey && hsubkey != hkey) + RegCloseKey(hsubkey); + return ret; } static void Discord_RegisterW( const wchar_t* applicationId, const wchar_t* command) { - /* https://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx - * we want to register games so we can run them as discord-:// - * Update the HKEY_CURRENT_USER, because it doesn't seem to require special permissions. */ + /* https://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx + * we want to register games so we can run them as discord-:// + * Update the HKEY_CURRENT_USER, because it doesn't seem to require special permissions. */ - DWORD len; - LSTATUS result; - wchar_t urlProtocol = 0; - wchar_t keyName[256]; - wchar_t protocolName[64]; - wchar_t protocolDescription[128]; - wchar_t exeFilePath[MAX_PATH]; - DWORD exeLen = GetModuleFileNameW(NULL, exeFilePath, MAX_PATH); - wchar_t openCommand[1024]; + DWORD len; + LSTATUS result; + wchar_t urlProtocol = 0; + wchar_t keyName[256]; + wchar_t protocolName[64]; + wchar_t protocolDescription[128]; + wchar_t exeFilePath[MAX_PATH]; + DWORD exeLen = GetModuleFileNameW(NULL, exeFilePath, MAX_PATH); + wchar_t openCommand[1024]; - if (command && command[0]) - StringCbPrintfW(openCommand, sizeof(openCommand), L"%S", command); - else - StringCbPrintfW(openCommand, sizeof(openCommand), L"%S", exeFilePath); + if (command && command[0]) + StringCbPrintfW(openCommand, sizeof(openCommand), L"%S", command); + else + StringCbPrintfW(openCommand, sizeof(openCommand), L"%S", exeFilePath); - StringCbPrintfW(protocolName, sizeof(protocolName), - L"discord-%S", applicationId); - StringCbPrintfW( - protocolDescription, sizeof(protocolDescription), - L"URL:Run game %S protocol", applicationId); - StringCbPrintfW(keyName, sizeof(keyName), L"Software\\Classes\\%S", protocolName); - HKEY key; - LSTATUS status = + StringCbPrintfW(protocolName, sizeof(protocolName), + L"discord-%S", applicationId); + StringCbPrintfW( + protocolDescription, sizeof(protocolDescription), + L"URL:Run game %S protocol", applicationId); + StringCbPrintfW(keyName, sizeof(keyName), L"Software\\Classes\\%S", protocolName); + HKEY key; + LSTATUS status = RegCreateKeyExW(HKEY_CURRENT_USER, keyName, 0, NULL, 0, KEY_WRITE, NULL, &key, NULL); - if (status != ERROR_SUCCESS) - { - fprintf(stderr, "Error creating key\n"); - return; - } - len = (DWORD)lstrlenW(protocolDescription) + 1; - result = + if (status != ERROR_SUCCESS) + { + fprintf(stderr, "Error creating key\n"); + return; + } + len = (DWORD)lstrlenW(protocolDescription) + 1; + result = RegSetKeyValueW(key, NULL, NULL, REG_SZ, protocolDescription, len * sizeof(wchar_t)); - if (FAILED(result)) { - fprintf(stderr, "Error writing description\n"); - } + if (FAILED(result)) + fprintf(stderr, "Error writing description\n"); - len = (DWORD)lstrlenW(protocolDescription) + 1; - result = RegSetKeyValueW(key, NULL, L"URL Protocol", REG_SZ, &urlProtocol, sizeof(wchar_t)); - if (FAILED(result)) - fprintf(stderr, "Error writing description\n"); + len = (DWORD)lstrlenW(protocolDescription) + 1; + result = RegSetKeyValueW(key, NULL, L"URL Protocol", REG_SZ, &urlProtocol, sizeof(wchar_t)); + if (FAILED(result)) + fprintf(stderr, "Error writing description\n"); - result = RegSetKeyValueW( - key, L"DefaultIcon", NULL, REG_SZ, exeFilePath, (exeLen + 1) * sizeof(wchar_t)); - if (FAILED(result)) - fprintf(stderr, "Error writing icon\n"); + result = RegSetKeyValueW( + key, L"DefaultIcon", NULL, REG_SZ, exeFilePath, (exeLen + 1) * sizeof(wchar_t)); + if (FAILED(result)) + fprintf(stderr, "Error writing icon\n"); - len = (DWORD)lstrlenW(openCommand) + 1; - result = RegSetKeyValueW( - key, L"shell\\open\\command", NULL, REG_SZ, openCommand, len * sizeof(wchar_t)); - if (FAILED(result)) - fprintf(stderr, "Error writing command\n"); - RegCloseKey(key); + len = (DWORD)lstrlenW(openCommand) + 1; + result = RegSetKeyValueW( + key, L"shell\\open\\command", NULL, REG_SZ, openCommand, len * sizeof(wchar_t)); + if (FAILED(result)) + fprintf(stderr, "Error writing command\n"); + RegCloseKey(key); } void Discord_Register(const char* applicationId, const char* command) { - wchar_t openCommand[1024]; - const wchar_t* wcommand = NULL; - wchar_t appId[32]; + wchar_t appId[32]; + wchar_t openCommand[1024]; + const wchar_t* wcommand = NULL; - MultiByteToWideChar(CP_UTF8, 0, applicationId, -1, appId, 32); - if (command && command[0]) - { - const int commandBufferLen = - sizeof(openCommand) / sizeof(*openCommand); - MultiByteToWideChar(CP_UTF8, 0, command, -1, - openCommand, commandBufferLen); - wcommand = openCommand; - } + MultiByteToWideChar(CP_UTF8, 0, applicationId, -1, appId, 32); - Discord_RegisterW(appId, wcommand); + if (command && command[0]) + { + const int commandBufferLen = + sizeof(openCommand) / sizeof(*openCommand); + MultiByteToWideChar(CP_UTF8, 0, command, -1, + openCommand, commandBufferLen); + wcommand = openCommand; + } + + Discord_RegisterW(appId, wcommand); } void Discord_RegisterSteamGame( @@ -172,7 +171,8 @@ void Discord_RegisterSteamGame( status = RegQueryValueExW(key, L"SteamExe", NULL, NULL, (BYTE*)steamPath, &pathBytes); RegCloseKey(key); - if (status != ERROR_SUCCESS || pathBytes < 1) { + if (status != ERROR_SUCCESS || pathBytes < 1) + { fprintf(stderr, "Error reading SteamExe key\n"); return; } diff --git a/deps/discord-rpc/src/discord_rpc.cpp b/deps/discord-rpc/src/discord_rpc.cpp index f430746e83..3f430bed16 100644 --- a/deps/discord-rpc/src/discord_rpc.cpp +++ b/deps/discord-rpc/src/discord_rpc.cpp @@ -1,7 +1,7 @@ +#include #include "discord_rpc.h" #include "backoff.h" -#include "discord_register.h" #include "msg_queue.h" #include "rpc_connection.h" #include "serialization.h" @@ -15,14 +15,23 @@ #include #endif -constexpr size_t MaxMessageSize{16 * 1024}; -constexpr size_t MessageQueueSize{8}; -constexpr size_t JoinQueueSize{8}; + +/* Forward declarations */ +#if defined(__cplusplus) && !defined(CXX_BUILD) +extern "C" { +#endif + +void Discord_Register(const char *a, const char *b); +void Discord_RegisterSteamGame(const char *a, const char *b); + +#if defined(__cplusplus) && !defined(CXX_BUILD) +} +#endif struct QueuedMessage { size_t length; - char buffer[MaxMessageSize]; + char buffer[16384]; void Copy(const QueuedMessage& other) { @@ -50,25 +59,32 @@ struct User * from future changes in these sizes */ }; +static int Pid{0}; +static int Nonce{1}; +static int LastErrorCode{0}; +static int LastDisconnectErrorCode{0}; + +static char JoinGameSecret[256]; +static char SpectateGameSecret[256]; +static char LastErrorMessage[256]; +static char LastDisconnectErrorMessage[256]; + static RpcConnection* Connection{nullptr}; + static DiscordEventHandlers QueuedHandlers{}; static DiscordEventHandlers Handlers{}; + static std::atomic_bool WasJustConnected{false}; static std::atomic_bool WasJustDisconnected{false}; static std::atomic_bool GotErrorMessage{false}; static std::atomic_bool WasJoinGame{false}; static std::atomic_bool WasSpectateGame{false}; -static char JoinGameSecret[256]; -static char SpectateGameSecret[256]; -static int LastErrorCode{0}; -static char LastErrorMessage[256]; -static int LastDisconnectErrorCode{0}; -static char LastDisconnectErrorMessage[256]; + static std::mutex PresenceMutex; static std::mutex HandlerMutex; static QueuedMessage QueuedPresence{}; -static MsgQueue SendQueue; -static MsgQueue JoinAskQueue; +static MsgQueue SendQueue; +static MsgQueue JoinAskQueue; static User connectedUser; /* We want to auto connect, and retry on failure, @@ -76,57 +92,57 @@ static User connectedUser; * backoff from 0.5 seconds to 1 minute */ static Backoff ReconnectTimeMs(500, 60 * 1000); static auto NextConnect = std::chrono::system_clock::now(); -static int Pid{0}; -static int Nonce{1}; #ifndef DISCORD_DISABLE_IO_THREAD static void Discord_UpdateConnection(void); -class IoThreadHolder { -private: - std::atomic_bool keepRunning{true}; - std::mutex waitForIOMutex; - std::condition_variable waitForIOActivity; - std::thread ioThread; +class IoThreadHolder +{ + private: + std::atomic_bool keepRunning{true}; + std::mutex waitForIOMutex; + std::condition_variable waitForIOActivity; + std::thread ioThread; -public: - void Start() - { - keepRunning.store(true); - ioThread = std::thread([&]() { - const std::chrono::duration maxWait{500LL}; - Discord_UpdateConnection(); - while (keepRunning.load()) { - std::unique_lock lock(waitForIOMutex); - waitForIOActivity.wait_for(lock, maxWait); - Discord_UpdateConnection(); - } - }); - } + public: + void Start() + { + keepRunning.store(true); + ioThread = std::thread([&]() { + const std::chrono::duration maxWait{500LL}; + Discord_UpdateConnection(); + while (keepRunning.load()) { + std::unique_lock lock(waitForIOMutex); + waitForIOActivity.wait_for(lock, maxWait); + Discord_UpdateConnection(); + } + }); + } - void Notify() { waitForIOActivity.notify_all(); } + void Notify() { waitForIOActivity.notify_all(); } - void Stop() - { - keepRunning.exchange(false); - Notify(); - if (ioThread.joinable()) + void Stop() + { + keepRunning.exchange(false); + Notify(); + if (ioThread.joinable()) ioThread.join(); - } + } - ~IoThreadHolder() { Stop(); } + ~IoThreadHolder() { Stop(); } }; #else -class IoThreadHolder { -public: - void Start() {} - void Stop() {} - void Notify() {} +class IoThreadHolder +{ + public: + void Start() {} + void Stop() {} + void Notify() {} }; #endif /* DISCORD_DISABLE_IO_THREAD */ static IoThreadHolder* IoThread{nullptr}; -static void UpdateReconnectTime() +static void UpdateReconnectTime(void) { NextConnect = std::chrono::system_clock::now() + std::chrono::duration{ReconnectTimeMs.nextDelay()}; @@ -160,18 +176,18 @@ static void Discord_UpdateConnection(void) if (!Connection->Read(message)) break; - const char* evtName = GetStrMember(&message, "evt"); - const char* nonce = GetStrMember(&message, "nonce"); + const char *evtName = GetStrMember(&message, "evt"); + const char *nonce = GetStrMember(&message, "nonce"); if (nonce) { /* in responses only -- * should use to match up response when needed. */ - if (evtName && strcmp(evtName, "ERROR") == 0) + if (evtName && !strcmp(evtName, "ERROR")) { - auto data = GetObjMember(&message, "data"); - LastErrorCode = GetIntMember(data, "code"); + JsonValue *data = GetObjMember(&message, "data"); + LastErrorCode = GetIntMember(data, "code"); StringCopy(LastErrorMessage, GetStrMember(data, "message", "")); GotErrorMessage.store(true); } @@ -182,39 +198,40 @@ static void Discord_UpdateConnection(void) if (!evtName) continue; - auto data = GetObjMember(&message, "data"); + JsonValue *data = GetObjMember(&message, "data"); - if (strcmp(evtName, "ACTIVITY_JOIN") == 0) + if (!strcmp(evtName, "ACTIVITY_JOIN")) { - auto secret = GetStrMember(data, "secret"); + const char *secret = GetStrMember(data, "secret"); if (secret) { StringCopy(JoinGameSecret, secret); WasJoinGame.store(true); } } - else if (strcmp(evtName, "ACTIVITY_SPECTATE") == 0) + else if (!strcmp(evtName, "ACTIVITY_SPECTATE")) { - auto secret = GetStrMember(data, "secret"); + const char *secret = GetStrMember(data, "secret"); if (secret) { StringCopy(SpectateGameSecret, secret); WasSpectateGame.store(true); } } - else if (strcmp(evtName, "ACTIVITY_JOIN_REQUEST") == 0) + else if (!strcmp(evtName, "ACTIVITY_JOIN_REQUEST")) { - auto user = GetObjMember(data, "user"); - auto userId = GetStrMember(user, "id"); - auto username = GetStrMember(user, "username"); - auto avatar = GetStrMember(user, "avatar"); - auto joinReq = JoinAskQueue.GetNextAddMessage(); + JsonValue *user = GetObjMember(data, "user"); + const char *userId = GetStrMember(user, "id"); + const char *username = GetStrMember(user, "username"); + const char *avatar = GetStrMember(user, "avatar"); + auto joinReq = JoinAskQueue.GetNextAddMessage(); if (userId && username && joinReq) { StringCopy(joinReq->userId, userId); StringCopy(joinReq->username, username); - auto discriminator = GetStrMember(user, "discriminator"); + const char *discriminator = GetStrMember(user, + "discriminator"); if (discriminator) StringCopy(joinReq->discriminator, discriminator); if (avatar) @@ -321,16 +338,16 @@ extern "C" DISCORD_EXPORT void Discord_Initialize( Connection->onConnect = [](JsonDocument& readyMessage) { Discord_UpdateHandlers(&QueuedHandlers); - auto data = GetObjMember(&readyMessage, "data"); - auto user = GetObjMember(data, "user"); - auto userId = GetStrMember(user, "id"); - auto username = GetStrMember(user, "username"); - auto avatar = GetStrMember(user, "avatar"); + JsonValue *data = GetObjMember(&readyMessage, "data"); + JsonValue *user = GetObjMember(data, "user"); + const char *userId = GetStrMember(user, "id"); + const char *username = GetStrMember(user, "username"); + const char *avatar = GetStrMember(user, "avatar"); if (userId && username) { StringCopy(connectedUser.userId, userId); StringCopy(connectedUser.username, username); - auto discriminator = GetStrMember(user, "discriminator"); + const char *discriminator = GetStrMember(user, "discriminator"); if (discriminator) StringCopy(connectedUser.discriminator, discriminator); if (avatar) diff --git a/deps/discord-rpc/src/rpc_connection.cpp b/deps/discord-rpc/src/rpc_connection.cpp index f93cb66278..6904b32249 100644 --- a/deps/discord-rpc/src/rpc_connection.cpp +++ b/deps/discord-rpc/src/rpc_connection.cpp @@ -36,8 +36,8 @@ void RpcConnection::Open() JsonDocument message; if (Read(message)) { - auto cmd = GetStrMember(&message, "cmd"); - auto evt = GetStrMember(&message, "evt"); + const char *cmd = GetStrMember(&message, "cmd"); + const char *evt = GetStrMember(&message, "evt"); if (cmd && evt && !strcmp(cmd, "DISPATCH") && !strcmp(evt, "READY")) diff --git a/deps/discord-rpc/src/rpc_connection.h b/deps/discord-rpc/src/rpc_connection.h index a4ccb82638..6fb69c9ee0 100644 --- a/deps/discord-rpc/src/rpc_connection.h +++ b/deps/discord-rpc/src/rpc_connection.h @@ -5,7 +5,7 @@ /* I took this from the buffer size libuv uses for named pipes; * I suspect ours would usually be much smaller. */ -constexpr size_t MaxRpcFrameSize = 64 * 1024; +#define MAX_RPC_FRAMESIZE 65536 struct RpcConnection { @@ -33,7 +33,7 @@ struct RpcConnection struct MessageFrame : public MessageFrameHeader { - char message[MaxRpcFrameSize - sizeof(MessageFrameHeader)]; + char message[MAX_RPC_FRAMESIZE - sizeof(MessageFrameHeader)]; }; enum class State : uint32_t From 2052f1595c792f70ea5a1b302b89d5f652485169 Mon Sep 17 00:00:00 2001 From: barbudreadmon Date: Fri, 22 May 2020 12:02:19 +0200 Subject: [PATCH 184/192] (vita) try at fixing upside-down vertical games it is a blind commit, i don't have access to the hardware, see #6859 for more explanations --- gfx/drivers/vita2d_gfx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index 781bb11e6e..69f59b30ea 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -210,7 +210,7 @@ static bool vita2d_gfx_frame(void *data, const void *frame, PSP_FB_HEIGHT / (float)vita->height); else { - const float radian = 90 * 0.0174532925f; + const float radian = 270 * 0.0174532925f; const float rad = vita->rotation * radian; float scalex = vita->vp.width / (float)vita->width; float scaley = vita->vp.height / (float)vita->height; From 955e25fc39d67008f5a98dcb92c4c7bf036bf400 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Fri, 22 May 2020 11:07:34 +0100 Subject: [PATCH 185/192] (On Demand Thumbnails) Fix heap-use-after-free error --- tasks/task_pl_thumbnail_download.c | 71 +++++++++++++++--------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/tasks/task_pl_thumbnail_download.c b/tasks/task_pl_thumbnail_download.c index 972b3bd115..9b885c9d11 100644 --- a/tasks/task_pl_thumbnail_download.c +++ b/tasks/task_pl_thumbnail_download.c @@ -282,30 +282,30 @@ static void download_pl_thumbnail(pl_thumb_handle_t *pl_thumb) } } -static void free_pl_thumb_handle(pl_thumb_handle_t *pl_thumb, bool free_playlist) +static void free_pl_thumb_handle(pl_thumb_handle_t *pl_thumb) { if (!pl_thumb) return; - if (!string_is_empty(pl_thumb->system)) + if (pl_thumb->system) { free(pl_thumb->system); pl_thumb->system = NULL; } - if (!string_is_empty(pl_thumb->playlist_path)) + if (pl_thumb->playlist_path) { free(pl_thumb->playlist_path); pl_thumb->playlist_path = NULL; } - if (!string_is_empty(pl_thumb->dir_thumbnails)) + if (pl_thumb->dir_thumbnails) { free(pl_thumb->dir_thumbnails); pl_thumb->dir_thumbnails = NULL; } - if (pl_thumb->playlist && free_playlist) + if (pl_thumb->playlist) { playlist_free(pl_thumb->playlist); pl_thumb->playlist = NULL; @@ -452,7 +452,7 @@ task_finished: if (task) task_set_finished(task, true); - free_pl_thumb_handle(pl_thumb, true); + free_pl_thumb_handle(pl_thumb); } static bool task_pl_thumbnail_finder(retro_task_t *task, void *user_data) @@ -645,7 +645,7 @@ static void task_pl_entry_thumbnail_free(retro_task_t *task) pl_thumb = (pl_thumb_handle_t*)task->state; - free_pl_thumb_handle(pl_thumb, false); + free_pl_thumb_handle(pl_thumb); } static void task_pl_entry_thumbnail_download_handler(retro_task_t *task) @@ -671,31 +671,6 @@ static void task_pl_entry_thumbnail_download_handler(retro_task_t *task) const char *right_thumbnail_path = NULL; const char *left_thumbnail_path = NULL; - /* Redundant safety check - ensure that playlist is - * non-NULL, and that the playlist path is the same - * as that recorded when task_push_pl_entry_thumbnail_download() - * was called... */ - if (!pl_thumb->playlist) - goto task_finished; - - if (!string_is_equal(pl_thumb->playlist_path, - playlist_get_conf_path(pl_thumb->playlist))) - goto task_finished; - - /* Initialise thumbnail path data */ - pl_thumb->thumbnail_path_data = gfx_thumbnail_path_init(); - - if (!pl_thumb->thumbnail_path_data) - goto task_finished; - - if (!gfx_thumbnail_set_system( - pl_thumb->thumbnail_path_data, pl_thumb->system, pl_thumb->playlist)) - goto task_finished; - - if (!gfx_thumbnail_set_content_playlist( - pl_thumb->thumbnail_path_data, pl_thumb->playlist, pl_thumb->list_index)) - goto task_finished; - /* Check whether current right/left thumbnails * already exist (required for menu refresh callback) */ pl_thumb->right_thumbnail_exists = false; @@ -805,6 +780,8 @@ bool task_push_pl_entry_thumbnail_download( pl_thumb_handle_t *pl_thumb = (pl_thumb_handle_t*)calloc(1, sizeof(pl_thumb_handle_t)); pl_entry_id_t *entry_id = (pl_entry_id_t*)calloc(1, sizeof(pl_entry_id_t)); char *playlist_path = NULL; + gfx_thumbnail_path_data_t * + thumbnail_path_data = NULL; const char *dir_thumbnails = NULL; /* Sanity check */ @@ -845,6 +822,22 @@ bool task_push_pl_entry_thumbnail_download( free(entry_id); entry_id = NULL; + /* Initialise thumbnail path data + * > Have to do this here rather than in the + * task handler to avoid thread race conditions */ + thumbnail_path_data = gfx_thumbnail_path_init(); + + if (!thumbnail_path_data) + goto error; + + if (!gfx_thumbnail_set_system( + thumbnail_path_data, system, playlist)) + goto error; + + if (!gfx_thumbnail_set_content_playlist( + thumbnail_path_data, playlist, idx)) + goto error; + /* Configure task */ task->handler = task_pl_entry_thumbnail_download_handler; task->state = pl_thumb; @@ -856,11 +849,11 @@ bool task_push_pl_entry_thumbnail_download( task->cleanup = task_pl_entry_thumbnail_free; /* Configure handle */ - pl_thumb->system = strdup(system); + pl_thumb->system = NULL; pl_thumb->playlist_path = playlist_path; pl_thumb->dir_thumbnails = strdup(dir_thumbnails); - pl_thumb->playlist = playlist; - pl_thumb->thumbnail_path_data = NULL; + pl_thumb->playlist = NULL; + pl_thumb->thumbnail_path_data = thumbnail_path_data; pl_thumb->http_task = NULL; pl_thumb->http_task_complete = false; pl_thumb->list_size = playlist_size(playlist); @@ -893,11 +886,17 @@ error: entry_id = NULL; } - if (!string_is_empty(playlist_path)) + if (playlist_path) { free(playlist_path); playlist_path = NULL; } + if (thumbnail_path_data) + { + free(thumbnail_path_data); + thumbnail_path_data = NULL; + } + return false; } From 2f57d3cbeacbee5eb492f7531b11746ac533c7ae Mon Sep 17 00:00:00 2001 From: barbudreadmon Date: Fri, 22 May 2020 15:38:47 +0200 Subject: [PATCH 186/192] (video) fix "Allow Cores to Switch the Video Driver OFF" behavior fix #10677 : video driver must never be switched when this setting is set to OFF, it is the job of the core to request the right context --- retroarch.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/retroarch.c b/retroarch.c index 46224cb30a..5b100fd973 100644 --- a/retroarch.c +++ b/retroarch.c @@ -9907,9 +9907,11 @@ static bool dynamic_verify_hw_context(enum retro_hw_context_type type, case RETRO_HW_CONTEXT_OPENGLES3: case RETRO_HW_CONTEXT_OPENGLES_VERSION: case RETRO_HW_CONTEXT_OPENGL: + if (!string_is_equal(video_ident, "gl")) + return false; + break; case RETRO_HW_CONTEXT_OPENGL_CORE: - if (!string_is_equal(video_ident, "gl") && - !string_is_equal(video_ident, "glcore")) + if (!string_is_equal(video_ident, "glcore")) return false; break; case RETRO_HW_CONTEXT_DIRECT3D: @@ -22303,42 +22305,27 @@ static bool video_driver_find_driver(void) } #endif -#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL_CORE) +#if defined(HAVE_OPENGL) if (hwr && hw_render_context_is_gl(hwr->context_type)) { RARCH_LOG("[Video]: Using HW render, OpenGL driver forced.\n"); - - /* If we have configured one of the HW render capable GL drivers, go with that. */ - if ( !string_is_equal(settings->arrays.video_driver, "gl") && - !string_is_equal(settings->arrays.video_driver, "glcore")) + if (!string_is_equal(settings->arrays.video_driver, "gl")) { RARCH_LOG("[Video]: \"%s\" saved as cached driver.\n", settings->arrays.video_driver); strlcpy(cached_video_driver, settings->arrays.video_driver, sizeof(cached_video_driver)); -#if defined(HAVE_OPENGL_CORE) - RARCH_LOG("[Video]: Forcing \"glcore\" driver.\n"); configuration_set_string(settings, - settings->arrays.video_driver, "glcore"); - current_video = &video_gl_core; -#else - RARCH_LOG("[Video]: Forcing \"gl\" driver.\n"); - configuration_set_string(settings, - settings->arrays.video_driver, "gl"); - current_video = &video_gl2; -#endif - } - else - { - RARCH_LOG("[Video]: Using configured \"%s\" driver for GL HW render.\n", - settings->arrays.video_driver); + settings->arrays.video_driver, + "gl"); } + current_video = &video_gl2; } #endif #if defined(HAVE_OPENGL_CORE) if (hwr && hw_render_context_is_glcore(hwr->context_type)) { - RARCH_LOG("[Video]: Using HW render, OpenGL core driver forced.\n"); + RARCH_LOG("[Video]: Using HW render, core OpenGL driver forced.\n"); if (!string_is_equal(settings->arrays.video_driver, "glcore")) { RARCH_LOG("[Video]: \"%s\" saved as cached driver.\n", settings->arrays.video_driver); From 5ad36f7040a77c002aac8bbb193f64df628b3151 Mon Sep 17 00:00:00 2001 From: Autechre Date: Fri, 22 May 2020 16:29:03 +0200 Subject: [PATCH 187/192] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 8392f2d87b..32fa810f0a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ - AUDIO/JACK: Fix regression introduced after 1.8.4 - would hang at startup - CHEEVOS: Disable hardcore when cheats are enabled - CHD: Return false when special track cannot be found +- DISCORD/MATCHMAKING: Fix Discord 'Ask To Join' functionality - INPUT MAPPING/REMAPPING: Restore broken 'reset to default' functionality with RetroPad 'start' button - INPUT MAPPING/REMAPPING: Fix 'reset to default' action for analog sticks and undefined core inputs - MENU/THUMBNAILS/BUGFIX: Fix heap-use-after-free error From d24498bdf16d682054099701e941a14fe13b6e63 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Fri, 22 May 2020 16:55:41 +0100 Subject: [PATCH 188/192] Image file type detection fixes/optimisations --- libretro-common/formats/image_texture.c | 41 +++++++++++++++++----- libretro-common/include/string/stdstring.h | 15 ++++++++ tasks/task_image.c | 37 +++++++++---------- 3 files changed, 65 insertions(+), 28 deletions(-) diff --git a/libretro-common/formats/image_texture.c b/libretro-common/formats/image_texture.c index e434766e3a..1c4a605fe0 100644 --- a/libretro-common/formats/image_texture.c +++ b/libretro-common/formats/image_texture.c @@ -28,26 +28,51 @@ #include #include #include - +#include enum image_type_enum image_texture_get_type(const char *path) { -#ifdef HAVE_RTGA - if (strstr(path, ".tga")) - return IMAGE_TYPE_TGA; -#endif + /* We are comparing against a fixed list of file + * extensions, the longest (jpeg) being 4 characters + * in length. We therefore only need to extract the first + * 5 characters from the extension of the input path + * to correctly validate a match */ + const char *ext = NULL; + char ext_lower[6]; + + ext_lower[0] = '\0'; + + if (string_is_empty(path)) + return IMAGE_TYPE_NONE; + + /* Get file extension */ + ext = strrchr(path, '.'); + + if (!ext || (*(++ext) == '\0')) + return IMAGE_TYPE_NONE; + + /* Copy and convert to lower case */ + strlcpy(ext_lower, ext, sizeof(ext_lower)); + string_to_lower(ext_lower); + #ifdef HAVE_RPNG - if (strstr(path, ".png")) + if (string_is_equal(ext_lower, "png")) return IMAGE_TYPE_PNG; #endif #ifdef HAVE_RJPEG - if (strstr(path, ".jpg") || strstr(path, ".jpeg")) + if (string_is_equal(ext_lower, "jpg") || + string_is_equal(ext_lower, "jpeg")) return IMAGE_TYPE_JPEG; #endif #ifdef HAVE_RBMP - if (strstr(path, ".bmp")) + if (string_is_equal(ext_lower, "bmp")) return IMAGE_TYPE_BMP; #endif +#ifdef HAVE_RTGA + if (string_is_equal(ext_lower, "tga")) + return IMAGE_TYPE_TGA; +#endif + return IMAGE_TYPE_NONE; } diff --git a/libretro-common/include/string/stdstring.h b/libretro-common/include/string/stdstring.h index 18668e98db..9676a50503 100644 --- a/libretro-common/include/string/stdstring.h +++ b/libretro-common/include/string/stdstring.h @@ -50,6 +50,21 @@ static INLINE bool string_starts_with(const char *str, const char *prefix) return (str && prefix) ? !strncmp(prefix, str, strlen(prefix)) : false; } +static INLINE bool string_ends_with(const char *str, const char *suffix) +{ + size_t str_len; + size_t suffix_len; + + if (!str || !suffix) + return false; + + str_len = strlen(str); + suffix_len = strlen(suffix); + + return (str_len < suffix_len) ? false : + !memcmp(suffix, str + (str_len - suffix_len), suffix_len); +} + #define STRLEN_CONST(x) ((sizeof((x))-1)) #define string_is_not_equal(a, b) !string_is_equal((a), (b)) diff --git a/tasks/task_image.c b/tasks/task_image.c index d21170d3e2..850a07318c 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -422,7 +422,7 @@ bool task_push_image_load(const char *fullpath, nbio->path = strdup(fullpath); - image->type = IMAGE_TYPE_NONE; + image->type = image_texture_get_type(fullpath); image->status = IMAGE_STATUS_WAIT; image->is_blocking = false; image->is_blocking_on_processing = false; @@ -439,26 +439,23 @@ bool task_push_image_load(const char *fullpath, /* TODO/FIXME - shouldn't we set this ? */ image->ti.supports_rgba = false; - if (strstr(fullpath, ".png")) + switch (image->type) { - nbio->type = NBIO_TYPE_PNG; - image->type = IMAGE_TYPE_PNG; - } - else if (strstr(fullpath, ".jpeg") - || strstr(fullpath, ".jpg")) - { - nbio->type = NBIO_TYPE_JPEG; - image->type = IMAGE_TYPE_JPEG; - } - else if (strstr(fullpath, ".bmp")) - { - nbio->type = NBIO_TYPE_BMP; - image->type = IMAGE_TYPE_BMP; - } - else if (strstr(fullpath, ".tga")) - { - nbio->type = NBIO_TYPE_TGA; - image->type = IMAGE_TYPE_TGA; + case IMAGE_TYPE_PNG: + nbio->type = NBIO_TYPE_PNG; + break; + case IMAGE_TYPE_JPEG: + nbio->type = NBIO_TYPE_JPEG; + break; + case IMAGE_TYPE_BMP: + nbio->type = NBIO_TYPE_BMP; + break; + case IMAGE_TYPE_TGA: + nbio->type = NBIO_TYPE_TGA; + break; + default: + nbio->type = NBIO_TYPE_NONE; + break; } nbio->data = (struct nbio_image_handle*)image; From 7cbb79277d27882b2679167e31af5b0af849135e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 22 May 2020 19:43:10 +0200 Subject: [PATCH 189/192] Cleanup core_load_game function --- retroarch.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/retroarch.c b/retroarch.c index 5b100fd973..8e5827fd1c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -29486,6 +29486,7 @@ bool core_load_game(retro_ctx_load_content_info_t *load_info) { bool contentless = false; bool is_inited = false; + bool game_loaded = false; video_driver_set_cached_frame_ptr(NULL); @@ -29498,16 +29499,16 @@ bool core_load_game(retro_ctx_load_content_info_t *load_info) set_save_state_in_background(false); if (load_info && load_info->special) - current_core.game_loaded = current_core.retro_load_game_special( + game_loaded = current_core.retro_load_game_special( load_info->special->id, load_info->info, load_info->content->size); else if (load_info && !string_is_empty(load_info->content->elems[0].data)) - current_core.game_loaded = current_core.retro_load_game(load_info->info); + game_loaded = current_core.retro_load_game(load_info->info); else if (contentless) - current_core.game_loaded = current_core.retro_load_game(NULL); - else - current_core.game_loaded = false; + game_loaded = current_core.retro_load_game(NULL); - return current_core.game_loaded; + current_core.game_loaded = game_loaded; + + return game_loaded; } bool core_get_system_info(struct retro_system_info *system) From 9f4b3b0fc6ca4a1ce639def86ae6c6d91cf5ecec Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 22 May 2020 20:07:21 +0200 Subject: [PATCH 190/192] Start using string_ends_with --- menu/drivers/ozone/ozone_sidebar.c | 4 ++-- menu/drivers/stripes.c | 7 ++----- menu/drivers/xmb.c | 4 ++-- menu/menu_shader.c | 6 +++--- tasks/task_audio_mixer.c | 28 ++++++++++++++-------------- 5 files changed, 23 insertions(+), 26 deletions(-) diff --git a/menu/drivers/ozone/ozone_sidebar.c b/menu/drivers/ozone/ozone_sidebar.c index 367643f8e2..f2c1c37d8f 100644 --- a/menu/drivers/ozone/ozone_sidebar.c +++ b/menu/drivers/ozone/ozone_sidebar.c @@ -851,7 +851,7 @@ void ozone_context_reset_horizontal_list(ozone_handle_t *ozone) if (!path) continue; - if (!strstr(path, ".lpl")) + if (!string_ends_with(path, ".lpl")) continue; { @@ -968,7 +968,7 @@ void ozone_context_destroy_horizontal_list(ozone_handle_t *ozone) file_list_get_at_offset(ozone->horizontal_list, i, &path, NULL, NULL, NULL); - if (!path || !strstr(path, ".lpl")) + if (!path || !string_ends_with(path, ".lpl")) continue; video_driver_texture_unload(&node->icon); diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index 7b2ecac23d..307ce6ffdc 100644 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -1839,7 +1839,7 @@ static void stripes_context_destroy_horizontal_list(stripes_handle_t *stripes) file_list_get_at_offset(stripes->horizontal_list, i, &path, NULL, NULL, NULL); - if (!path || !strstr(path, ".lpl")) + if (!path || !string_ends_with(path, ".lpl")) continue; video_driver_texture_unload(&node->icon); @@ -1937,10 +1937,7 @@ static void stripes_context_reset_horizontal_list( file_list_get_at_offset(stripes->horizontal_list, i, &path, NULL, NULL, NULL); - if (!path) - continue; - - if (!strstr(path, ".lpl")) + if (!path || !string_ends_with(path, ".lpl")) continue; { diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 04d6b9a1f2..d26ead6292 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2016,7 +2016,7 @@ static void xmb_context_destroy_horizontal_list(xmb_handle_t *xmb) file_list_get_at_offset(xmb->horizontal_list, i, &path, NULL, NULL, NULL); - if (!path || !strstr(path, ".lpl")) + if (!path || !string_ends_with(path, ".lpl")) continue; video_driver_texture_unload(&node->icon); @@ -2115,7 +2115,7 @@ static void xmb_context_reset_horizontal_list( if (!path) continue; - if (!strstr(path, ".lpl")) + if (!string_ends_with(path, ".lpl")) continue; { diff --git a/menu/menu_shader.c b/menu/menu_shader.c index 1aafd41b93..b584dfb512 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -249,9 +249,9 @@ static bool menu_shader_manager_save_preset_internal( strlcpy(fullname, basename, sizeof(fullname)); /* Append extension automatically as appropriate. */ - if ( !strstr(basename, ".cgp") - && !strstr(basename, ".glslp") - && !strstr(basename, ".slangp")) + if ( !string_ends_with(basename, ".cgp") + && !string_ends_with(basename, ".glslp") + && !string_ends_with(basename, ".slangp")) { const char *preset_ext = video_shader_get_preset_extension(type); strlcat(fullname, preset_ext, sizeof(fullname)); diff --git a/tasks/task_audio_mixer.c b/tasks/task_audio_mixer.c index 4f5a8c4c79..69c3ce409f 100644 --- a/tasks/task_audio_mixer.c +++ b/tasks/task_audio_mixer.c @@ -479,34 +479,34 @@ bool task_push_audio_mixer_load_and_play( nbio->type = NBIO_TYPE_NONE; mixer->type = AUDIO_MIXER_TYPE_NONE; - if (strstr(fullpath, ".wav")) + if (string_ends_with(fullpath, ".wav")) { mixer->type = AUDIO_MIXER_TYPE_WAV; nbio->type = NBIO_TYPE_WAV; t->callback = task_audio_mixer_handle_upload_wav_and_play; } - else if (strstr(fullpath, ".ogg")) + else if (string_ends_with(fullpath, ".ogg")) { mixer->type = AUDIO_MIXER_TYPE_OGG; nbio->type = NBIO_TYPE_OGG; t->callback = task_audio_mixer_handle_upload_ogg_and_play; } - else if (strstr(fullpath, ".mp3")) + else if (string_ends_with(fullpath, ".mp3")) { mixer->type = AUDIO_MIXER_TYPE_MP3; nbio->type = NBIO_TYPE_MP3; t->callback = task_audio_mixer_handle_upload_mp3_and_play; } - else if (strstr(fullpath, ".flac")) + else if (string_ends_with(fullpath, ".flac")) { mixer->type = AUDIO_MIXER_TYPE_FLAC; nbio->type = NBIO_TYPE_FLAC; t->callback = task_audio_mixer_handle_upload_flac_and_play; } else if ( - strstr(fullpath, ".mod") || - strstr(fullpath, ".s3m") || - strstr(fullpath, ".xm")) + string_ends_with(fullpath, ".mod") || + string_ends_with(fullpath, ".s3m") || + string_ends_with(fullpath, ".xm")) { mixer->type = AUDIO_MIXER_TYPE_MOD; nbio->type = NBIO_TYPE_MOD; @@ -589,34 +589,34 @@ bool task_push_audio_mixer_load( nbio->type = NBIO_TYPE_NONE; mixer->type = AUDIO_MIXER_TYPE_NONE; - if (strstr(fullpath, ".wav")) + if (string_ends_with(fullpath, ".wav")) { mixer->type = AUDIO_MIXER_TYPE_WAV; nbio->type = NBIO_TYPE_WAV; t->callback = task_audio_mixer_handle_upload_wav; } - else if (strstr(fullpath, ".ogg")) + else if (string_ends_with(fullpath, ".ogg")) { mixer->type = AUDIO_MIXER_TYPE_OGG; nbio->type = NBIO_TYPE_OGG; t->callback = task_audio_mixer_handle_upload_ogg; } - else if (strstr(fullpath, ".mp3")) + else if (string_ends_with(fullpath, ".mp3")) { mixer->type = AUDIO_MIXER_TYPE_MP3; nbio->type = NBIO_TYPE_MP3; t->callback = task_audio_mixer_handle_upload_mp3; } - else if (strstr(fullpath, ".flac")) + else if (string_ends_with(fullpath, ".flac")) { mixer->type = AUDIO_MIXER_TYPE_FLAC; nbio->type = NBIO_TYPE_FLAC; t->callback = task_audio_mixer_handle_upload_flac; } else if ( - strstr(fullpath, ".mod") || - strstr(fullpath, ".s3m") || - strstr(fullpath, ".xm")) + string_ends_with(fullpath, ".mod") || + string_ends_with(fullpath, ".s3m") || + string_ends_with(fullpath, ".xm")) { mixer->type = AUDIO_MIXER_TYPE_MOD; nbio->type = NBIO_TYPE_MOD; From 31674f9246097c589624d05b800bcb8dcbb8175d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 22 May 2020 20:57:48 +0200 Subject: [PATCH 191/192] Use string_ends_with and string_starts_with --- menu/cbs/menu_cbs_ok.c | 2 +- menu/cbs/menu_cbs_title.c | 4 ++-- tasks/task_netplay_find_content.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 22ec4b824f..ef2f093710 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -5346,7 +5346,7 @@ static void netplay_refresh_rooms_cb(retro_task_t *task, data->data = new_data; data->data[data->len] = '\0'; - if (!strstr(data->data, "registry.lpl")) + if (!string_ends_with(data->data, "registry.lpl")) { if (string_is_empty(data->data)) netplay_room_count = 0; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index f54fc19096..86638311f5 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -156,7 +156,7 @@ static int action_get_title_dropdown_item( if (string_is_empty(path)) return 0; - if (strstr(path, "core_option_")) + if (string_starts_with(path, "core_option_")) { /* This is a core options item */ struct string_list *tmp_str_list = string_split(path, "_"); @@ -1406,7 +1406,7 @@ int menu_cbs_init_bind_title(menu_file_list_cbs_t *cbs, * treatment, since the label has the format: * | * i.e. cannot use a normal string_is_equal() */ - if (strstr(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RDB_ENTRY_DETAIL))) + if (string_starts_with(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RDB_ENTRY_DETAIL))) { BIND_ACTION_GET_TITLE(cbs, action_get_title_list_rdb_entry_database_info); return 0; diff --git a/tasks/task_netplay_find_content.c b/tasks/task_netplay_find_content.c index 6955275c24..279b74f7ac 100644 --- a/tasks/task_netplay_find_content.c +++ b/tasks/task_netplay_find_content.c @@ -266,7 +266,7 @@ static void task_netplay_crc_scan_handler(retro_task_t *task) const char *lpl_path = state->lpl_list->elems[i].data; /* skip files without .lpl file extension */ - if (!strstr(lpl_path, ".lpl")) + if (!string_ends_with(lpl_path, ".lpl")) continue; RARCH_LOG("[Lobby] Searching playlist: %s\n", lpl_path); @@ -340,7 +340,7 @@ static void task_netplay_crc_scan_handler(retro_task_t *task) const char *lpl_path = state->lpl_list->elems[j].data; /* skip files without .lpl file extension */ - if (!strstr(lpl_path, ".lpl")) + if (!string_ends_with(lpl_path, ".lpl")) continue; RARCH_LOG("[Lobby] Searching content %d/%d (%s) in playlist: %s\n", i + 1, game_list->size, game_list->elems[i].data, lpl_path); From eaba575c9ebed13047a94af1b7f7fc0a3e596f1f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 22 May 2020 21:11:35 +0200 Subject: [PATCH 192/192] Replace strstrs where possible --- menu/cbs/menu_cbs_deferred_push.c | 2 +- menu/menu_displaylist.c | 4 ++-- menu/menu_networking.c | 6 ++++-- tasks/task_http.c | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 46fa637174..0e805cb5fc 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -895,7 +895,7 @@ static int menu_cbs_init_bind_deferred_push_compare_label( * treatment, since the label has the format: * | * i.e. cannot use a normal string_is_equal() */ - if (strstr(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RDB_ENTRY_DETAIL))) + if (string_starts_with(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RDB_ENTRY_DETAIL))) { BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_rdb_entry_detail); } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 2fc1f61b92..8629749820 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -10570,7 +10570,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, { menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); - if (strstr(info->path, "core_option_")) + if (string_starts_with(info->path, "core_option_")) { struct string_list *tmp_str_list = string_split(info->path, "_"); @@ -10988,7 +10988,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, case DISPLAYLIST_DROPDOWN_LIST_SPECIAL: menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); - if (strstr(info->path, "core_option_")) + if (string_starts_with(info->path, "core_option_")) { struct string_list *tmp_str_list = string_split(info->path, "_"); diff --git a/menu/menu_networking.c b/menu/menu_networking.c index d4f107622d..4d8d56d527 100644 --- a/menu/menu_networking.c +++ b/menu/menu_networking.c @@ -152,7 +152,8 @@ void cb_net_generic_subdir(retro_task_t *task, subdir_path[data->len] = '\0'; finish: - if (!err && !strstr(subdir_path, file_path_str(FILE_PATH_INDEX_DIRS_URL))) + if (!err && !string_ends_with(subdir_path, + file_path_str(FILE_PATH_INDEX_DIRS_URL))) { char parent_dir[PATH_MAX_LENGTH]; @@ -219,7 +220,8 @@ finish: free(data); } - if (!err && !strstr(state->path, file_path_str(FILE_PATH_INDEX_DIRS_URL))) + if (!err && + !string_ends_with(state->path, file_path_str(FILE_PATH_INDEX_DIRS_URL))) { char *parent_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); char *parent_dir_encoded = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); diff --git a/tasks/task_http.c b/tasks/task_http.c index 3a76545963..415591b520 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -353,7 +353,7 @@ void* task_push_http_transfer_file(const char* url, bool mute, strlcpy(tmp, msg_hash_to_str(MSG_DOWNLOADING), sizeof(tmp)); strlcat(tmp, " ", sizeof(tmp)); - if (strstr(s, ".index")) + if (string_ends_with(s, ".index")) strlcat(tmp, msg_hash_to_str(MSG_INDEX_FILE), sizeof(tmp)); else strlcat(tmp, s, sizeof(tmp));