From f355646fb8db9faef9ff6a98f4503b8dc600b3a1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 14 Mar 2021 11:50:23 +0100 Subject: [PATCH 01/19] Add ios-arm64/tvos-arm64 --- .gitlab-ci.yml | 28 +++++++++++++++++++++++++--- src/libretro/Makefile | 19 ++++++------------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a0bb99c9..89a8c21c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -44,7 +44,11 @@ include: - project: 'libretro-infrastructure/ci-templates' file: '/android-jni.yml' - # iOS 9 + # iOS + - project: 'libretro-infrastructure/ci-templates' + file: '/ios-arm64.yml' + + # iOS (armv7) - project: 'libretro-infrastructure/ci-templates' file: '/ios9.yml' @@ -57,6 +61,12 @@ include: - project: 'libretro-infrastructure/ci-templates' file: '/libnx-static.yml' + # tvOS (AppleTV) + - project: 'libretro-infrastructure/ci-templates' + file: '/tvos-arm64.yml' + + #################################### MISC ################################## + # Stages for building stages: - build-prepare @@ -129,11 +139,23 @@ android-x86: - .libretro-android-jni-x86 - .core-defs -# iOS 9 -libretro-build-ios-9: +# iOS +libretro-build-ios-arm64: + extends: + - .libretro-ios-arm64-make-default + - .core-defs + +# iOS (armv7) [iOS 9 and up] +libretro-build-ios9: extends: - .libretro-ios9-make-default - .core-defs + +# tvOS +libretro-build-tvos-arm64: + extends: + - .libretro-tvos-arm64-make-default + - .core-defs ################################### CONSOLES ################################# # PlayStation Vita diff --git a/src/libretro/Makefile b/src/libretro/Makefile index 5e444e2f..2c35083e 100644 --- a/src/libretro/Makefile +++ b/src/libretro/Makefile @@ -170,6 +170,7 @@ else ifneq (,$(findstring ios,$(platform))) TARGET := $(TARGET_NAME)_libretro_ios.dylib fpic := -fPIC SHARED := -dynamiclib + MINVERSION := ifeq ($(IOSSDK),) IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path) endif @@ -181,22 +182,12 @@ else ifneq (,$(findstring ios,$(platform))) CXX = clang++ -arch armv7 -isysroot $(IOSSDK) endif CFLAGS += -DIOS - ifeq ($(platform), ios-arm64) - CXX = clang++ -arch armv7 -isysroot $(IOSSDK) - CC = clang -arch arm64 -isysroot $(IOSSDK) - else - CC = clang -arch armv7 -isysroot $(IOSSDK) - CXX = clang++ -arch armv7 -isysroot $(IOSSDK) - endif ifeq ($(platform),$(filter $(platform),ios9 ios-arm64)) - CC += -miphoneos-version-min=8.0 - CXX += -miphoneos-version-min=8.0 - CFLAGS += -miphoneos-version-min=8.0 + MINVERSION = -miphoneos-version-min=8.0 else - CC += -miphoneos-version-min=5.0 - CXX += -miphoneos-version-min=5.0 - CFLAGS += -miphoneos-version-min=5.0 + MINVERSION = -miphoneos-version-min=5.0 endif + CFLAGS += $(MINVERSION) TILED_RENDERING=1 else ifeq ($(platform), tvos-arm64) @@ -207,6 +198,8 @@ ifeq ($(IOSSDK),) IOSSDK := $(shell xcodebuild -version -sdk appletvos Path) endif TILED_RENDERING = 1 + CC = cc -arch arm64 -isysroot $(IOSSDK) + CXX = c++ -arch arm64 -isysroot $(IOSSDK) # Theos iOS else ifeq ($(platform), theos_ios) From 210e79bb74ade118eac3adbea77e22f8e49e5948 Mon Sep 17 00:00:00 2001 From: ds22x Date: Tue, 16 Mar 2021 00:17:19 +0100 Subject: [PATCH 02/19] Add descriptions for the 'Interframe Blending' and 'LCD Color Filter' options --- src/libretro/libretro_core_options.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libretro/libretro_core_options.h b/src/libretro/libretro_core_options.h index 8d1d93f4..e05e46ba 100644 --- a/src/libretro/libretro_core_options.h +++ b/src/libretro/libretro_core_options.h @@ -192,7 +192,7 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_lcdfilter", "LCD Color Filter", - "TODO:", + "Darkens the onscreen colors by applying a screen filter.", { { "disabled", NULL }, { "enabled", NULL }, @@ -203,11 +203,11 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_interframeblending", "Interframe Blending", - "TODO:", + "Simulates LCD ghosting effects. 'Smart' attempts to detect screen flickering, and only performs a 50:50 mix on affected pixels, while 'Motion Blur' mimics natural LCD response times by combining multiple buffered frames. 'Smart' blending is required when playing games that aggressively exploit LCD ghosting for transparency effects (Wave Race, Chikyuu Kaihou Gun ZAS, F-Zero, the Boktai series...).", { { "disabled", NULL }, - { "smart", NULL }, - { "motion blur", NULL }, + { "smart", "Smart" }, + { "motion blur", "Motion Blur" }, { NULL, NULL }, }, "disabled" From 25fefc1b3dcdc6362c44845687bea70dd350c33a Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Thu, 20 May 2021 14:12:08 +0800 Subject: [PATCH 03/19] 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 04/19] 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 05/19] 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 06/19] 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 07/19] 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 08/19] 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 09/19] 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 10/19] 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) { From 15bcad135148ca505e9f70bc2ced94e805171bf8 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Sat, 22 May 2021 08:00:33 +0800 Subject: [PATCH 11/19] GB:Fix serial emulation when compiled with NO_LINK Fix https://github.com/libretro/vbam-libretro/issues/83 --- src/gb/GB.cpp | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/gb/GB.cpp b/src/gb/GB.cpp index 462e69e5..16517d37 100644 --- a/src/gb/GB.cpp +++ b/src/gb/GB.cpp @@ -1065,10 +1065,13 @@ void gbWriteMemory(uint16_t address, uint8_t value) } #endif } - +#else + gbMemory[0xff02] = value; + if (gbSerialOn) + gbSerialTicks = GBSERIAL_CLOCK_TICKS; +#endif gbSerialBits = 0; return; -#endif } case 0x04: { @@ -1893,11 +1896,11 @@ uint8_t gbReadMemory(uint16_t address) return gbMemory[0xff01]; case 0x02: return (gbMemory[0xff02]); - case 0x03: - log("Undocumented Memory register read %04x PC=%04x\n", + case 0x03: + log("Undocumented Memory register read %04x PC=%04x\n", address, PC.W); - return 0xff; + return 0xff; case 0x04: return register_DIV; case 0x05: @@ -5295,6 +5298,27 @@ void gbEmulate(int ticksToStop) } #endif } +#else + static int SIOctr = 0; + SIOctr++; + if (SIOctr % 5) { + if (gbSerialOn) { + if (gbMemory[0xff02] & 1) { + gbSerialTicks -= clockTicks; + while (gbSerialTicks <= 0) { + gbMemory[0xff01] = (gbMemory[0xff01] << 1) | 1; + gbSerialBits++; + if (gbSerialBits >= 8) { + gbMemory[0xff02] &= 0x7f; + gbMemory[0xff0f] = register_IF |= 8; + gbSerialOn = 0; + gbSerialBits = 0; + } else + gbSerialTicks += GBSERIAL_CLOCK_TICKS; + } + } + } + } #endif // TODO: evaluate and fix this // On VBA-M (gb core running twice as fast?), each vblank is uses 35112 cycles. From 70477dcd9b5844a90774dc427a8b16d2c3d485d9 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Sat, 22 May 2021 08:26:19 +0800 Subject: [PATCH 12/19] GBA:Fix serial emulation if compiled with NO_LINK --- src/gba/GBA.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/gba/GBA.cpp b/src/gba/GBA.cpp index ee02097e..ae0e6b06 100644 --- a/src/gba/GBA.cpp +++ b/src/gba/GBA.cpp @@ -3038,11 +3038,27 @@ void CPUUpdateRegister(uint32_t address, uint16_t value) cpuNextEvent = cpuTotalTicks; break; -#ifndef NO_LINK case COMM_SIOCNT: +#ifndef NO_LINK StartLink(value); +#else + if (!ioMem) + return; + + if (value & 0x80) { + value &= 0xff7f; + if (value & 1 && (value & 0x4000)) { + UPDATE_REG(COMM_SIOCNT, 0xFF); + IF |= 0x80; + UPDATE_REG(0x202, IF); + value &= 0x7f7f; + } + } + UPDATE_REG(COMM_SIOCNT, value); +#endif break; +#ifndef NO_LINK case COMM_SIODATA8: UPDATE_REG(COMM_SIODATA8, value); break; @@ -3057,11 +3073,19 @@ void CPUUpdateRegister(uint32_t address, uint16_t value) UPDATE_REG(0x132, value & 0xC3FF); break; -#ifndef NO_LINK + case COMM_RCNT: +#ifndef NO_LINK StartGPLink(value); +#else + if (!ioMem) + return; + + UPDATE_REG(COMM_RCNT, value); +#endif break; +#ifndef NO_LINK case COMM_JOYCNT: { uint16_t cur = READ16LE(&ioMem[COMM_JOYCNT]); From bdb65596cedf5fd133e58c759bc2d3edfcc13b14 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Sat, 22 May 2021 08:29:12 +0800 Subject: [PATCH 13/19] Libretro: Remove serial emulation workaround These are not needed anymore due to previous 2 commits. --- src/libretro/Makefile | 2 +- src/libretro/libretro.cpp | 66 --------------------------------------- 2 files changed, 1 insertion(+), 67 deletions(-) diff --git a/src/libretro/Makefile b/src/libretro/Makefile index 2c35083e..bb67a911 100644 --- a/src/libretro/Makefile +++ b/src/libretro/Makefile @@ -2,7 +2,7 @@ DEBUG=0 TILED_RENDERING=0 STATIC_LINKING=0 FRONTEND_SUPPORTS_RGB565=1 -NO_LINK=0 +NO_LINK=1 SPACE := SPACE := $(SPACE) $(SPACE) diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index fb834fd6..61d3ef05 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -92,72 +92,6 @@ 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 -#include "../gba/GBALink.h" -uint8_t gbSIO_SC; -bool LinkIsWaiting; -bool LinkFirstTime; -bool EmuReseted; -int winGbPrinterEnabled; -bool gba_joybus_active = false; - -#define UPDATE_REG(address, value) WRITE16LE(((uint16_t*)&ioMem[address]), value) - -LinkMode GetLinkMode() -{ - return LINK_DISCONNECTED; -} - -void StartGPLink(uint16_t value) -{ - if (!ioMem) - return; - - UPDATE_REG(COMM_RCNT, value); -} - -void LinkUpdate(int ticks) -{ -} - -void StartLink(uint16_t siocnt) -{ -/* log("'s' siocnt = %04x\n", siocnt); */ - - if (!ioMem) - return; - - if(siocnt & 0x80) - { - siocnt &= 0xff7f; - if(siocnt & 1 && (siocnt & 0x4000)) - { - UPDATE_REG(COMM_SIOCNT, 0xFF); - IF |= 0x80; - UPDATE_REG(0x202, IF); - siocnt &= 0x7f7f; - } - } - UPDATE_REG(COMM_SIOCNT, siocnt); -} - -void CheckLinkConnection() -{ -} - -void gbInitLink() -{ - LinkIsWaiting = false; - LinkFirstTime = true; -} - -uint16_t gbLinkUpdate(uint8_t b, int gbSerialOn) //used on external clock -{ - return (b << 8); -} -#endif - #define GS555(x) (x | (x << 5) | (x << 10)) uint16_t systemGbPalette[24] = { GS555(0x1f), GS555(0x15), GS555(0x0c), 0, From fcc8b273c3986351953edf26887a221a6859bc6e Mon Sep 17 00:00:00 2001 From: negativeExponent <54053706+negativeExponent@users.noreply.github.com> Date: Sun, 23 May 2021 08:58:43 +0800 Subject: [PATCH 14/19] android: Fix build --- src/libretro/jni/Android.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libretro/jni/Android.mk b/src/libretro/jni/Android.mk index 5868e9a4..c2b85e64 100644 --- a/src/libretro/jni/Android.mk +++ b/src/libretro/jni/Android.mk @@ -4,6 +4,7 @@ LIBRETRO_DIR := $(CORE_DIR)/libretro FRONTEND_SUPPORTS_RGB565 := 1 TILED_RENDERING := 1 +NO_LINK := 1 include $(LIBRETRO_DIR)/Makefile.common @@ -18,6 +19,10 @@ ifneq ($(CURRENT_COMMIT),$(TAG_COMMIT)) COREFLAGS += -DGIT_COMMIT=\"$(CURRENT_COMMIT)\" endif +ifeq ($(NO_LINK), 1) +COREFLAGS += -DNO_LINK +endif + include $(CLEAR_VARS) LOCAL_MODULE := retro LOCAL_SRC_FILES := $(SOURCES_CXX) From 05a046e7edb86ee9dfd8f0a92e15a0312df797f4 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Mon, 24 May 2021 09:11:48 +0800 Subject: [PATCH 15/19] HuC3: Enable battery save, update RTC support - SRAM support is already available, but the battery-enabled flag was not enable for 0xFE (HuC3) rom types. - Hookup rtc support based on local time. This would allow time to sync when starting the game. You need to initially set the time first though on first bootup (RTC support was based on gambatte sources) Fix https://github.com/libretro/vbam-libretro/issues/95 --- src/gb/GB.cpp | 2 + src/gb/gbMemory.cpp | 94 ++++++++++++++++++++++++++++++++------- src/gb/gbMemory.h | 22 ++++++--- src/libretro/libretro.cpp | 17 ++++++- 4 files changed, 113 insertions(+), 22 deletions(-) diff --git a/src/gb/GB.cpp b/src/gb/GB.cpp index 16517d37..f571d2c1 100644 --- a/src/gb/GB.cpp +++ b/src/gb/GB.cpp @@ -4376,6 +4376,7 @@ bool gbUpdateSizes() case 0x1e: case 0x22: case 0xfd: + case 0xfe: case 0xff: gbBattery = 1; break; @@ -4399,6 +4400,7 @@ bool gbUpdateSizes() case 0x0f: case 0x10: // mbc3 case 0xfd: // tama5 + case 0xfe: gbRTCPresent = 1; break; default: diff --git a/src/gb/gbMemory.cpp b/src/gb/gbMemory.cpp index d1a6e61e..02a559fc 100644 --- a/src/gb/gbMemory.cpp +++ b/src/gb/gbMemory.cpp @@ -1000,14 +1000,33 @@ mapperHuC3 gbDataHuC3 = { 0, // RAM read value 0, // Register 1 0, // Register 2 - 0, // Register 3 - 0, // Register 4 - 0, // Register 5 - 0, // Register 6 - 0, // Register 7 - 0 // Register 8 + 0, // DateTime + 0, // WritingTime + 0, // ModeFlag + 0, // ClockShift + 0 // lastTime }; +void memoryupdateHuC3Latch() { + uint64_t now = time(NULL); + uint64_t diff = now - gbDataHuC3.mapperLastTime; + + if (diff > 0) { + unsigned minute = (diff / 60) % 1440; + unsigned day = (diff / 86400) & 0xFFF; + + gbDataHuC3.mapperDateTime = (day << 12) | minute; + } +} + +void memoryupdateHuC3Clock() { + uint64_t now = time(NULL); + unsigned minute = (gbDataHuC3.mapperWritingTime & 0xFFF) % 1440; + unsigned day = (gbDataHuC3.mapperWritingTime & 0xFFF000) >> 12; + + gbDataHuC3.mapperLastTime = now - minute * 60 - day * 86400; +} + // HuC3 ROM write registers void mapperHuC3ROM(uint16_t address, uint8_t value) { @@ -1066,7 +1085,7 @@ uint8_t mapperHuC3ReadRAM(uint16_t address) // HuC3 RAM write void mapperHuC3RAM(uint16_t address, uint8_t value) { - int* p; + //int* p; if (gbDataHuC3.mapperRAMFlag < 0x0b || gbDataHuC3.mapperRAMFlag > 0x0e) { if (gbDataHuC3.mapperRAMEnable) { @@ -1082,20 +1101,43 @@ void mapperHuC3RAM(uint16_t address, uint8_t value) } else { switch (value & 0xf0) { case 0x10: - p = &gbDataHuC3.mapperRegister2; + /*p = &gbDataHuC3.mapperRegister2; gbDataHuC3.mapperRAMValue = *(p + gbDataHuC3.mapperRegister1++); if (gbDataHuC3.mapperRegister1 > 6) - gbDataHuC3.mapperRegister1 = 0; + gbDataHuC3.mapperRegister1 = 0;*/ + + // read time + memoryupdateHuC3Latch(); + if (gbDataHuC3.mapperModeFlag == HUC3_READ) { + gbDataHuC3.mapperRAMValue = (gbDataHuC3.mapperDateTime >> gbDataHuC3.mapperClockShift) & 0x0F; + gbDataHuC3.mapperClockShift += 4; + if (gbDataHuC3.mapperClockShift > 24) + gbDataHuC3.mapperClockShift = 0; + } break; case 0x30: - p = &gbDataHuC3.mapperRegister2; + /*p = &gbDataHuC3.mapperRegister2; *(p + gbDataHuC3.mapperRegister1++) = value & 0x0f; if (gbDataHuC3.mapperRegister1 > 6) gbDataHuC3.mapperRegister1 = 0; - gbDataHuC3.mapperAddress = (gbDataHuC3.mapperRegister6 << 24) | (gbDataHuC3.mapperRegister5 << 16) | (gbDataHuC3.mapperRegister4 << 8) | (gbDataHuC3.mapperRegister3 << 4) | (gbDataHuC3.mapperRegister2); + gbDataHuC3.mapperAddress = (gbDataHuC3.mapperRegister6 << 24) | (gbDataHuC3.mapperRegister5 << 16) | (gbDataHuC3.mapperRegister4 << 8) | (gbDataHuC3.mapperRegister3 << 4) | (gbDataHuC3.mapperRegister2);*/ + + // write time + if (gbDataHuC3.mapperModeFlag == HUC3_WRITE) { + if (gbDataHuC3.mapperClockShift == 0) + gbDataHuC3.mapperWritingTime = 0; + if (gbDataHuC3.mapperClockShift <= 24) { + gbDataHuC3.mapperWritingTime |= (value & 0x0F) << gbDataHuC3.mapperClockShift; + gbDataHuC3.mapperClockShift += 4; + if (gbDataHuC3.mapperClockShift == 24) { + memoryupdateHuC3Clock(); + gbDataHuC3.mapperModeFlag = HUC3_READ; + } + } + } break; case 0x40: - gbDataHuC3.mapperRegister1 = (gbDataHuC3.mapperRegister1 & 0xf0) | (value & 0x0f); + /*gbDataHuC3.mapperRegister1 = (gbDataHuC3.mapperRegister1 & 0xf0) | (value & 0x0f); gbDataHuC3.mapperRegister2 = (gbDataHuC3.mapperAddress & 0x0f); gbDataHuC3.mapperRegister3 = ((gbDataHuC3.mapperAddress >> 4) & 0x0f); gbDataHuC3.mapperRegister4 = ((gbDataHuC3.mapperAddress >> 8) & 0x0f); @@ -1103,13 +1145,35 @@ void mapperHuC3RAM(uint16_t address, uint8_t value) gbDataHuC3.mapperRegister6 = ((gbDataHuC3.mapperAddress >> 24) & 0x0f); gbDataHuC3.mapperRegister7 = 0; gbDataHuC3.mapperRegister8 = 0; - gbDataHuC3.mapperRAMValue = 0; + gbDataHuC3.mapperRAMValue = 0;*/ + + // some kind of mode shift + switch(value & 0x0F) { + case 0x0: + // shift reset? + gbDataHuC3.mapperClockShift = 0; + break; + case 0x3: + // write time? + gbDataHuC3.mapperModeFlag = HUC3_WRITE; + gbDataHuC3.mapperClockShift = 0; + break; + case 0x7: + gbDataHuC3.mapperModeFlag = HUC3_READ; + gbDataHuC3.mapperClockShift = 0; + break; + // others are unimplemented so far + } break; case 0x50: - gbDataHuC3.mapperRegister1 = (gbDataHuC3.mapperRegister1 & 0x0f) | ((value << 4) & 0x0f); + //gbDataHuC3.mapperRegister1 = (gbDataHuC3.mapperRegister1 & 0x0f) | ((value << 4) & 0x0f); + break; + case 0x60: + gbDataHuC3.mapperModeFlag = HUC3_READ; // ??? + gbDataHuC3.mapperRAMValue = 1; break; default: - gbDataHuC3.mapperRAMValue = 1; + //gbDataHuC3.mapperRAMValue = 1; break; } } diff --git a/src/gb/gbMemory.h b/src/gb/gbMemory.h index 0ca97506..e901be0b 100644 --- a/src/gb/gbMemory.h +++ b/src/gb/gbMemory.h @@ -77,6 +77,12 @@ struct mapperHuC1 { int mapperRAMAddress; }; +enum { + HUC3_READ = 0, + HUC3_WRITE = 1, + HUC3_NONE = 2 +}; + struct mapperHuC3 { int mapperRAMEnable; int mapperROMBank; @@ -87,12 +93,14 @@ struct mapperHuC3 { int mapperRAMValue; int mapperRegister1; int mapperRegister2; - int mapperRegister3; - int mapperRegister4; - int mapperRegister5; - int mapperRegister6; - int mapperRegister7; - int mapperRegister8; + int mapperDateTime; + int mapperWritingTime; + int mapperModeFlag; + int mapperClockShift; + union { + time_t mapperLastTime; + uint64_t _time_pad; /* so that 32bit and 64bit saves are compatible */ + }; }; struct mapperTAMA5 { @@ -196,4 +204,6 @@ extern void memoryUpdateMapGS3(); #define TAMA5_RTC_DATA_SIZE sizeof(int) * 14 + sizeof(uint64_t) +#define HUC3_RTC_DATA_SIZE sizeof(int) * 4 + sizeof(uint64_t) + #endif // GBMEMORY_H diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index 61d3ef05..2b3508ec 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -161,6 +161,9 @@ static void set_gbPalette(void) } } +extern void memoryupdateHuC3Clock(); +extern void memoryupdateHuC3Latch(); + static void* gb_rtcdata_prt(void) { switch (gbRomType) { @@ -169,6 +172,8 @@ static void* gb_rtcdata_prt(void) return &gbDataMBC3.mapperSeconds; case 0xfd: // TAMA5 + extended return &gbDataTAMA5.mapperSeconds; + case 0xfe: // HuC3 + Clock + return &gbDataHuC3.mapperDateTime; } return NULL; } @@ -181,6 +186,8 @@ static size_t gb_rtcdata_size(void) return MBC3_RTC_DATA_SIZE; case 0xfd: // TAMA5 + extended return TAMA5_RTC_DATA_SIZE; + case 0xfe: // HuC3 + Clock + return HUC3_RTC_DATA_SIZE; } return 0; } @@ -231,6 +238,10 @@ static void gbInitRTC(void) gbDataTAMA5.mapperControl = (gbDataTAMA5.mapperControl & 0xfe) | (lt->tm_yday > 255 ? 1 : 0); } break; + case 0xfe: + //memoryupdateHuC3Clock(); + memoryupdateHuC3Latch(); + break; } } @@ -298,7 +309,7 @@ void* retro_get_memory_data(unsigned id) data = (gbCgbMode ? gbVram : (gbMemory + 0x8000)); break; case RETRO_MEMORY_RTC: - if (gbBattery && gbRTCPresent) + //if (gbBattery/* && gbRTCPresent*/) data = gb_rtcdata_prt(); break; } @@ -1425,6 +1436,10 @@ void retro_run(void) if (!gbDataTAMA5.mapperLastTime) initRTC = true; break; + case 0xfe: + if (!gbDataHuC3.mapperLastTime) + initRTC = true; + break; } /* Initialize RTC using local time if needed */ if (initRTC) From ab7f7baab0db3c3960342465b26b0fed79ce4267 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Tue, 25 May 2021 09:52:44 +0800 Subject: [PATCH 16/19] Libretro: Only enable RTC save if gbRTCPresent=1 --- src/libretro/libretro.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index 2b3508ec..ce443ba2 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -309,7 +309,7 @@ void* retro_get_memory_data(unsigned id) data = (gbCgbMode ? gbVram : (gbMemory + 0x8000)); break; case RETRO_MEMORY_RTC: - //if (gbBattery/* && gbRTCPresent*/) + if (gbRTCPresent) data = gb_rtcdata_prt(); break; } @@ -357,7 +357,8 @@ size_t retro_get_memory_size(unsigned id) size = gbCgbMode ? 0x4000 : 0x2000; break; case RETRO_MEMORY_RTC: - size = gb_rtcdata_size(); + if (gbRTCPresent) + size = gb_rtcdata_size(); break; } break; From 93084990b2c26d595c37df4b1413fa3a39235206 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Tue, 25 May 2021 12:08:08 +0800 Subject: [PATCH 17/19] HuC3: Refactoring to avoid breaking savestates Savestates are broken due to the change in savestate struct size for HuC3. Since save/load function also includes save data for other non-active mappers, the change in size breaks every savesfiles being made. This PR refactors the HuC3 clock data struct to be separate from the main struct, and then only added to save/load functions when HuC3 mapper is used. This still breaks previous HuC3 states but other mappers should now not get affected Solution: Savestate/LoadState should only include mapper data of current active running rom, not all mappers even if they are inactive. This will break every savefile but it would be better for the long run when changes are neede to be done. --- src/gb/GB.cpp | 4 +++ src/gb/gbMemory.cpp | 61 ++++++++++++++++++++++----------------- src/gb/gbMemory.h | 30 ++++++++++++------- src/libretro/libretro.cpp | 6 ++-- 4 files changed, 62 insertions(+), 39 deletions(-) diff --git a/src/gb/GB.cpp b/src/gb/GB.cpp index f571d2c1..bdf00a2b 100644 --- a/src/gb/GB.cpp +++ b/src/gb/GB.cpp @@ -5515,6 +5515,8 @@ unsigned int gbWriteSaveState(uint8_t* data, unsigned) utilWriteMem(data, &gbDataMBC5, sizeof(gbDataMBC5)); utilWriteMem(data, &gbDataHuC1, sizeof(gbDataHuC1)); utilWriteMem(data, &gbDataHuC3, sizeof(gbDataHuC3)); + if (gbRomType == 0xfe) // HuC3 rtc data + utilWriteMem(data, &gbRTCHuC3, sizeof(gbRTCHuC3)); utilWriteMem(data, &gbDataTAMA5, sizeof(gbDataTAMA5)); if (gbTAMA5ram != NULL) utilWriteMem(data, gbTAMA5ram, gbTAMA5ramSize); @@ -5632,6 +5634,8 @@ bool gbReadSaveState(const uint8_t* data, unsigned) utilReadMem(&gbDataMBC5, data, sizeof(gbDataMBC5)); utilReadMem(&gbDataHuC1, data, sizeof(gbDataHuC1)); utilReadMem(&gbDataHuC3, data, sizeof(gbDataHuC3)); + if (gbRomType == 0xfe) // HuC3 rtc data + utilReadMem(&gbRTCHuC3, data, sizeof(gbRTCHuC3)); utilReadMem(&gbDataTAMA5, data, sizeof(gbDataTAMA5)); if (gbTAMA5ram != NULL) { utilReadMem(gbTAMA5ram, data, gbTAMA5ramSize); diff --git a/src/gb/gbMemory.cpp b/src/gb/gbMemory.cpp index 02a559fc..b334d471 100644 --- a/src/gb/gbMemory.cpp +++ b/src/gb/gbMemory.cpp @@ -1000,31 +1000,40 @@ mapperHuC3 gbDataHuC3 = { 0, // RAM read value 0, // Register 1 0, // Register 2 + 0, // Register 3 + 0, // Register 4 + 0, // Register 5 + 0, // Register 6 + 0, // Register 7 + 0 // Register 8 +}; + +mapperHuC3RTC gbRTCHuC3 = { + 0, // lastTime 0, // DateTime 0, // WritingTime 0, // ModeFlag - 0, // ClockShift - 0 // lastTime + 0 // ClockShift }; void memoryupdateHuC3Latch() { uint64_t now = time(NULL); - uint64_t diff = now - gbDataHuC3.mapperLastTime; + uint64_t diff = now - gbRTCHuC3.mapperLastTime; if (diff > 0) { unsigned minute = (diff / 60) % 1440; unsigned day = (diff / 86400) & 0xFFF; - gbDataHuC3.mapperDateTime = (day << 12) | minute; + gbRTCHuC3.mapperDateTime = (day << 12) | minute; } } void memoryupdateHuC3Clock() { uint64_t now = time(NULL); - unsigned minute = (gbDataHuC3.mapperWritingTime & 0xFFF) % 1440; - unsigned day = (gbDataHuC3.mapperWritingTime & 0xFFF000) >> 12; + unsigned minute = (gbRTCHuC3.mapperWritingTime & 0xFFF) % 1440; + unsigned day = (gbRTCHuC3.mapperWritingTime & 0xFFF000) >> 12; - gbDataHuC3.mapperLastTime = now - minute * 60 - day * 86400; + gbRTCHuC3.mapperLastTime = now - minute * 60 - day * 86400; } // HuC3 ROM write registers @@ -1108,11 +1117,11 @@ void mapperHuC3RAM(uint16_t address, uint8_t value) // read time memoryupdateHuC3Latch(); - if (gbDataHuC3.mapperModeFlag == HUC3_READ) { - gbDataHuC3.mapperRAMValue = (gbDataHuC3.mapperDateTime >> gbDataHuC3.mapperClockShift) & 0x0F; - gbDataHuC3.mapperClockShift += 4; - if (gbDataHuC3.mapperClockShift > 24) - gbDataHuC3.mapperClockShift = 0; + if (gbRTCHuC3.mapperModeFlag == HUC3_READ) { + gbDataHuC3.mapperRAMValue = (gbRTCHuC3.mapperDateTime >> gbRTCHuC3.mapperClockShift) & 0x0F; + gbRTCHuC3.mapperClockShift += 4; + if (gbRTCHuC3.mapperClockShift > 24) + gbRTCHuC3.mapperClockShift = 0; } break; case 0x30: @@ -1123,15 +1132,15 @@ void mapperHuC3RAM(uint16_t address, uint8_t value) gbDataHuC3.mapperAddress = (gbDataHuC3.mapperRegister6 << 24) | (gbDataHuC3.mapperRegister5 << 16) | (gbDataHuC3.mapperRegister4 << 8) | (gbDataHuC3.mapperRegister3 << 4) | (gbDataHuC3.mapperRegister2);*/ // write time - if (gbDataHuC3.mapperModeFlag == HUC3_WRITE) { - if (gbDataHuC3.mapperClockShift == 0) - gbDataHuC3.mapperWritingTime = 0; - if (gbDataHuC3.mapperClockShift <= 24) { - gbDataHuC3.mapperWritingTime |= (value & 0x0F) << gbDataHuC3.mapperClockShift; - gbDataHuC3.mapperClockShift += 4; - if (gbDataHuC3.mapperClockShift == 24) { + if (gbRTCHuC3.mapperModeFlag == HUC3_WRITE) { + if (gbRTCHuC3.mapperClockShift == 0) + gbRTCHuC3.mapperWritingTime = 0; + if (gbRTCHuC3.mapperClockShift <= 24) { + gbRTCHuC3.mapperWritingTime |= (value & 0x0F) << gbRTCHuC3.mapperClockShift; + gbRTCHuC3.mapperClockShift += 4; + if (gbRTCHuC3.mapperClockShift == 24) { memoryupdateHuC3Clock(); - gbDataHuC3.mapperModeFlag = HUC3_READ; + gbRTCHuC3.mapperModeFlag = HUC3_READ; } } } @@ -1151,16 +1160,16 @@ void mapperHuC3RAM(uint16_t address, uint8_t value) switch(value & 0x0F) { case 0x0: // shift reset? - gbDataHuC3.mapperClockShift = 0; + gbRTCHuC3.mapperClockShift = 0; break; case 0x3: // write time? - gbDataHuC3.mapperModeFlag = HUC3_WRITE; - gbDataHuC3.mapperClockShift = 0; + gbRTCHuC3.mapperModeFlag = HUC3_WRITE; + gbRTCHuC3.mapperClockShift = 0; break; case 0x7: - gbDataHuC3.mapperModeFlag = HUC3_READ; - gbDataHuC3.mapperClockShift = 0; + gbRTCHuC3.mapperModeFlag = HUC3_READ; + gbRTCHuC3.mapperClockShift = 0; break; // others are unimplemented so far } @@ -1169,7 +1178,7 @@ void mapperHuC3RAM(uint16_t address, uint8_t value) //gbDataHuC3.mapperRegister1 = (gbDataHuC3.mapperRegister1 & 0x0f) | ((value << 4) & 0x0f); break; case 0x60: - gbDataHuC3.mapperModeFlag = HUC3_READ; // ??? + gbRTCHuC3.mapperModeFlag = HUC3_READ; // ??? gbDataHuC3.mapperRAMValue = 1; break; default: diff --git a/src/gb/gbMemory.h b/src/gb/gbMemory.h index e901be0b..f1128586 100644 --- a/src/gb/gbMemory.h +++ b/src/gb/gbMemory.h @@ -77,12 +77,6 @@ struct mapperHuC1 { int mapperRAMAddress; }; -enum { - HUC3_READ = 0, - HUC3_WRITE = 1, - HUC3_NONE = 2 -}; - struct mapperHuC3 { int mapperRAMEnable; int mapperROMBank; @@ -93,14 +87,29 @@ struct mapperHuC3 { int mapperRAMValue; int mapperRegister1; int mapperRegister2; - int mapperDateTime; - int mapperWritingTime; - int mapperModeFlag; - int mapperClockShift; + int mapperRegister3; + int mapperRegister4; + int mapperRegister5; + int mapperRegister6; + int mapperRegister7; + int mapperRegister8; +}; + +enum { + HUC3_READ = 0, + HUC3_WRITE = 1, + HUC3_NONE = 2 +}; + +struct mapperHuC3RTC { union { time_t mapperLastTime; uint64_t _time_pad; /* so that 32bit and 64bit saves are compatible */ }; + uint32_t mapperDateTime; + uint32_t mapperWritingTime; + uint32_t mapperModeFlag; + uint32_t mapperClockShift; }; struct mapperTAMA5 { @@ -155,6 +164,7 @@ extern mapperMBC3 gbDataMBC3; extern mapperMBC5 gbDataMBC5; extern mapperHuC1 gbDataHuC1; extern mapperHuC3 gbDataHuC3; +extern mapperHuC3RTC gbRTCHuC3; extern mapperTAMA5 gbDataTAMA5; extern mapperMMM01 gbDataMMM01; extern mapperGS3 gbDataGS3; diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index ce443ba2..ea039174 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -173,7 +173,7 @@ static void* gb_rtcdata_prt(void) case 0xfd: // TAMA5 + extended return &gbDataTAMA5.mapperSeconds; case 0xfe: // HuC3 + Clock - return &gbDataHuC3.mapperDateTime; + return &gbRTCHuC3.mapperLastTime; } return NULL; } @@ -187,7 +187,7 @@ static size_t gb_rtcdata_size(void) case 0xfd: // TAMA5 + extended return TAMA5_RTC_DATA_SIZE; case 0xfe: // HuC3 + Clock - return HUC3_RTC_DATA_SIZE; + return sizeof(gbRTCHuC3); } return 0; } @@ -1438,7 +1438,7 @@ void retro_run(void) initRTC = true; break; case 0xfe: - if (!gbDataHuC3.mapperLastTime) + if (!gbRTCHuC3.mapperLastTime) initRTC = true; break; } From c05056ab91e6175cde76e71d3fe155efecb441cf Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Thu, 27 May 2021 13:02:22 +0800 Subject: [PATCH 18/19] HuC3: Update - Minor refactoring, some variable name and type changes - Remove unnecessary checks in clock latch - Fix stuck in whitescreen after Hudson startup logo - Fix Gamepak error message at initial load of game without prior rtc data available to load - Save the bare-minimum variable needed for rtc (saves only Basetime/lastTime) --- src/gb/GB.cpp | 2 ++ src/gb/gbMemory.cpp | 40 +++++++++++++++++++-------------------- src/gb/gbMemory.h | 15 +++++---------- src/libretro/libretro.cpp | 8 ++------ 4 files changed, 28 insertions(+), 37 deletions(-) diff --git a/src/gb/GB.cpp b/src/gb/GB.cpp index bdf00a2b..e7b1a9f0 100644 --- a/src/gb/GB.cpp +++ b/src/gb/GB.cpp @@ -2764,6 +2764,8 @@ void gbReset() memset(&gbDataHuC3, 0, sizeof(gbDataHuC3)); gbDataHuC3.mapperROMBank = 1; + gbDataHuC3.mapperRAMValue = 1; + gbRTCHuC3.memoryTimerRead = 1; memset(&gbDataTAMA5, 0, 26 * sizeof(int)); gbDataTAMA5.mapperROMBank = 1; diff --git a/src/gb/gbMemory.cpp b/src/gb/gbMemory.cpp index b334d471..8dc360ed 100644 --- a/src/gb/gbMemory.cpp +++ b/src/gb/gbMemory.cpp @@ -1016,19 +1016,16 @@ mapperHuC3RTC gbRTCHuC3 = { 0 // ClockShift }; -void memoryupdateHuC3Latch() { +void memoryUpdateHuC3Latch() { uint64_t now = time(NULL); uint64_t diff = now - gbRTCHuC3.mapperLastTime; + unsigned minute = (diff / 60) % 1440; + unsigned day = (diff / 86400) & 0xFFF; - if (diff > 0) { - unsigned minute = (diff / 60) % 1440; - unsigned day = (diff / 86400) & 0xFFF; - - gbRTCHuC3.mapperDateTime = (day << 12) | minute; - } + gbRTCHuC3.mapperDateTime = (day << 12) | minute; } -void memoryupdateHuC3Clock() { +void memoryUpdateHuC3Clock() { uint64_t now = time(NULL); unsigned minute = (gbRTCHuC3.mapperWritingTime & 0xFFF) % 1440; unsigned day = (gbRTCHuC3.mapperWritingTime & 0xFFF000) >> 12; @@ -1105,9 +1102,10 @@ void mapperHuC3RAM(uint16_t address, uint8_t value) } } else { if (gbDataHuC3.mapperRAMFlag == 0x0b) { - if (value == 0x62) { - gbDataHuC3.mapperRAMValue = 1; - } else { + //if (value == 0x62) { + //gbDataHuC3.mapperRAMValue = 1; + //} else + { switch (value & 0xf0) { case 0x10: /*p = &gbDataHuC3.mapperRegister2; @@ -1116,8 +1114,8 @@ void mapperHuC3RAM(uint16_t address, uint8_t value) gbDataHuC3.mapperRegister1 = 0;*/ // read time - memoryupdateHuC3Latch(); - if (gbRTCHuC3.mapperModeFlag == HUC3_READ) { + memoryUpdateHuC3Latch(); + if (gbRTCHuC3.memoryTimerRead) { gbDataHuC3.mapperRAMValue = (gbRTCHuC3.mapperDateTime >> gbRTCHuC3.mapperClockShift) & 0x0F; gbRTCHuC3.mapperClockShift += 4; if (gbRTCHuC3.mapperClockShift > 24) @@ -1132,15 +1130,15 @@ void mapperHuC3RAM(uint16_t address, uint8_t value) gbDataHuC3.mapperAddress = (gbDataHuC3.mapperRegister6 << 24) | (gbDataHuC3.mapperRegister5 << 16) | (gbDataHuC3.mapperRegister4 << 8) | (gbDataHuC3.mapperRegister3 << 4) | (gbDataHuC3.mapperRegister2);*/ // write time - if (gbRTCHuC3.mapperModeFlag == HUC3_WRITE) { + if (!gbRTCHuC3.memoryTimerRead) { if (gbRTCHuC3.mapperClockShift == 0) gbRTCHuC3.mapperWritingTime = 0; - if (gbRTCHuC3.mapperClockShift <= 24) { + if (gbRTCHuC3.mapperClockShift < 24) { gbRTCHuC3.mapperWritingTime |= (value & 0x0F) << gbRTCHuC3.mapperClockShift; gbRTCHuC3.mapperClockShift += 4; if (gbRTCHuC3.mapperClockShift == 24) { - memoryupdateHuC3Clock(); - gbRTCHuC3.mapperModeFlag = HUC3_READ; + memoryUpdateHuC3Clock(); + gbRTCHuC3.memoryTimerRead = 1; } } } @@ -1164,11 +1162,11 @@ void mapperHuC3RAM(uint16_t address, uint8_t value) break; case 0x3: // write time? - gbRTCHuC3.mapperModeFlag = HUC3_WRITE; + gbRTCHuC3.memoryTimerRead = 0; gbRTCHuC3.mapperClockShift = 0; break; case 0x7: - gbRTCHuC3.mapperModeFlag = HUC3_READ; + gbRTCHuC3.memoryTimerRead = 1; gbRTCHuC3.mapperClockShift = 0; break; // others are unimplemented so far @@ -1178,8 +1176,8 @@ void mapperHuC3RAM(uint16_t address, uint8_t value) //gbDataHuC3.mapperRegister1 = (gbDataHuC3.mapperRegister1 & 0x0f) | ((value << 4) & 0x0f); break; case 0x60: - gbRTCHuC3.mapperModeFlag = HUC3_READ; // ??? - gbDataHuC3.mapperRAMValue = 1; + gbRTCHuC3.memoryTimerRead = 1; // ??? + //gbDataHuC3.mapperRAMValue = 1; break; default: //gbDataHuC3.mapperRAMValue = 1; diff --git a/src/gb/gbMemory.h b/src/gb/gbMemory.h index f1128586..6c7927a5 100644 --- a/src/gb/gbMemory.h +++ b/src/gb/gbMemory.h @@ -95,21 +95,16 @@ struct mapperHuC3 { int mapperRegister8; }; -enum { - HUC3_READ = 0, - HUC3_WRITE = 1, - HUC3_NONE = 2 -}; - struct mapperHuC3RTC { union { time_t mapperLastTime; uint64_t _time_pad; /* so that 32bit and 64bit saves are compatible */ }; - uint32_t mapperDateTime; - uint32_t mapperWritingTime; - uint32_t mapperModeFlag; - uint32_t mapperClockShift; + unsigned mapperDateTime; + unsigned mapperWritingTime; + unsigned memoryTimerRead; + unsigned mapperClockShift; + unsigned reserved[4]; }; struct mapperTAMA5 { diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index ea039174..ee4426e4 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -161,9 +161,6 @@ static void set_gbPalette(void) } } -extern void memoryupdateHuC3Clock(); -extern void memoryupdateHuC3Latch(); - static void* gb_rtcdata_prt(void) { switch (gbRomType) { @@ -187,7 +184,7 @@ static size_t gb_rtcdata_size(void) case 0xfd: // TAMA5 + extended return TAMA5_RTC_DATA_SIZE; case 0xfe: // HuC3 + Clock - return sizeof(gbRTCHuC3); + return sizeof(gbRTCHuC3.mapperLastTime); } return 0; } @@ -239,8 +236,7 @@ static void gbInitRTC(void) } break; case 0xfe: - //memoryupdateHuC3Clock(); - memoryupdateHuC3Latch(); + gbRTCHuC3.mapperLastTime = rawtime; break; } } From 983ea451d0346653a4e5dd2f118a769e516fded3 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Mon, 5 Jul 2021 00:02:02 +0800 Subject: [PATCH 19/19] Flash : Erased memory is FFh-filled https://akkit.org/info/gbatek.htm#gbacartbackupflashrom --- src/gba/Flash.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gba/Flash.cpp b/src/gba/Flash.cpp index c3c5585a..9d0124e0 100644 --- a/src/gba/Flash.cpp +++ b/src/gba/Flash.cpp @@ -172,13 +172,13 @@ void flashWrite(uint32_t address, uint8_t byte) if (byte == 0x30) { // SECTOR ERASE memset(&flashSaveMemory[(flashBank << 16) + (address & 0xF000)], - 0, + 0xff, 0x1000); systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; flashReadState = FLASH_ERASE_COMPLETE; } else if (byte == 0x10) { // CHIP ERASE - memset(flashSaveMemory, 0, flashSize); + memset(flashSaveMemory, 0xff, flashSize); systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; flashReadState = FLASH_ERASE_COMPLETE; } else {