From 25fefc1b3dcdc6362c44845687bea70dd350c33a Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Thu, 20 May 2021 14:12:08 +0800 Subject: [PATCH 1/8] Implement libretro input bitmask --- src/libretro/libretro.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index a0e4f656..0a2bd5c2 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -63,6 +63,7 @@ static bool option_showAdvancedOptions = false; static double option_sndFiltering = 0.5; static unsigned option_gbPalette = 0; static bool option_lcdfilter = false; + // filters static IFBFilterFunc ifb_filter_func = NULL; @@ -71,6 +72,7 @@ static unsigned systemWidth = gbaWidth; static unsigned systemHeight = gbaHeight; static EmulatedSystem* core = NULL; static IMAGE_TYPE type = IMAGE_UNKNOWN; +static bool libretro_supports_bitmasks = false; // global vars uint16_t systemColorMap16[0x10000]; @@ -643,6 +645,12 @@ void retro_init(void) rumble_cb = rumble.set_rumble_state; else rumble_cb = NULL; + + if (environ_cb(RETRO_ENVIRONMENT_GET_INPUT_BITMASKS, NULL)) + { + libretro_supports_bitmasks = true; + log_cb(RETRO_LOG_INFO, "SET_SUPPORT_INPUT_BITMASK: yes\n"); + } } static const char *gbGetCartridgeType(void) @@ -978,6 +986,7 @@ void retro_deinit(void) emulating = 0; core->emuCleanUp(); soundShutdown(); + libretro_supports_bitmasks = false; } void retro_reset(void) @@ -1414,6 +1423,7 @@ void updateInput_SolarSensor(void) static void updateInput_Joypad(void) { unsigned max_buttons = MAX_BUTTONS - ((type == IMAGE_GB) ? 2 : 0); // gb only has 8 buttons + int16_t inbuf = 0; for (unsigned port = 0; port < MAX_PLAYERS; port++) { @@ -1421,8 +1431,16 @@ static void updateInput_Joypad(void) input_buf[port] = 0; if (retropad_device[port] == RETRO_DEVICE_JOYPAD) { + if (libretro_supports_bitmasks) + inbuf = input_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_MASK); + else + { + for (int i = 0; i < (RETRO_DEVICE_ID_JOYPAD_R3 + 1); i++) + inbuf |= input_cb(0, RETRO_DEVICE_JOYPAD, 0, i) ? (1 << i) : 0; + } + for (unsigned button = 0; button < max_buttons; button++) - input_buf[port] |= input_cb(port, RETRO_DEVICE_JOYPAD, 0, binds[button]) << button; + input_buf[port] |= (inbuf & (1 << binds[button])) ? (1 << button) : 0; if (option_turboEnable) { /* Handle Turbo A & B buttons */ From 6afbc9a09c16e6689d4960d4ff11462f9fc5fa43 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Thu, 20 May 2021 13:15:05 +0800 Subject: [PATCH 2/8] Remove unused files and folders --- src/libretro/gbaconv/gbaconv.c | 199 -------------- src/libretro/msvc/msvc-2003-xbox1.bat | 47 ---- src/libretro/msvc/msvc-2003-xbox1.sln | 30 --- .../msvc-2003-xbox1/msvc-2003-xbox1.vcproj | 234 ---------------- src/libretro/msvc/msvc-2003-xbox1/stdint.h | 246 ----------------- src/libretro/msvc/msvc-2010-360.bat | 124 --------- src/libretro/msvc/msvc-2010-360.sln | 32 --- .../msvc/msvc-2010-360/msvc-2010-360.vcxproj | 254 ------------------ .../msvc-2010-360.vcxproj.filters | 62 ----- src/libretro/msvc/msvc-2010.sln | 20 -- src/libretro/msvc/msvc-2010/libretro.def | 27 -- src/libretro/msvc/msvc-2010/msvc-2010.vcxproj | 105 -------- .../msvc/msvc-2010/msvc-2010.vcxproj.filters | 78 ------ 13 files changed, 1458 deletions(-) delete mode 100644 src/libretro/gbaconv/gbaconv.c delete mode 100644 src/libretro/msvc/msvc-2003-xbox1.bat delete mode 100644 src/libretro/msvc/msvc-2003-xbox1.sln delete mode 100644 src/libretro/msvc/msvc-2003-xbox1/msvc-2003-xbox1.vcproj delete mode 100644 src/libretro/msvc/msvc-2003-xbox1/stdint.h delete mode 100644 src/libretro/msvc/msvc-2010-360.bat delete mode 100644 src/libretro/msvc/msvc-2010-360.sln delete mode 100644 src/libretro/msvc/msvc-2010-360/msvc-2010-360.vcxproj delete mode 100644 src/libretro/msvc/msvc-2010-360/msvc-2010-360.vcxproj.filters delete mode 100644 src/libretro/msvc/msvc-2010.sln delete mode 100644 src/libretro/msvc/msvc-2010/libretro.def delete mode 100644 src/libretro/msvc/msvc-2010/msvc-2010.vcxproj delete mode 100644 src/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters diff --git a/src/libretro/gbaconv/gbaconv.c b/src/libretro/gbaconv/gbaconv.c deleted file mode 100644 index afe98ecf..00000000 --- a/src/libretro/gbaconv/gbaconv.c +++ /dev/null @@ -1,199 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -enum save_type { EEPROM_512B, - EEPROM_8K, - FLASH_64K, - FLASH_128K, - SAVE_UNKNOWN }; - -static const char* save_type_to_string(enum save_type type) -{ - switch (type) { - case EEPROM_512B: - return "EEPROM 4kbit"; - case EEPROM_8K: - return "EEPROM 64kbit"; - case FLASH_64K: - return "FLASH 512kbit"; - case FLASH_128K: - return "FLASH 1MBit"; - - default: - return "Unknown type"; - } -} - -static bool scan_section(const uint8_t* data, unsigned size) -{ - for (unsigned i = 0; i < size; i++) { - if (data[i] != 0xff) - return true; - } - - return false; -} - -static enum save_type detect_save_type(const uint8_t* data, unsigned size) -{ - if (size == 512) - return EEPROM_512B; - if (size == 0x2000) - return EEPROM_8K; - if (size == 0x10000) - return FLASH_64K; - if (size == 0x20000) - return FLASH_128K; - - if (size == (0x20000 + 0x2000)) { - if (scan_section(data, 0x10000) && !scan_section(data + 0x10000, 0x10000)) - return FLASH_64K; - if (scan_section(data, 0x20000)) - return FLASH_128K; - - if (scan_section(data + 0x20000, 512) && !scan_section(data + 0x20000 + 512, 0x20000 - 512)) - return EEPROM_512B; - if (scan_section(data + 0x20000, 0x2000)) - return EEPROM_8K; - } - - return SAVE_UNKNOWN; -} - -static void dump_srm(FILE* file, const uint8_t* data, enum save_type type) -{ - void* buf = malloc(0x20000 + 0x2000); - memset(buf, 0xff, 0x20000 + 0x2000); - - switch (type) { - case EEPROM_512B: - fwrite(buf, 1, 0x20000, file); - fwrite(data, 1, 512, file); - fwrite(buf, 1, 0x2000 - 512, file); - break; - - case EEPROM_8K: - fwrite(buf, 1, 0x20000, file); - fwrite(data, 1, 0x2000, file); - break; - - case FLASH_64K: - fwrite(data, 1, 0x10000, file); - fwrite(buf, 1, 0x20000 + 0x2000 - 0x10000, file); - break; - - case FLASH_128K: - fwrite(data, 1, 0x20000, file); - fwrite(buf, 1, 0x2000, file); - break; - - default: - break; - } - - free(buf); -} - -static void dump_sav(FILE* file, const uint8_t* data, enum save_type type) -{ - switch (type) { - case EEPROM_512B: - fwrite(data + 0x20000, 1, 512, file); - break; - - case EEPROM_8K: - fwrite(data + 0x20000, 1, 0x2000, file); - break; - - case FLASH_64K: - fwrite(data, 1, 0x10000, file); - break; - - case FLASH_128K: - fwrite(data, 1, 0x20000, file); - break; - - default: - break; - } -} - -// One shot cowboy code :) - -int main(int argc, char* argv[]) -{ - if (argc != 2) { - fprintf(stderr, "Usage: %s \n", argv[0]); - return 1; - } - - FILE* file = fopen(argv[1], "rb"); - if (!file) { - fprintf(stderr, "Failed to open file \"%s\"\n", argv[1]); - goto error; - } - - fseek(file, 0, SEEK_END); - long len = ftell(file); - rewind(file); - - uint8_t* buffer = malloc(len); - if (!buffer) { - fprintf(stderr, "Failed to allocate memory!\n"); - goto error; - } - fread(buffer, 1, len, file); - fclose(file); - file = NULL; - - char* out_path = strdup(argv[1]); - char* split = strrchr(out_path, '.'); - const char* ext = NULL; - - if (split) { - *split = '\0'; - ext = split + 1; - - if (strcasecmp(ext, "srm") == 0) - strcat(out_path, ".sav"); - else if (strlen(ext) >= 3) - strcat(out_path, ".srm"); - else - ext = NULL; - } - - if (!ext) { - fprintf(stderr, "Cannot detect extension!\n"); - goto error; - } - - enum save_type type = detect_save_type(buffer, len); - printf("Detected save type: %s\n", save_type_to_string(type)); - - if (type == SAVE_UNKNOWN) { - fprintf(stderr, "Cannot infer save type ...\n"); - goto error; - } - - file = fopen(out_path, "wb"); - if (!file) - goto error; - - if (len == (0x20000 + 0x2000)) - dump_sav(file, buffer, type); - else - dump_srm(file, buffer, type); - fclose(file); - - return 0; - -error: - if (file) - fclose(file); - return 1; -} diff --git a/src/libretro/msvc/msvc-2003-xbox1.bat b/src/libretro/msvc/msvc-2003-xbox1.bat deleted file mode 100644 index 44db3003..00000000 --- a/src/libretro/msvc/msvc-2003-xbox1.bat +++ /dev/null @@ -1,47 +0,0 @@ -@SET VSINSTALLDIR=C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE -@SET VCINSTALLDIR=C:\Program Files\Microsoft Visual Studio .NET 2003 -@SET FrameworkDir=C:\WINDOWS\Microsoft.NET\Framework -@SET FrameworkVersion=v1.1.4322 -@SET FrameworkSDKDir=C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1 -@rem Root of Visual Studio common files. - -@if "%VSINSTALLDIR%"=="" goto Usage -@if "%VCINSTALLDIR%"=="" set VCINSTALLDIR=%VSINSTALLDIR% - -@rem -@rem Root of Visual Studio ide installed files. -@rem -@set DevEnvDir=%VSINSTALLDIR% - -@rem -@rem Root of Visual C++ installed files. -@rem -@set MSVCDir=%VCINSTALLDIR%\VC7 - -@rem -@echo Setting environment for using Microsoft Visual Studio .NET 2003 tools. -@echo (If you have another version of Visual Studio or Visual C++ installed and wish -@echo to use its tools from the command line, run vcvars32.bat for that version.) -@rem - -@REM %VCINSTALLDIR%\Common7\Tools dir is added only for real setup. - -@set PATH=%DevEnvDir%;%MSVCDir%\BIN;%VCINSTALLDIR%\Common7\Tools;%VCINSTALLDIR%\Common7\Tools\bin\prerelease;%VCINSTALLDIR%\Common7\Tools\bin;%FrameworkSDKDir%\bin;%FrameworkDir%\%FrameworkVersion%;%PATH%; -@set INCLUDE=%MSVCDir%\ATLMFC\INCLUDE;%MSVCDir%\INCLUDE;%FrameworkSDKDir%\include;%INCLUDE%;%XDK%\xbox\include -@set LIB=%MSVCDir%\ATLMFC\LIB;%MSVCDir%\LIB;%MSVCDir%\PlatformSDK\lib;%XDK%\lib;%XDK%\xbox\lib;%LIB% - -@goto end - -:Usage - -@echo. VSINSTALLDIR variable is not set. -@echo. -@echo SYNTAX: %0 - -@goto end - -:end - -devenv /clean Release msvc-2003-xbox1.sln -devenv /build Release msvc-2003-xbox1.sln -exit diff --git a/src/libretro/msvc/msvc-2003-xbox1.sln b/src/libretro/msvc/msvc-2003-xbox1.sln deleted file mode 100644 index f52e31b5..00000000 --- a/src/libretro/msvc/msvc-2003-xbox1.sln +++ /dev/null @@ -1,30 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vbanext-msvc2003-xbox1", "msvc-2003-xbox1/msvc-2003-xbox1.vcproj", "{BDCB70E0-EEBB-404A-9874-9A2E22A4A2B3}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Profile = Profile - Profile_FastCap = Profile_FastCap - Release = Release - Release_LTCG = Release_LTCG - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {BDCB70E0-EEBB-404A-9874-9A2E22A4A2B3}.Debug.ActiveCfg = Debug|Xbox - {BDCB70E0-EEBB-404A-9874-9A2E22A4A2B3}.Debug.Build.0 = Debug|Xbox - {BDCB70E0-EEBB-404A-9874-9A2E22A4A2B3}.Profile.ActiveCfg = Profile|Xbox - {BDCB70E0-EEBB-404A-9874-9A2E22A4A2B3}.Profile.Build.0 = Profile|Xbox - {BDCB70E0-EEBB-404A-9874-9A2E22A4A2B3}.Profile_FastCap.ActiveCfg = Profile_FastCap|Xbox - {BDCB70E0-EEBB-404A-9874-9A2E22A4A2B3}.Profile_FastCap.Build.0 = Profile_FastCap|Xbox - {BDCB70E0-EEBB-404A-9874-9A2E22A4A2B3}.Release.ActiveCfg = Release|Xbox - {BDCB70E0-EEBB-404A-9874-9A2E22A4A2B3}.Release.Build.0 = Release|Xbox - {BDCB70E0-EEBB-404A-9874-9A2E22A4A2B3}.Release_LTCG.ActiveCfg = Release_LTCG|Xbox - {BDCB70E0-EEBB-404A-9874-9A2E22A4A2B3}.Release_LTCG.Build.0 = Release_LTCG|Xbox - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal diff --git a/src/libretro/msvc/msvc-2003-xbox1/msvc-2003-xbox1.vcproj b/src/libretro/msvc/msvc-2003-xbox1/msvc-2003-xbox1.vcproj deleted file mode 100644 index ecc0de8e..00000000 --- a/src/libretro/msvc/msvc-2003-xbox1/msvc-2003-xbox1.vcproj +++ /dev/null @@ -1,234 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/libretro/msvc/msvc-2003-xbox1/stdint.h b/src/libretro/msvc/msvc-2003-xbox1/stdint.h deleted file mode 100644 index 78c4f689..00000000 --- a/src/libretro/msvc/msvc-2003-xbox1/stdint.h +++ /dev/null @@ -1,246 +0,0 @@ -// ISO C9x compliant stdint.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// -// Copyright (c) 2006-2008 Alexander Chemeris -// -// Redistribution and use 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. The name of the author may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// 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. -// -/////////////////////////////////////////////////////////////////////////////// -#ifndef __RARCH_STDINT_H -#define __RARCH_STDINT_H - -#if _MSC_VER && (_MSC_VER < 1600) -// pre-MSVC 2010 needs an implementation of stdint.h - -#if _MSC_VER > 1000 -#pragma once -#endif - -#include - -// For Visual Studio 6 in C++ mode and for many Visual Studio versions when -// compiling for ARM we should wrap include with 'extern "C++" {}' -// or compiler give many errors like this: -// error C2733: second C linkage of overloaded function 'wmemchr' not allowed -#ifdef __cplusplus -extern "C" { -#endif -#include -#ifdef __cplusplus -} -#endif - -// Define _W64 macros to mark types changing their size, like intptr_t. -#ifndef _W64 -#if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 -#define _W64 __w64 -#else -#define _W64 -#endif -#endif - -// 7.18.1 Integer types - -// 7.18.1.1 Exact-width integer types - -// Visual Studio 6 and Embedded Visual C++ 4 doesn't -// realize that, e.g. char has the same size as __int8 -// so we give up on __intX for them. -#if (_MSC_VER < 1300) -typedef signed char int8_t; -typedef signed short int16_t; -typedef signed int int32_t; -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -#else -typedef signed __int8 int8_t; -typedef signed __int16 int16_t; -typedef signed __int32 int32_t; -typedef unsigned __int8 uint8_t; -typedef unsigned __int16 uint16_t; -typedef unsigned __int32 uint32_t; -#endif -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; - -// 7.18.1.2 Minimum-width integer types -typedef int8_t int_least8_t; -typedef int16_t int_least16_t; -typedef int32_t int_least32_t; -typedef int64_t int_least64_t; -typedef uint8_t uint_least8_t; -typedef uint16_t uint_least16_t; -typedef uint32_t uint_least32_t; -typedef uint64_t uint_least64_t; - -// 7.18.1.3 Fastest minimum-width integer types -typedef int8_t int_fast8_t; -typedef int16_t int_fast16_t; -typedef int32_t int_fast32_t; -typedef int64_t int_fast64_t; -typedef uint8_t uint_fast8_t; -typedef uint16_t uint_fast16_t; -typedef uint32_t uint_fast32_t; -typedef uint64_t uint_fast64_t; - -// 7.18.1.4 Integer types capable of holding object pointers -#ifdef _WIN64 // [ -typedef signed __int64 intptr_t; -typedef unsigned __int64 uintptr_t; -#else // _WIN64 ][ -typedef _W64 signed int intptr_t; -typedef _W64 unsigned int uintptr_t; -#endif // _WIN64 ] - -// 7.18.1.5 Greatest-width integer types -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; - -// 7.18.2 Limits of specified-width integer types - -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and - // footnote 221 at page 259 - -// 7.18.2.1 Limits of exact-width integer types -#define INT8_MIN ((int8_t)_I8_MIN) -#define INT8_MAX _I8_MAX -#define INT16_MIN ((int16_t)_I16_MIN) -#define INT16_MAX _I16_MAX -#define INT32_MIN ((int32_t)_I32_MIN) -#define INT32_MAX _I32_MAX -#define INT64_MIN ((int64_t)_I64_MIN) -#define INT64_MAX _I64_MAX -#define UINT8_MAX _UI8_MAX -#define UINT16_MAX _UI16_MAX -#define UINT32_MAX _UI32_MAX -#define UINT64_MAX _UI64_MAX - -// 7.18.2.2 Limits of minimum-width integer types -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MIN INT64_MIN -#define INT_LEAST64_MAX INT64_MAX -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -// 7.18.2.3 Limits of fastest minimum-width integer types -#define INT_FAST8_MIN INT8_MIN -#define INT_FAST8_MAX INT8_MAX -#define INT_FAST16_MIN INT16_MIN -#define INT_FAST16_MAX INT16_MAX -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MIN INT64_MIN -#define INT_FAST64_MAX INT64_MAX -#define UINT_FAST8_MAX UINT8_MAX -#define UINT_FAST16_MAX UINT16_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX - -// 7.18.2.4 Limits of integer types capable of holding object pointers -#ifdef _WIN64 // [ -#define INTPTR_MIN INT64_MIN -#define INTPTR_MAX INT64_MAX -#define UINTPTR_MAX UINT64_MAX -#else // _WIN64 ][ -#define INTPTR_MIN INT32_MIN -#define INTPTR_MAX INT32_MAX -#define UINTPTR_MAX UINT32_MAX -#endif // _WIN64 ] - -// 7.18.2.5 Limits of greatest-width integer types -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -// 7.18.3 Limits of other integer types - -#ifdef _WIN64 // [ -#define PTRDIFF_MIN _I64_MIN -#define PTRDIFF_MAX _I64_MAX -#else // _WIN64 ][ -#define PTRDIFF_MIN _I32_MIN -#define PTRDIFF_MAX _I32_MAX -#endif // _WIN64 ] - -#define SIG_ATOMIC_MIN INT_MIN -#define SIG_ATOMIC_MAX INT_MAX - -#ifndef SIZE_MAX // [ -#ifdef _WIN64 // [ -#define SIZE_MAX _UI64_MAX -#else // _WIN64 ][ -#define SIZE_MAX _UI32_MAX -#endif // _WIN64 ] -#endif // SIZE_MAX ] - -// WCHAR_MIN and WCHAR_MAX are also defined in -#ifndef WCHAR_MIN // [ -#define WCHAR_MIN 0 -#endif // WCHAR_MIN ] -#ifndef WCHAR_MAX // [ -#define WCHAR_MAX _UI16_MAX -#endif // WCHAR_MAX ] - -#define WINT_MIN 0 -#define WINT_MAX _UI16_MAX - -#endif // __STDC_LIMIT_MACROS ] - -// 7.18.4 Limits of other integer types - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 - -// 7.18.4.1 Macros for minimum-width integer constants - -#define INT8_C(val) val##i8 -#define INT16_C(val) val##i16 -#define INT32_C(val) val##i32 -#define INT64_C(val) val##i64 - -#define UINT8_C(val) val##ui8 -#define UINT16_C(val) val##ui16 -#define UINT32_C(val) val##ui32 -#define UINT64_C(val) val##ui64 - -// 7.18.4.2 Macros for greatest-width integer constants -#define INTMAX_C INT64_C -#define UINTMAX_C UINT64_C - -#endif // __STDC_CONSTANT_MACROS ] - -#else -// sanity for everything else -#include -#endif - -#endif diff --git a/src/libretro/msvc/msvc-2010-360.bat b/src/libretro/msvc/msvc-2010-360.bat deleted file mode 100644 index 0e5fde55..00000000 --- a/src/libretro/msvc/msvc-2010-360.bat +++ /dev/null @@ -1,124 +0,0 @@ -@echo off - -@echo Setting environment for using Microsoft Visual Studio 2010 x86 tools. - -@call :GetVSCommonToolsDir -@if "%VS100COMNTOOLS%"=="" goto error_no_VS100COMNTOOLSDIR - -@call "%VS100COMNTOOLS%VCVarsQueryRegistry.bat" 32bit No64bit - -@if "%VSINSTALLDIR%"=="" goto error_no_VSINSTALLDIR -@if "%FrameworkDir32%"=="" goto error_no_FrameworkDIR32 -@if "%FrameworkVersion32%"=="" goto error_no_FrameworkVer32 -@if "%Framework35Version%"=="" goto error_no_Framework35Version - -@set FrameworkDir=%FrameworkDir32% -@set FrameworkVersion=%FrameworkVersion32% - -@if not "%WindowsSdkDir%" == "" ( - @set "PATH=%WindowsSdkDir%bin\NETFX 4.0 Tools;%WindowsSdkDir%bin;%PATH%" - @set "INCLUDE=%WindowsSdkDir%include;%INCLUDE%" - @set "LIB=%WindowsSdkDir%lib;%LIB%" -) - -@rem -@rem Root of Visual Studio IDE installed files. -@rem -@set DevEnvDir=%VSINSTALLDIR%Common7\IDE\ - -@rem PATH -@rem ---- -@if exist "%VSINSTALLDIR%Team Tools\Performance Tools" ( - @set "PATH=%VSINSTALLDIR%Team Tools\Performance Tools;%PATH%" -) -@if exist "%ProgramFiles%\HTML Help Workshop" set PATH=%ProgramFiles%\HTML Help Workshop;%PATH% -@if exist "%ProgramFiles(x86)%\HTML Help Workshop" set PATH=%ProgramFiles(x86)%\HTML Help Workshop;%PATH% -@if exist "%VCINSTALLDIR%VCPackages" set PATH=%VCINSTALLDIR%VCPackages;%PATH% -@set PATH=%FrameworkDir%%Framework35Version%;%PATH% -@set PATH=%FrameworkDir%%FrameworkVersion%;%PATH% -@set PATH=%VSINSTALLDIR%Common7\Tools;%PATH% -@if exist "%VCINSTALLDIR%BIN" set PATH=%VCINSTALLDIR%BIN;%PATH% -@set PATH=%DevEnvDir%;%PATH% - -@if exist "%VSINSTALLDIR%VSTSDB\Deploy" ( - @set "PATH=%VSINSTALLDIR%VSTSDB\Deploy;%PATH%" -) - -@if not "%FSHARPINSTALLDIR%" == "" ( - @set "PATH=%FSHARPINSTALLDIR%;%PATH%" -) - -@rem INCLUDE -@rem ------- -@if exist "%VCINSTALLDIR%ATLMFC\INCLUDE" set INCLUDE=%VCINSTALLDIR%ATLMFC\INCLUDE;%INCLUDE% -@if exist "%VCINSTALLDIR%INCLUDE" set INCLUDE=%VCINSTALLDIR%INCLUDE;%INCLUDE% - -@rem LIB -@rem --- -@if exist "%VCINSTALLDIR%ATLMFC\LIB" set LIB=%VCINSTALLDIR%ATLMFC\LIB;%LIB% -@if exist "%VCINSTALLDIR%LIB" set LIB=%VCINSTALLDIR%LIB;%LIB% - -@rem LIBPATH -@rem ------- -@if exist "%VCINSTALLDIR%ATLMFC\LIB" set LIBPATH=%VCINSTALLDIR%ATLMFC\LIB;%LIBPATH% -@if exist "%VCINSTALLDIR%LIB" set LIBPATH=%VCINSTALLDIR%LIB;%LIBPATH% -@set LIBPATH=%FrameworkDir%%Framework35Version%;%LIBPATH% -@set LIBPATH=%FrameworkDir%%FrameworkVersion%;%LIBPATH% - -@goto end - -@REM ----------------------------------------------------------------------- -:GetVSCommonToolsDir -@set VS100COMNTOOLS= -@call :GetVSCommonToolsDirHelper32 HKLM > nul 2>&1 -@if errorlevel 1 call :GetVSCommonToolsDirHelper32 HKCU > nul 2>&1 -@if errorlevel 1 call :GetVSCommonToolsDirHelper64 HKLM > nul 2>&1 -@if errorlevel 1 call :GetVSCommonToolsDirHelper64 HKCU > nul 2>&1 -@exit /B 0 - -:GetVSCommonToolsDirHelper32 -@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" /v "10.0"') DO ( - @if "%%i"=="10.0" ( - @SET "VS100COMNTOOLS=%%k" - ) -) -@if "%VS100COMNTOOLS%"=="" exit /B 1 -@SET "VS100COMNTOOLS=%VS100COMNTOOLS%Common7\Tools\" -@exit /B 0 - -:GetVSCommonToolsDirHelper64 -@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7" /v "10.0"') DO ( - @if "%%i"=="10.0" ( - @SET "VS100COMNTOOLS=%%k" - ) -) -@if "%VS100COMNTOOLS%"=="" exit /B 1 -@SET "VS100COMNTOOLS=%VS100COMNTOOLS%Common7\Tools\" -@exit /B 0 - -@REM ----------------------------------------------------------------------- -:error_no_VS100COMNTOOLSDIR -@echo ERROR: Cannot determine the location of the VS Common Tools folder. -@goto end - -:error_no_VSINSTALLDIR -@echo ERROR: Cannot determine the location of the VS installation. -@goto end - -:error_no_FrameworkDIR32 -@echo ERROR: Cannot determine the location of the .NET Framework 32bit installation. -@goto end - -:error_no_FrameworkVer32 -@echo ERROR: Cannot determine the version of the .NET Framework 32bit installation. -@goto end - -:error_no_Framework35Version -@echo ERROR: Cannot determine the .NET Framework 3.5 version. -@goto end - -:end - -msbuild msvc-2010-360.sln /p:Configuration=Release /target:clean -msbuild msvc-2010-360.sln /p:Configuration=Release -exit diff --git a/src/libretro/msvc/msvc-2010-360.sln b/src/libretro/msvc/msvc-2010-360.sln deleted file mode 100644 index 9978fb3b..00000000 --- a/src/libretro/msvc/msvc-2010-360.sln +++ /dev/null @@ -1,32 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mvc-2010-360", "msvc-2010-360/msvc-2010-360.vcxproj", "{DB17AF79-EB79-4062-ACA8-F82864712DA0}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - CodeAnalysis|Xbox 360 = CodeAnalysis|Xbox 360 - Debug|Xbox 360 = Debug|Xbox 360 - Profile_FastCap|Xbox 360 = Profile_FastCap|Xbox 360 - Profile|Xbox 360 = Profile|Xbox 360 - Release_LTCG|Xbox 360 = Release_LTCG|Xbox 360 - Release|Xbox 360 = Release|Xbox 360 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DB17AF79-EB79-4062-ACA8-F82864712DA0}.CodeAnalysis|Xbox 360.ActiveCfg = CodeAnalysis|Xbox 360 - {DB17AF79-EB79-4062-ACA8-F82864712DA0}.CodeAnalysis|Xbox 360.Build.0 = CodeAnalysis|Xbox 360 - {DB17AF79-EB79-4062-ACA8-F82864712DA0}.Debug|Xbox 360.ActiveCfg = Debug|Xbox 360 - {DB17AF79-EB79-4062-ACA8-F82864712DA0}.Debug|Xbox 360.Build.0 = Debug|Xbox 360 - {DB17AF79-EB79-4062-ACA8-F82864712DA0}.Profile_FastCap|Xbox 360.ActiveCfg = Profile_FastCap|Xbox 360 - {DB17AF79-EB79-4062-ACA8-F82864712DA0}.Profile_FastCap|Xbox 360.Build.0 = Profile_FastCap|Xbox 360 - {DB17AF79-EB79-4062-ACA8-F82864712DA0}.Profile|Xbox 360.ActiveCfg = Profile|Xbox 360 - {DB17AF79-EB79-4062-ACA8-F82864712DA0}.Profile|Xbox 360.Build.0 = Profile|Xbox 360 - {DB17AF79-EB79-4062-ACA8-F82864712DA0}.Release_LTCG|Xbox 360.ActiveCfg = Release_LTCG|Xbox 360 - {DB17AF79-EB79-4062-ACA8-F82864712DA0}.Release_LTCG|Xbox 360.Build.0 = Release_LTCG|Xbox 360 - {DB17AF79-EB79-4062-ACA8-F82864712DA0}.Release|Xbox 360.ActiveCfg = Release|Xbox 360 - {DB17AF79-EB79-4062-ACA8-F82864712DA0}.Release|Xbox 360.Build.0 = Release|Xbox 360 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/src/libretro/msvc/msvc-2010-360/msvc-2010-360.vcxproj b/src/libretro/msvc/msvc-2010-360/msvc-2010-360.vcxproj deleted file mode 100644 index 86b93a5b..00000000 --- a/src/libretro/msvc/msvc-2010-360/msvc-2010-360.vcxproj +++ /dev/null @@ -1,254 +0,0 @@ - - - - - CodeAnalysis - Xbox 360 - - - Debug - Xbox 360 - - - Profile - Xbox 360 - - - Profile_FastCap - Xbox 360 - - - Release - Xbox 360 - - - Release_LTCG - Xbox 360 - - - - - - - - - - - - - - - - - - - - - {DB17AF79-EB79-4062-ACA8-F82864712DA0} - Xbox360Proj - vba-next-libretro-360 - - - - StaticLibrary - MultiByte - - - StaticLibrary - MultiByte - - - StaticLibrary - MultiByte - - - StaticLibrary - MultiByte - - - StaticLibrary - MultiByte - true - - - StaticLibrary - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - $(OutDir)vba_next_libretro_xdk360$(TargetExt) - - - $(OutDir)vba_next_libretro_xdk360$(TargetExt) - - - $(OutDir)vba_next_libretro_xdk360$(TargetExt) - - - $(OutDir)vba_next_libretro_xdk360$(TargetExt) - - - $(OutDir)vba_next_libretro_xdk360$(TargetExt) - - - $(OutDir)vba_next_libretro_xdk360$(TargetExt) - - - - NotUsing - Level3 - ProgramDatabase - Disabled - false - true - false - $(OutDir)$(ProjectName).pch - MultiThreadedDebug - _DEBUG;_XBOX;_LIB;;__LIBRETRO__;SPEEDHAX;__POWERPC__;__ppc__;WORDS_BIGENDIAN;BLARGG_BIG_ENDIAN;INLINE=_inline;%(PreprocessorDefinitions);_XBOX360;FRONTEND_SUPPORTS_RGB565 - Callcap - $(SolutionDir)\..\libretro;$(SolutionDir)\..\src;$(SolutionDir)\..\src\common;$(SolutionDir)\..\src\gb;$(SolutionDir)\..\src\gba;%(AdditionalIncludeDirectories) - - - true - - - - - NotUsing - Level4 - ProgramDatabase - Disabled - false - true - AnalyzeOnly - false - $(OutDir)$(ProjectName).pch - MultiThreadedDebug - _DEBUG;_XBOX;_LIB;%(PreprocessorDefinitions);_XBOX360;FRONTEND_SUPPORTS_RGB565 - Callcap - $(SolutionDir)\..\libretro;$(SolutionDir)\..\src;$(SolutionDir)\..\src\common;$(SolutionDir)\..\src\gb;$(SolutionDir)\..\src\gba;%(AdditionalIncludeDirectories) - - - true - - - - - Level3 - NotUsing - Full - true - false - true - ProgramDatabase - Size - false - $(OutDir)$(ProjectName).pch - MultiThreaded - NDEBUG;_XBOX;PROFILE;_LIB;%(PreprocessorDefinitions);_XBOX360;FRONTEND_SUPPORTS_RGB565 - Callcap - $(SolutionDir)\..\libretro;$(SolutionDir)\..\src;$(SolutionDir)\..\src\common;$(SolutionDir)\..\src\gb;$(SolutionDir)\..\src\gba;%(AdditionalIncludeDirectories) - - - true - false - xapilib.lib;%(IgnoreSpecificDefaultLibraries) - true - - - - - Level3 - NotUsing - Full - true - false - true - ProgramDatabase - Fastcap - Size - false - $(OutDir)$(ProjectName).pch - MultiThreaded - NDEBUG;_XBOX;PROFILE;FASTCAP;_LIB;%(PreprocessorDefinitions);_XBOX360;FRONTEND_SUPPORTS_RGB565 - $(SolutionDir)\..\libretro;$(SolutionDir)\..\src;$(SolutionDir)\..\src\common;$(SolutionDir)\..\src\gb;$(SolutionDir)\..\src\gba;%(AdditionalIncludeDirectories) - - - true - false - true - - - - - Level3 - NotUsing - Full - true - true - ProgramDatabase - Speed - false - false - $(OutDir)$(ProjectName).pch - MultiThreaded - NDEBUG;_XBOX;_LIB;__LIBRETRO__;SPEEDHAX;__POWERPC__;__ppc__;WORDS_BIGENDIAN;BLARGG_BIG_ENDIAN;INLINE=_inline;USE_CACHE_PREFETCH;BRANCHLESS_GBA_GFX;%(PreprocessorDefinitions);_XBOX360;FRONTEND_SUPPORTS_RGB565 - $(SolutionDir)\..\libretro;$(SolutionDir)\..\src;$(SolutionDir)\..\src\common;$(SolutionDir)\..\src\gb;$(SolutionDir)\..\src\gba;%(AdditionalIncludeDirectories) - true - true - - - true - true - true - - - - - Level3 - NotUsing - Full - true - true - ProgramDatabase - Size - false - false - $(OutDir)$(ProjectName).pch - MultiThreaded - NDEBUG;_XBOX;LTCG;_LIB;__LIBRETRO__;USE_CACHE_PREFETCH;BRANCHLESS_GBA_GFX;SPEEDHAX;__POWERPC__;__ppc__;WORDS_BIGENDIAN;BLARGG_BIG_ENDIAN;INLINE=_inline;%(PreprocessorDefinitions);_XBOX360;FRONTEND_SUPPORTS_RGB565 - $(SolutionDir)\..\libretro;$(SolutionDir)\..\src;$(SolutionDir)\..\src\common;$(SolutionDir)\..\src\gb;$(SolutionDir)\..\src\gba;%(AdditionalIncludeDirectories) - true - - - true - true - true - - - - - - diff --git a/src/libretro/msvc/msvc-2010-360/msvc-2010-360.vcxproj.filters b/src/libretro/msvc/msvc-2010-360/msvc-2010-360.vcxproj.filters deleted file mode 100644 index c93fc424..00000000 --- a/src/libretro/msvc/msvc-2010-360/msvc-2010-360.vcxproj.filters +++ /dev/null @@ -1,62 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {d19de43b-0337-4673-9b9e-1892d348647d} - - - {becd444c-3df5-4a9e-9885-8a181058095d} - - - - - Header Files\libretro - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files\libretro - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/src/libretro/msvc/msvc-2010.sln b/src/libretro/msvc/msvc-2010.sln deleted file mode 100644 index d7ef2d09..00000000 --- a/src/libretro/msvc/msvc-2010.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "msvc-2010", "msvc-2010/msvc-2010.vcxproj", "{C461207F-8F4F-4BFB-A90D-25298F37B47D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C461207F-8F4F-4BFB-A90D-25298F37B47D}.Debug|Win32.ActiveCfg = Debug|Win32 - {C461207F-8F4F-4BFB-A90D-25298F37B47D}.Debug|Win32.Build.0 = Debug|Win32 - {C461207F-8F4F-4BFB-A90D-25298F37B47D}.Release|Win32.ActiveCfg = Release|Win32 - {C461207F-8F4F-4BFB-A90D-25298F37B47D}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/src/libretro/msvc/msvc-2010/libretro.def b/src/libretro/msvc/msvc-2010/libretro.def deleted file mode 100644 index 2a71c098..00000000 --- a/src/libretro/msvc/msvc-2010/libretro.def +++ /dev/null @@ -1,27 +0,0 @@ -LIBRARY "libretro-prboom msvc2010" -EXPORTS -retro_set_environment -retro_set_video_refresh -retro_set_audio_sample -retro_set_audio_sample_batch -retro_set_input_poll -retro_set_input_state -retro_init -retro_deinit -retro_api_version -retro_get_system_info -retro_get_system_av_info -retro_set_controller_port_device -retro_reset -retro_run -retro_serialize_size -retro_serialize -retro_unserialize -retro_cheat_reset -retro_cheat_set -retro_load_game -retro_load_game_special -retro_unload_game -retro_get_region -retro_get_memory_data -retro_get_memory_size diff --git a/src/libretro/msvc/msvc-2010/msvc-2010.vcxproj b/src/libretro/msvc/msvc-2010/msvc-2010.vcxproj deleted file mode 100644 index 4492e952..00000000 --- a/src/libretro/msvc/msvc-2010/msvc-2010.vcxproj +++ /dev/null @@ -1,105 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {C461207F-8F4F-4BFB-A90D-25298F37B47D} - Win32Proj - msvc2010 - vba-next - - - - DynamicLibrary - true - Unicode - - - DynamicLibrary - false - true - Unicode - - - - - - - - - - - - - true - libretro - - - false - libretro - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;MSVC2010_EXPORTS;_CRT_SECURE_NO_WARNINGS;LSB_FIRST;SPEEDHAX=1;__LIBRETRO__;INLINE=_inline;%(PreprocessorDefinitions);FRONTEND_SUPPORTS_RGB565 - $(SolutionDir)\..\src\common;$(SolutionDir)\..\src\gb;$(SolutionDir)\..\src\gba;$(SolutionDir)\..\src\;$(SolutionDir)\..\libretro;%(AdditionalIncludeDirectories) - - - Windows - true - libretro.def - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;MSVC2010_EXPORTS;_CRT_SECURE_NO_WARNINGS;LSB_FIRST;SPEEDHAX=1;__LIBRETRO__;INLINE=_inline;%(PreprocessorDefinitions);FRONTEND_SUPPORTS_RGB565 - $(SolutionDir)\..\src\common;$(SolutionDir)\..\src\gb;$(SolutionDir)\..\src\gba;$(SolutionDir)\..\src\;$(SolutionDir)\..\libretro;%(AdditionalIncludeDirectories) - - - Windows - true - true - true - libretro.def - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters b/src/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters deleted file mode 100644 index 543d7d22..00000000 --- a/src/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters +++ /dev/null @@ -1,78 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {3ed03eb4-3d22-42ca-b2ab-1058e771db27} - - - {01290b17-a062-4772-8a90-1fb347398419} - - - {9553246f-4fb1-41ce-807d-bd3c3dc6f564} - - - {d5a23baf-0d6e-4d49-a81e-f1320c3186cc} - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files\gba - - - Header Files\gba - - - Header Files\gba - - - Header Files\gba - - - Header Files\libretro - - - Header Files\gba - - - Header Files\common - - - Header Files\common - - - - - Source Files\libretro - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file From 11bd3e0eeeea593cfa5829a06366664345a36470 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Thu, 20 May 2021 13:24:40 +0800 Subject: [PATCH 3/8] Silence warning [-Wsign-compare] --- src/libretro/UtilRetro.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libretro/UtilRetro.cpp b/src/libretro/UtilRetro.cpp index 17a729a4..9217d745 100644 --- a/src/libretro/UtilRetro.cpp +++ b/src/libretro/UtilRetro.cpp @@ -158,7 +158,7 @@ uint8_t *utilLoad(const char *file, bool (*accept)(const char *), uint8_t *data, } } - if (fread(image, 1, size, fp) != size) { + if (fread(image, 1, size, fp) != (size_t)size) { log("Failed to read from %s", file); fclose(fp); return NULL; From 21c08e9d9f5f33ed429ecbd378acfa375feb99f8 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Thu, 20 May 2021 15:01:40 +0800 Subject: [PATCH 4/8] Cleanup unused variables --- src/libretro/UtilRetro.cpp | 8 -------- src/libretro/libretro.cpp | 2 -- 2 files changed, 10 deletions(-) diff --git a/src/libretro/UtilRetro.cpp b/src/libretro/UtilRetro.cpp index 9217d745..5a854f0d 100644 --- a/src/libretro/UtilRetro.cpp +++ b/src/libretro/UtilRetro.cpp @@ -43,14 +43,6 @@ bool cpuIsMultiBoot = false; const char* loadDotCodeFile; const char* saveDotCodeFile; -extern int systemColorDepth; -extern int systemRedShift; -extern int systemGreenShift; -extern int systemBlueShift; - -extern uint16_t systemColorMap16[0x10000]; -extern uint32_t systemColorMap32[0x10000]; - bool utilWritePNGFile(const char* fileName, int w, int h, uint8_t* pix) { return false; diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index 0a2bd5c2..512fc5b5 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -82,11 +82,9 @@ int systemRedShift = 0; int systemBlueShift = 0; int systemGreenShift = 0; int systemColorDepth = 32; -int systemDebug = 0; int systemVerbose = 0; int systemFrameSkip = 0; int systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; -int systemSpeed = 0; int emulating = 0; void (*dbgOutput)(const char* s, uint32_t addr); From 19aae231c096bcc3adc8b00df5c58d2b46239c28 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Thu, 20 May 2021 15:06:41 +0800 Subject: [PATCH 5/8] Wrap these with #ifdef BKPT_SUPPORT --- src/gba/agbprint.cpp | 5 ++++- src/libretro/libretro.cpp | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gba/agbprint.cpp b/src/gba/agbprint.cpp index cb206e99..6820931d 100644 --- a/src/gba/agbprint.cpp +++ b/src/gba/agbprint.cpp @@ -56,7 +56,9 @@ void agbPrintFlush() uint32_t address = (debuggerReadHalfWord(0x9fe20fa) << 16); if (address != 0xfd0000 && address != 0x1fd0000) { +#ifdef BKPT_SUPPORT dbgOutput("Did you forget to call AGBPrintInit?\n", 0); +#endif // get rid of the text otherwise we will continue to be called debuggerWriteHalfWord(0x9fe20fc, put); return; @@ -66,12 +68,13 @@ void agbPrintFlush() while (get != put) { char c = data[get++]; +#ifdef BKPT_SUPPORT char s[2]; s[0] = c; s[1] = 0; - if (systemVerbose & VERBOSE_AGBPRINT) dbgOutput(s, 0); +#endif if (c == '\n') break; } diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index 512fc5b5..fb834fd6 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -87,8 +87,10 @@ int systemFrameSkip = 0; int systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; int emulating = 0; +#ifdef BKPT_SUPPORT void (*dbgOutput)(const char* s, uint32_t addr); void (*dbgSignal)(int sig, int number); +#endif // Dummy vars/funcs for serial io emulation without LINK communication related stuff #ifndef NO_LINK From 4e5b61f22092456acff87eab0784ecc50f06b5a3 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Fri, 21 May 2021 12:49:47 +0800 Subject: [PATCH 6/8] Backport fix https://github.com/libretro/vba-next/commit/e560db692f27d8656a71e20e24ee28f8e777e36e --- src/gba/GBAinline.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gba/GBAinline.h b/src/gba/GBAinline.h index a715a8ef..f4f5862c 100644 --- a/src/gba/GBAinline.h +++ b/src/gba/GBAinline.h @@ -133,8 +133,8 @@ static inline uint32_t CPUReadMemory(uint32_t address) case 15: if (cpuFlashEnabled | cpuSramEnabled) { // no need to swap this value = flashRead(address) * 0x01010101; + break; } - break; // default default: unreadable: @@ -288,6 +288,7 @@ static inline uint32_t CPUReadHalfWord(uint32_t address) if (cpuFlashEnabled | cpuSramEnabled) { // no need to swap this value = flashRead(address) * 0x0101; + break; } // default default: @@ -638,7 +639,7 @@ static inline void CPUWriteHalfWord(uint32_t address, uint16_t value) (*cpuSaveGameFunc)(address, (uint8_t)value); break; } - goto unwritable; + // fallthrough default: unwritable: #ifdef GBA_LOGGING From 025f3079b1eee43b2ad79901b396bebcb0142655 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Fri, 21 May 2021 14:50:20 +0800 Subject: [PATCH 7/8] GBA:Fix a few memory read/write issues - Affects both aligned and unaligned in unsigned 8/16/32 and signed 16 reads/writes - Rom out-of-bounds reads - SRAM r/w access - etc --- src/gba/GBA.cpp | 4 ++-- src/gba/GBAinline.h | 43 +++++++++++++++---------------------------- 2 files changed, 17 insertions(+), 30 deletions(-) diff --git a/src/gba/GBA.cpp b/src/gba/GBA.cpp index 1e23aa05..36f02f81 100644 --- a/src/gba/GBA.cpp +++ b/src/gba/GBA.cpp @@ -1506,7 +1506,7 @@ int CPULoadRom(const char* szFile) uint16_t* temp = (uint16_t*)(rom + ((romSize + 1) & ~1)); int i; - for (i = (romSize + 1) & ~1; i < romSize; i += 2) { + for (i = (romSize + 1) & ~1; i < SIZE_ROM; i += 2) { WRITE16LE(temp, (i >> 1) & 0xFFFF); temp++; } @@ -1599,7 +1599,7 @@ int CPULoadRomData(const char* data, int size) uint16_t* temp = (uint16_t*)(rom + ((romSize + 1) & ~1)); int i; - for (i = (romSize + 1) & ~1; i < romSize; i += 2) { + for (i = (romSize + 1) & ~1; i < SIZE_ROM; i += 2) { WRITE16LE(temp, (i >> 1) & 0xFFFF); temp++; } diff --git a/src/gba/GBAinline.h b/src/gba/GBAinline.h index f4f5862c..dd3d0eed 100644 --- a/src/gba/GBAinline.h +++ b/src/gba/GBAinline.h @@ -57,11 +57,6 @@ static inline uint32_t CPUReadMemory(uint32_t address) } #endif uint32_t value = 0; - uint32_t oldAddress = address; - - if (address & 3) { - address &= ~0x03; - } switch (address >> 24) { case 0: @@ -149,17 +144,17 @@ static inline uint32_t CPUReadMemory(uint32_t address) value = cpuDmaLast; } else { if (armState) { - return CPUReadMemoryQuick(reg[15].I); + value = CPUReadMemoryQuick(reg[15].I); } else { - return CPUReadHalfWordQuick(reg[15].I) | CPUReadHalfWordQuick(reg[15].I) << 16; + value = CPUReadHalfWordQuick(reg[15].I) | CPUReadHalfWordQuick(reg[15].I) << 16; } } break; } - if (oldAddress & 3) { + if (address & 3) { #ifdef C_CORE - int shift = (oldAddress & 3) << 3; + int shift = (address & 3) << 3; value = (value >> shift) | (value << (32 - shift)); #else #ifdef __GNUC__ @@ -167,10 +162,10 @@ static inline uint32_t CPUReadMemory(uint32_t address) "shl $3 ,%%ecx;" "ror %%cl, %0" : "=r"(value) - : "r"(value), "c"(oldAddress)); + : "r"(value), "c"(address)); #else __asm { - mov ecx, oldAddress; + mov ecx, address; and ecx, 3; shl ecx, 3; ror [dword ptr value], cl; @@ -180,10 +175,10 @@ static inline uint32_t CPUReadMemory(uint32_t address) } #ifdef GBA_LOGGING - if (oldAddress & 3) { + if (address & 3) { if (systemVerbose & VERBOSE_UNALIGNED_MEMORY) { log("Unaligned word read from: %08x at %08x (%08x)\n", - oldAddress, + address, armMode ? armNextPC - 4 : armNextPC - 2, value); } @@ -203,12 +198,7 @@ static inline uint32_t CPUReadHalfWord(uint32_t address) } #endif - uint32_t value; - uint32_t oldAddress = address; - - if (address & 1) { - address &= ~0x01; - } + uint32_t value = 0; switch (address >> 24) { case 0: @@ -217,7 +207,7 @@ static inline uint32_t CPUReadHalfWord(uint32_t address) #ifdef GBA_LOGGING if (systemVerbose & VERBOSE_ILLEGAL_READ) { log("Illegal halfword read from bios: %08x at %08x\n", - oldAddress, + address, armMode ? armNextPC - 4 : armNextPC - 2); } #endif @@ -304,20 +294,20 @@ static inline uint32_t CPUReadHalfWord(uint32_t address) #ifdef GBA_LOGGING if (systemVerbose & VERBOSE_ILLEGAL_READ) { log("Illegal halfword read: %08x at %08x (%08x)\n", - oldAddress, + address, reg[15].I, value); } #endif - return value; + break; } - if (oldAddress & 1) { + if (address & 1) { value = (value >> 8) | (value << 24); #ifdef GBA_LOGGING if (systemVerbose & VERBOSE_UNALIGNED_MEMORY) { log("Unaligned halfword read from: %08x at %08x (%08x)\n", - oldAddress, + address, armMode ? armNextPC - 4 : armNextPC - 2, value); } @@ -339,6 +329,7 @@ static inline int16_t CPUReadHalfWordSigned(uint32_t address) value); } #endif + return (int8_t)value; } return (int16_t)value; } @@ -459,8 +450,6 @@ static inline void CPUWriteMemory(uint32_t address, uint32_t value) } #endif - address &= 0xFFFFFFFC; - switch (address >> 24) { case 0x02: #ifdef BKPT_SUPPORT @@ -565,8 +554,6 @@ static inline void CPUWriteHalfWord(uint32_t address, uint16_t value) } #endif - address &= 0xFFFFFFFE; - switch (address >> 24) { case 2: #ifdef BKPT_SUPPORT From a9f35645b79356d06a4c7873ccdfebb1a2ef067a Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Fri, 21 May 2021 17:37:58 +0800 Subject: [PATCH 8/8] DMA:Linger last DMA on bus (Backport https://github.com/libretro/vba-next/commit/511e58c8490d9df6706af767812427e811906739) --- src/gba/GBA.cpp | 10 ++++++---- src/gba/GBAinline.h | 9 +++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/gba/GBA.cpp b/src/gba/GBA.cpp index 36f02f81..ee02097e 100644 --- a/src/gba/GBA.cpp +++ b/src/gba/GBA.cpp @@ -49,8 +49,9 @@ bool busPrefetchEnable = false; uint32_t busPrefetchCount = 0; int cpuDmaTicksToUpdate = 0; int cpuDmaCount = 0; -bool cpuDmaHack = false; +bool cpuDmaRunning = false; uint32_t cpuDmaLast = 0; +uint32_t cpuDmaPC = 0; int dummyAddress = 0; bool cpuBreakLoop = false; @@ -2302,7 +2303,8 @@ void doDMA(uint32_t& s, uint32_t& d, uint32_t si, uint32_t di, uint32_t c, int t int dw = 0; int sc = c; - cpuDmaHack = true; + cpuDmaRunning = true; + cpuDmaPC = reg[15].I; cpuDmaCount = c; // This is done to get the correct waitstates. if (sm > 15) @@ -2367,7 +2369,7 @@ void doDMA(uint32_t& s, uint32_t& d, uint32_t si, uint32_t di, uint32_t c, int t } cpuDmaTicksToUpdate += totalTicks; - cpuDmaHack = false; + cpuDmaRunning = false; } void CPUCheckDMA(int reason, int dmamask) @@ -3595,7 +3597,7 @@ void CPUReset() systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; - cpuDmaHack = false; + cpuDmaRunning = false; lastTime = systemGetClock(); diff --git a/src/gba/GBAinline.h b/src/gba/GBAinline.h index dd3d0eed..a9310552 100644 --- a/src/gba/GBAinline.h +++ b/src/gba/GBAinline.h @@ -20,8 +20,9 @@ extern bool cpuSramEnabled; extern bool cpuFlashEnabled; extern bool cpuEEPROMEnabled; extern bool cpuEEPROMSensorEnabled; -extern bool cpuDmaHack; +extern bool cpuDmaRunning; extern uint32_t cpuDmaLast; +extern uint32_t cpuDmaPC; extern bool timer0On; extern int timer0Ticks; extern int timer0ClockReload; @@ -140,7 +141,7 @@ static inline uint32_t CPUReadMemory(uint32_t address) armMode ? armNextPC - 4 : armNextPC - 2); } #endif - if (cpuDmaHack) { + if (cpuDmaRunning || ((reg[15].I - cpuDmaPC) == (armState ? 4 : 2))) { value = cpuDmaLast; } else { if (armState) { @@ -283,7 +284,7 @@ static inline uint32_t CPUReadHalfWord(uint32_t address) // default default: unreadable: - if (cpuDmaHack) { + if (cpuDmaRunning|| ((reg[15].I - cpuDmaPC) == (armState ? 4 : 2))) { value = cpuDmaLast & 0xFFFF; } else { int param = reg[15].I; @@ -416,7 +417,7 @@ static inline uint8_t CPUReadByte(uint32_t address) armMode ? armNextPC - 4 : armNextPC - 2); } #endif - if (cpuDmaHack) { + if (cpuDmaRunning || ((reg[15].I - cpuDmaPC) == (armState ? 4 : 2))) { return cpuDmaLast & 0xFF; } else { if (armState) {