From 9a1344978251b6fc6aca7adabdd0da5ccc77a455 Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Sun, 4 Aug 2019 15:37:18 +0800 Subject: [PATCH 01/13] Update Makefiles - Updating makefile from vba_next's makefiles, removing any defines that are not available in this core. - Update Android.mk --- src/libretro/Makefile | 495 +++++++++++++++++++++++++---------- src/libretro/Makefile.common | 18 +- src/libretro/jni/Android.mk | 15 +- 3 files changed, 380 insertions(+), 148 deletions(-) diff --git a/src/libretro/Makefile b/src/libretro/Makefile index 9bbee1d4..f4dfb968 100644 --- a/src/libretro/Makefile +++ b/src/libretro/Makefile @@ -1,3 +1,4 @@ +DEBUG=0 TILED_RENDERING=0 STATIC_LINKING=0 FRONTEND_SUPPORTS_RGB565=1 @@ -13,118 +14,54 @@ filter_out2 = $(call filter_out1,$(call filter_out1,$1)) ifeq ($(platform),) platform = unix ifeq ($(shell uname -a),) - platform = win + platform = win else ifneq ($(findstring MINGW,$(shell uname -a)),) - platform = win -else ifneq ($(findstring win,$(shell uname -a)),) - platform = win + platform = win else ifneq ($(findstring Darwin,$(shell uname -a)),) - platform = osx - arch = intel -ifeq ($(shell uname -a),) - arch = ppc + platform = osx + arch = intel +ifeq ($(shell uname -p),powerpc) + arch = ppc endif +else ifneq ($(findstring win,$(shell uname -a)),) + platform = win endif endif -TARGET_NAME = vbam +# system platform +system_platform = unix +ifeq ($(shell uname -a),) +EXE_EXT = .exe + system_platform = win +else ifneq ($(findstring Darwin,$(shell uname -a)),) + system_platform = osx + arch = intel +ifeq ($(shell uname -p),powerpc) + arch = ppc +endif +else ifneq ($(findstring MINGW,$(shell uname -a)),) + system_platform = win +endif + +CORE_DIR := .. +LIBRETRO_DIR := $(CORE_DIR)/libretro +TARGET_NAME := vbam VBAM_VERSION := $(shell sed -En 's/.*\[([0-9]+[^]]+).*/\1/p; T; q' ../../CHANGELOG.md 2>/dev/null) - -CXXFLAGS += -DVBAM_VERSION=\"$(VBAM_VERSION)\" - TAG_COMMIT := $(shell git rev-list -n 1 v$(VBAM_VERSION) --abbrev-commit 2>/dev/null) CURRENT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null) +CXXFLAGS += -DVBAM_VERSION=\"$(VBAM_VERSION)\" ifneq ($(CURRENT_COMMIT),$(TAG_COMMIT)) CXXFLAGS += -DGIT_COMMIT=\"$(CURRENT_COMMIT)\" endif -ifeq ($(platform), unix) - TARGET := $(TARGET_NAME)_libretro.so - fpic := -fPIC - SHARED := -shared -Wl,-no-undefined -Wl,--version-script=link.T - TILED_RENDERING = 1 -else ifeq ($(platform), osx) - TARGET := $(TARGET_NAME)_libretro.dylib - fpic := -fPIC - SHARED := -dynamiclib - arch = intel -ifeq ($(shell uname -a),) - arch = ppc -endif - -ifneq ($(arch),ppc) - SHARED += -DLSB_FIRST -endif - OSXVER = `sw_vers -productVersion | cut -d. -f 2` - OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"` -ifeq ($(OSX_LT_MAVERICKS),"YES") - fpic += -mmacosx-version-min=10.5 -endif - -# iOS -else ifneq (,$(findstring ios,$(platform))) - TARGET := $(TARGET_NAME)_libretro_ios.dylib - fpic := -fPIC - SHARED := -dynamiclib -DLSB_FIRST - -ifeq ($(IOSSDK),) - IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path) -endif - - CC = clang -arch armv7 -isysroot $(IOSSDK) - CXX = clang++ -arch armv7 -isysroot $(IOSSDK) - ifeq ($(platform),ios9) - CC += -miphoneos-version-min=8.0 - CXX += -miphoneos-version-min=8.0 - SHARED += -miphoneos-version-min=8.0 - else - CC += -miphoneos-version-min=5.0 - CXX += -miphoneos-version-min=5.0 - SHARED += -miphoneos-version-min=5.0 -endif - TILED_RENDERING = 1 -else ifeq ($(platform), theos_ios) -DEPLOYMENT_IOSVERSION = 5.0 -TARGET = iphone:latest:$(DEPLOYMENT_IOSVERSION) -ARCHS = armv7 armv7s -TARGET_IPHONEOS_DEPLOYMENT_VERSION=$(DEPLOYMENT_IOSVERSION) -THEOS_BUILD_DIR := objs -include $(THEOS)/makefiles/common.mk - -LIBRARY_NAME = $(TARGET_NAME)_libretro_ios - - ENDIANNESS_DEFINES = -DLSB_FIRST +# UNIX +ifneq (,$(findstring unix,$(platform))) + TARGET := $(TARGET_NAME)_libretro.so + fpic := -fPIC + SHARED := -shared -Wl,-version-script=$(LIBRETRO_DIR)/link.T -Wl,-no-undefined TILED_RENDERING=1 -else ifeq ($(platform), qnx) - TARGET := $(TARGET_NAME)_libretro_qnx.so - fpic := -fPIC - SHARED := -shared - TILED_RENDERING = 1 - CC = qcc -Vgcc_ntoarmv7le - CXX = QCC -Vgcc_ntoarmv7le_cpp - AR = QCC -Vgcc_ntoarmv7le -else ifeq ($(platform), vita) - TARGET := $(TARGET_NAME)_libretro_vita.a - CC = arm-vita-eabi-gcc - CXX = arm-vita-eabi-g++ - AR = arm-vita-eabi-ar - __FLAGS := -marm -mtune=cortex-a9 -mcpu=cortex-a9 -mfloat-abi=hard -mword-relocations - __FLAGS += -fno-optimize-sibling-calls -fno-strict-aliasing -fno-partial-inlining -fno-tree-vrp - __FLAGS += -ffast-math -fsingle-precision-constant -funroll-loops -ftracer - __FLAGS += -DVITA -I../vita -Wno-attributes - - CFLAGS += $(__FLAGS) - CXXFLAGS += $(__FLAGS) - CXXFLAGS += -fno-exceptions -fno-rtti - STATIC_LINKING=1 - TILED_RENDERING=1 - USE_CHEATS=0 - USE_TWEAKS=1 - USE_THREADED_RENDERER=1 - USE_MOTION_SENSOR=1 - HAVE_NEON=1 # Classic Platforms #################### # Platform affix = classic__<µARCH> @@ -135,19 +72,23 @@ else ifeq ($(platform), vita) else ifeq ($(platform), classic_armv7_a7) TARGET := $(TARGET_NAME)_libretro.so fpic := -fPIC - SHARED := -shared - TILED_RENDERING = 1 + SHARED := -shared -Wl,--version-script=$(LIBRETRO_DIR)/link.T -Wl,--no-undefined -fPIC CFLAGS += -Ofast \ -flto=4 -fwhole-program -fuse-linker-plugin \ -fdata-sections -ffunction-sections -Wl,--gc-sections \ -fno-stack-protector -fno-ident -fomit-frame-pointer \ - -falign-functions=1 -falign-jumps=1 -falign-loops=1 \ + -falign-functions=1 -falign-jumps=1 -falign-loops=1 \ -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \ -fmerge-all-constants -fno-math-errno \ -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard CXXFLAGS += $(CFLAGS) - HAVE_NEON = 1 + CPPFLAGS += $(CFLAGS) + ASFLAGS += $(CFLAGS) + HAVE_NEON=1 ARCH = arm + BUILTIN_GPU = neon + USE_DYNAREC=1 + TILED_RENDERING=1 ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1) CFLAGS += -march=armv7-a else @@ -164,17 +105,17 @@ else ifeq ($(platform), classic_armv8_a35) TARGET := $(TARGET_NAME)_libretro.so fpic := -fPIC SHARED := -shared - TILED_RENDERING = 1 + TILED_RENDERING=1 CFLAGS += -Ofast \ -flto=4 -fwhole-program -fuse-linker-plugin \ -fdata-sections -ffunction-sections -Wl,--gc-sections \ -fno-stack-protector -fno-ident -fomit-frame-pointer \ - -falign-functions=1 -falign-jumps=1 -falign-loops=1 \ + -falign-functions=1 -falign-jumps=1 -falign-loops=1 \ -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \ -fmerge-all-constants -fno-math-errno \ -marm -mtune=cortex-a35 -mfpu=neon-fp-armv8 -mfloat-abi=hard CXXFLAGS += $(CFLAGS) - HAVE_NEON = 1 + HAVE_NEON=1 ARCH = arm ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1) CFLAGS += -march=armv8-a @@ -187,6 +128,300 @@ else ifeq ($(platform), classic_armv8_a35) endif ####################################### +# OS X +else ifeq ($(platform), osx) + TARGET := $(TARGET_NAME)_libretro.dylib + fpic := -fPIC + ifeq ($(arch),ppc) + ENDIANNESS_DEFINES += -DMSB_FIRST + PLATFORM_DEFINES := -D__POWERPC__ -D__ppc__ + endif + OSXVER = `sw_vers -productVersion | cut -d. -f 2` + OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"` + fpic += -mmacosx-version-min=1 0.2 + SHARED := -dynamiclib + TILED_RENDERING=1 + +# iOS +else ifneq (,$(findstring ios,$(platform))) + TARGET := $(TARGET_NAME)_libretro_ios.dylib + fpic := -fPIC + SHARED := -dynamiclib + ifeq ($(IOSSDK),) + IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path) + endif + ifeq ($(platform),ios-arm64) + CC = cc -arch arm64 -isysroot $(IOSSDK) + CXX = clang++ -arch arm64 -isysroot $(IOSSDK) + else + CC = cc -arch armv7 -isysroot $(IOSSDK) + CXX = clang++ -arch armv7 -isysroot $(IOSSDK) + endif + CFLAGS += -DIOS + 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 + else + CC += -miphoneos-version-min=5.0 + CXX += -miphoneos-version-min=5.0 + CFLAGS += -miphoneos-version-min=5.0 + endif + TILED_RENDERING=1 + +# Theos iOS +else ifeq ($(platform), theos_ios) + DEPLOYMENT_IOSVERSION = 5.0 + TARGET = iphone:latest:$(DEPLOYMENT_IOSVERSION) + ARCHS = armv7 armv7s + TARGET_IPHONEOS_DEPLOYMENT_VERSION=$(DEPLOYMENT_IOSVERSION) + THEOS_BUILD_DIR := objs + include $(THEOS)/makefiles/common.mk + LIBRARY_NAME = $(TARGET_NAME)_libretro_ios + TILED_RENDERING=1 + +# QNX +else ifeq ($(platform), qnx) + TARGET := $(TARGET_NAME)_libretro_$(platform).so + fpic := -fPIC + SHARED := -lcpp -lm -shared -Wl,-version-script=$(LIBRETRO_DIR)/link.T -Wl,-no-undefined + CC = qcc -Vgcc_ntoarmv7le + CXX = QCC -Vgcc_ntoarmv7le_cpp + AR = QCC -Vgcc_ntoarmv7le + PLATFORM_DEFINES := -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp + TILED_RENDERING=1 + +# PS3 +else ifeq ($(platform), ps3) + TARGET := $(TARGET_NAME)_libretro_$(platform).a + CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe + CXX = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe + AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe + ENDIANNESS_DEFINES += -DMSB_FIRST + PLATFORM_DEFINES := -D__CELLOS_LV2__ -D__POWERPC__ -D__ppc__ + STATIC_LINKING=1 + TILED_RENDERING=1 + +# PS3 (SNC) +else ifeq ($(platform), sncps3) + TARGET := $(TARGET_NAME)_libretro_ps3.a + CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe + CXX = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe + AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe + ENDIANNESS_DEFINES += -DMSB_FIRST + PLATFORM_DEFINES := -D__CELLOS_LV2__ -D__POWERPC__ -D__ppc__ + STATIC_LINKING=1 + TILED_RENDERING=1 + +# Lightweight PS3 Homebrew SDK +else ifeq ($(platform), psl1ght) + TARGET := $(TARGET_NAME)_libretro_psl1ght.a + CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT) + CXX = $(PS3DEV)/ppu/bin/ppu-g++$(EXE_EXT) + AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT) + ENDIANNESS_DEFINES += -DMSB_FIRST + PLATFORM_DEFINES := -D__CELLOS_LV2__ -D__POWERPC__ -D__ppc__ + STATIC_LINKING=1 + TILED_RENDERING=1 + +# PSP1 +else ifeq ($(platform), psp1) + TARGET := $(TARGET_NAME)_libretro_$(platform).a + CC = psp-gcc$(EXE_EXT) + CXX = psp-g++$(EXE_EXT) + AR = psp-ar$(EXE_EXT) + PLATFORM_DEFINES := -DPSP + CFLAGS += -G0 + CXXFLAGS += -G0 + STATIC_LINKING=1 + TILED_RENDERING=1 + +# Vita +else ifeq ($(platform), vita) + TARGET := $(TARGET_NAME)_libretro_$(platform).a + CC = arm-vita-eabi-gcc$(EXE_EXT) + CXX = arm-vita-eabi-g++$(EXE_EXT) + AR = arm-vita-eabi-ar$(EXE_EXT) + PLATFORM_DEFINES := -DVITA + __FLAGS := -marm -mfpu=neon -mtune=cortex-a9 -mcpu=cortex-a9 -mfloat-abi=hard -mword-relocations + __FLAGS += -fno-optimize-sibling-calls -fno-strict-aliasing -fno-partial-inlining -fno-tree-vrp + __FLAGS += -ffast-math -fsingle-precision-constant -funroll-loops -ftracer + + CFLAGS += $(__FLAGS) + CXXFLAGS += $(__FLAGS) + CXXFLAGS += -fno-exceptions -fno-rtti + STATIC_LINKING=1 + TILED_RENDERING=1 + USE_CHEATS=0 #for performance boost. + + USE_THREADED_RENDERER=1 + USE_MOTION_SENSOR=1 + USE_FRAME_SKIP=1 + HAVE_NEON=1 + +# Libxenon +else ifeq ($(platform), xenon) + TARGET := $(TARGET_NAME)_libretro_xenon360.a + CC = xenon-gcc$(EXE_EXT) + CXX = xenon-g++$(EXE_EXT) + AR = xenon-ar$(EXE_EXT) + ENDIANNESS_DEFINES += -DMSB_FIRST + PLATFORM_DEFINES := -D__LIBXENON__ -D__POWERPC__ -D__ppc__ + STATIC_LINKING=1 + TILED_RENDERING=1 + +# Nintendo Game Cube +else ifeq ($(platform), ngc) + TARGET := $(TARGET_NAME)_libretro_$(platform).a + CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT) + CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT) + AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) + ENDIANNESS_DEFINES += -DMSB_FIRST + PLATFORM_DEFINES += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ + PLATFORM_DEFINES += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int + STATIC_LINKING=1 + TILED_RENDERING=1 + +# Nintendo Wii +else ifeq ($(platform), wii) + TARGET := $(TARGET_NAME)_libretro_$(platform).a + CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT) + CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT) + AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) + ENDIANNESS_DEFINES += -DMSB_FIRST + PLATFORM_DEFINES += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ + PLATFORM_DEFINES += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int + STATIC_LINKING=1 + TILED_RENDERING=1 + +# Nintendo WiiU +else ifeq ($(platform), wiiu) + TARGET := $(TARGET_NAME)_libretro_$(platform).a + CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT) + CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT) + AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) + ENDIANNESS_DEFINES += -DMSB_FIRST + PLATFORM_DEFINES += -DGEKKO -DWIIU -DHW_RVL -mwup -mcpu=750 -meabi -mhard-float -D__ppc__ + PLATFORM_DEFINES += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int + STATIC_LINKING=1 + TILED_RENDERING=1 + +# Nintendo Switch (libnx) +else ifeq ($(platform), libnx) + include $(DEVKITPRO)/libnx/switch_rules + TARGET := $(TARGET_NAME)_libretro_$(platform).a + DEFINES := -DSWITCH=1 -U__linux__ -U__linux -DRARCH_INTERNAL -DHAVE_THREADS=1 + CFLAGS := $(DEFINES) -g -O3 \ + -fPIE -I$(LIBNX)/include/ -ffunction-sections -fdata-sections -ftls-model=local-exec -Wl,--allow-multiple-definition -specs=$(LIBNX)/switch.specs + CFLAGS += $(INCDIRS) + CFLAGS += $(INCLUDE) -D__SWITCH__ -DHAVE_LIBNX + CXXFLAGS := $(ASFLAGS) $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 + CFLAGS += -std=gnu11 + STATIC_LINKING=1 + +# Nintendo Switch (libtransistor) +else ifeq ($(platform), switch) + TARGET := $(TARGET_NAME)_libretro_$(platform).a + include $(LIBTRANSISTOR_HOME)/libtransistor.mk + STATIC_LINKING=1 + TILED_RENDERING=1 + +else ifneq (,$(findstring armv,$(platform))) + TARGET := $(TARGET_NAME)_libretro.so + SHARED := -shared -Wl,--no-undefined + TILED_RENDERING=1 + fpic := -fPIC + ifneq (,$(findstring cortexa8,$(platform))) + PLATFORM_DEFINES += -marm -mcpu=cortex-a8 + else ifneq (,$(findstring cortexa9,$(platform))) + PLATFORM_DEFINES += -marm -mcpu=cortex-a9 + endif + PLATFORM_DEFINES += -marm + ifneq (,$(findstring neon,$(platform))) + PLATFORM_DEFINES += -mfpu=neon + HAVE_NEON=1 + endif + ifneq (,$(findstring softfloat,$(platform))) + PLATFORM_DEFINES += -mfloat-abi=softfp + else ifneq (,$(findstring hardfloat,$(platform))) + PLATFORM_DEFINES += -mfloat-abi=hard + endif + PLATFORM_DEFINES += -DARM + +# Emscripten +else ifeq ($(platform), emscripten) + TARGET := $(TARGET_NAME)_libretro_$(platform).bc + STATIC_LINKING=1 + +# Windows MSVC 2003 Xbox 1 +else ifeq ($(platform), xbox1_msvc2003) + TARGET := $(TARGET_NAME)_libretro_xdk1.lib + CC = CL.exe + CXX = CL.exe + LD = lib.exe + export INCLUDE := $(XDK)\xbox\include + export LIB := $(XDK)\xbox\lib + PATH := $(call unixcygpath,$(XDK)/xbox/bin/vc71):$(PATH) + PSS_STYLE :=2 + CFLAGS += -D_XBOX -D_XBOX1 + CXXFLAGS += -D_XBOX -D_XBOX1 + TILED_RENDERING=1 + STATIC_LINKING=1 + HAS_GCC := 0 + +# Windows MSVC 2010 Xbox 360 +else ifeq ($(platform), xbox360_msvc2010) + TARGET := $(TARGET_NAME)_libretro_xdk360.lib + MSVCBINDIRPREFIX = $(XEDK)/bin/win32 + CC = "$(MSVCBINDIRPREFIX)/cl.exe" + CXX = "$(MSVCBINDIRPREFIX)/cl.exe" + LD = "$(MSVCBINDIRPREFIX)/lib.exe" + export INCLUDE := $(XEDK)/include/xbox + export LIB := $(XEDK)/lib/xbox + PSS_STYLE :=2 + TILED_RENDERING=1 + ENDIANNESS_DEFINES += -DMSB_FIRST + CFLAGS += -D_XBOX -D_XBOX360 + CXXFLAGS += -D_XBOX -D_XBOX360 + STATIC_LINKING=1 + HAS_GCC := 0 + +# Windows MSVC 2005 x86 +else ifeq ($(platform), windows_msvc2005_x86) + CC = cl.exe + CXX = cl.exe + PATH := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/bin"):$(PATH) + PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../IDE") + INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/include") + LIB := $(shell IFS=$$'\n'; cygpath -w "$(VS80COMNTOOLS)../../VC/lib") + BIN := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/bin") + WindowsSdkDir := $(INETSDK) + export INCLUDE := $(INCLUDE);$(INETSDK)/Include;libretro-common/include/compat/msvc + export LIB := $(LIB);$(WindowsSdkDir);$(INETSDK)/Lib + TARGET := $(TARGET_NAME)_libretro.dll + PSS_STYLE :=2 + LDFLAGS += -DLL + CFLAGS += -D_CRT_SECURE_NO_DEPRECATE + CXXFLAGS += -D_CRT_SECURE_NO_DEPRECATE + +# Windows MSVC 2003 x86 +else ifeq ($(platform), windows_msvc2003_x86) + CC = cl.exe + CXX = cl.exe + PATH := $(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../../Vc7/bin"):$(PATH) + PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../IDE") + INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../../Vc7/include") + LIB := $(shell IFS=$$'\n'; cygpath -w "$(VS71COMNTOOLS)../../Vc7/lib") + BIN := $(shell IFS=$$'\n'; cygpath "$(VS71COMNTOOLS)../../Vc7/bin") + WindowsSdkDir := $(INETSDK) + export INCLUDE := $(INCLUDE);$(INETSDK)/Include;src/drivers/libretro/msvc/msvc-2005 + export LIB := $(LIB);$(WindowsSdkDir);$(INETSDK)/Lib + TARGET := $(TARGET_NAME)_libretro.dll + PSS_STYLE :=2 + LDFLAGS += -DLL + CFLAGS += -D_CRT_SECURE_NO_DEPRECATE + CXXFLAGS += -D_CRT_SECURE_NO_DEPRECATE + # Windows MSVC 2017 all architectures else ifneq (,$(findstring windows_msvc2017,$(platform))) @@ -277,50 +512,40 @@ else ifneq (,$(findstring windows_msvc2017,$(platform))) PSS_STYLE :=2 LDFLAGS += -DLL +# Windows else - TARGET := $(TARGET_NAME)_libretro.dll - LDFLAGS += -Wl,-no-undefined -Wl,--version-script=link.T - CC = gcc - CXX = g++ - SHARED := -shared -static-libgcc -static-libstdc++ + TARGET := $(TARGET_NAME)_libretro.dll + CC = gcc + CXX = g++ + SHARED := -shared -static-libgcc -static-libstdc++ -Wl,-no-undefined -Wl,-version-script=$(LIBRETRO_DIR)/link.T + TILED_RENDERING=1 endif -ifeq ($(TILED_RENDERING), 1) -VBA_DEFINES += -DTILED_RENDERING -endif - -CORE_DIR := .. - -include Makefile.common +include $(CORE_DIR)/libretro/Makefile.common OBJS := $(SOURCES_CXX:.cpp=.o) -VBA_DEFINES += -D__LIBRETRO__ -DFINAL_VERSION -DC_CORE -DNO_DEBUGGER - -ifeq ($(FRONTEND_SUPPORTS_RGB565),1) -VBA_DEFINES += -DFRONTEND_SUPPORTS_RGB565 -endif - -ifeq ($(NO_LINK),1) -VBA_DEFINES += -DNO_LINK +ifeq ($(STATIC_LINKING),1) +SHARED= +fpic= endif ifneq ($(SANITIZER),) - CFLAGS += -fsanitize=$(SANITIZER) - CXXFLAGS += -fsanitize=$(SANITIZER) - LDFLAGS += -fsanitize=$(SANITIZER) + CFLAGS += -fsanitize=$(SANITIZER) + CXXFLAGS += -fsanitize=$(SANITIZER) + LDFLAGS += -fsanitize=$(SANITIZER) endif ifeq ($(DEBUG), 1) - CFLAGS += -O0 -g - CXXFLAGS += -O0 -g + CFLAGS += -O0 -g + CXXFLAGS += -O0 -g else - CFLAGS += -O2 -DNDEBUG - CXXFLAGS += -O2 -DNDEBUG + CFLAGS += -O2 -DNDEBUG + CXXFLAGS += -O2 -DNDEBUG endif -CFLAGS += $(fpic) $(VBA_DEFINES) -CXXFLAGS += $(fpic) $(VBA_DEFINES) +CFLAGS += $(fpic) $(VBA_DEFINES) $(ENDIANNESS_DEFINES) $(PLATFORM_DEFINES) +CXXFLAGS += $(fpic) $(VBA_DEFINES) $(ENDIANNESS_DEFINES) $(PLATFORM_DEFINES) OBJOUT = -o LINKOUT = -o @@ -355,10 +580,10 @@ else endif %.o: %.cpp - $(CXX) -c $(OBJOUT)$@ $< $(CXXFLAGS) $(INCFLAGS) + $(CXX) -c $(OBJOUT) $@ $< $(CXXFLAGS) $(INCFLAGS) %.o: %.c - $(CC) -c $(OBJOUT)$@ $< $(CFLAGS) $(INCFLAGS) + $(CC) -c $(OBJOUT) $@ $< $(CFLAGS) $(INCFLAGS) ifeq ($(platform), theos_ios) COMMON_FLAGS := -DIOS $(COMMON_DEFINES) $(INCFLAGS) -I$(THEOS_INCLUDE_PATH) -Wno-error @@ -373,7 +598,7 @@ $(TARGET): $(OBJS) ifeq ($(STATIC_LINKING), 1) $(AR) rcs $@ $(OBJS) else - $(LD) $(LINKOUT)$@ $(SHARED) $(OBJS) $(LDFLAGS) $(LIBS) + $(LD) $(LINKOUT) $@ $(SHARED) $(OBJS) $(LDFLAGS) $(LIBS) endif clean: diff --git a/src/libretro/Makefile.common b/src/libretro/Makefile.common index 9776ba71..7e3f992f 100644 --- a/src/libretro/Makefile.common +++ b/src/libretro/Makefile.common @@ -1,8 +1,20 @@ -LIBRETRO_COMMON := $(CORE_DIR)/libretro/libretro-common/include +LIBRETRO_COMMON := $(CORE_DIR)/libretro/libretro-common +INCFLAGS := -I$(CORE_DIR) -I$(LIBRETRO_COMMON)/include +VBA_DEFINES := -D__LIBRETRO__ -DFINAL_VERSION -DC_CORE -DNO_DEBUGGER + +ifeq ($(TILED_RENDERING), 1) +VBA_DEFINES += -DTILED_RENDERING +endif + +ifeq ($(FRONTEND_SUPPORTS_RGB565),1) +VBA_DEFINES += -DFRONTEND_SUPPORTS_RGB565 +endif + +ifeq ($(NO_LINK),1) +VBA_DEFINES += -DNO_LINK +endif -INCFLAGS := -I$(CORE_DIR) -I$(LIBRETRO_COMMON) SOURCES_CXX := - SOURCES_CXX += \ $(CORE_DIR)/libretro/libretro.cpp \ $(CORE_DIR)/libretro/UtilRetro.cpp \ diff --git a/src/libretro/jni/Android.mk b/src/libretro/jni/Android.mk index 304e8042..5868e9a4 100644 --- a/src/libretro/jni/Android.mk +++ b/src/libretro/jni/Android.mk @@ -1,21 +1,16 @@ -LOCAL_PATH := $(call my-dir) - +LOCAL_PATH := $(call my-dir) CORE_DIR := $(LOCAL_PATH)/../.. LIBRETRO_DIR := $(CORE_DIR)/libretro +FRONTEND_SUPPORTS_RGB565 := 1 +TILED_RENDERING := 1 + include $(LIBRETRO_DIR)/Makefile.common -COREFLAGS := -DHAVE_STDINT_H -DLSB_FIRST -D__LIBRETRO__ -DFINAL_VERSION -DC_CORE -DNO_LINK -DFRONTEND_SUPPORTS_RGB565 -DTILED_RENDERING -DNO_DEBUGGER $(INCFLAGS) - -#GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)" -#ifneq ($(GIT_VERSION)," unknown") -# COREFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\" -#endif +COREFLAGS := -DHAVE_STDINT_H $(VBA_DEFINES) $(INCFLAGS) VBAM_VERSION := $(shell sed -En 's/.*\[([0-9]+[^]]+).*/\1/p; T; q' ../../CHANGELOG.md 2>/dev/null) - COREFLAGS += -DVBAM_VERSION=\"$(VBAM_VERSION)\" - TAG_COMMIT := $(shell git rev-list -n 1 v$(VBAM_VERSION) --abbrev-commit 2>/dev/null) CURRENT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null) From d9f8396c6712323c3e47b2d2db591d0ea55b6b12 Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Tue, 6 Aug 2019 00:34:13 +0800 Subject: [PATCH 02/13] Cleanup --- src/gb/gb.h | 7 ++ src/gb/gbSound.cpp | 2 +- src/gba/Flash.cpp | 134 +++++++++++++------------- src/gba/GBA-arm.cpp | 1 + src/gba/GBA.h | 3 + src/gba/Sound.cpp | 2 + src/libretro/Makefile.common | 3 +- src/libretro/libretro.cpp | 104 ++++++++++---------- src/libretro/{scrc32.cpp => scrc32.h} | 8 -- 9 files changed, 137 insertions(+), 127 deletions(-) rename src/libretro/{scrc32.cpp => scrc32.h} (98%) diff --git a/src/gb/gb.h b/src/gb/gb.h index 527c41c4..4ef81090 100644 --- a/src/gb/gb.h +++ b/src/gb/gb.h @@ -1,6 +1,11 @@ #ifndef GB_H #define GB_H +#define gbWidth 160 +#define gbHeight 144 +#define sgbWidth 256 +#define sgbHeight 224 + const int GB_C_FLAG = 0x10; const int GB_H_FLAG = 0x20; const int GB_N_FLAG = 0x40; @@ -55,6 +60,8 @@ void setColorizerHack(bool value); bool allowColorizerHack(void); extern int gbHardware; +extern int gbRomType; // gets type from header 0x147 +extern int gbBattery; // enabled when gbRamSize != 0 extern struct EmulatedSystem GBSystem; diff --git a/src/gb/gbSound.cpp b/src/gb/gbSound.cpp index 2420f346..c77f7b89 100644 --- a/src/gb/gbSound.cpp +++ b/src/gb/gbSound.cpp @@ -246,6 +246,7 @@ static char dummy_state[735 * 2]; &name, sizeof(type) \ } +#ifndef __LIBRETRO__ // Old save state support static variable_desc gbsound_format[] = { @@ -355,7 +356,6 @@ enum { nr52 }; -#ifndef __LIBRETRO__ static void gbSoundReadGameOld(int version, gzFile gzFile) { if (version == 11) { diff --git a/src/gba/Flash.cpp b/src/gba/Flash.cpp index bd14a43e..c3c5585a 100644 --- a/src/gba/Flash.cpp +++ b/src/gba/Flash.cpp @@ -27,30 +27,6 @@ int flashDeviceID = 0x1b; int flashManufacturerID = 0x32; int flashBank = 0; -static variable_desc flashSaveData[] = { - { &flashState, sizeof(int) }, - { &flashReadState, sizeof(int) }, - { &flashSaveMemory[0], SIZE_FLASH512 }, - { NULL, 0 } -}; - -static variable_desc flashSaveData2[] = { - { &flashState, sizeof(int) }, - { &flashReadState, sizeof(int) }, - { &flashSize, sizeof(int) }, - { &flashSaveMemory[0], SIZE_FLASH1M }, - { NULL, 0 } -}; - -static variable_desc flashSaveData3[] = { - { &flashState, sizeof(int) }, - { &flashReadState, sizeof(int) }, - { &flashSize, sizeof(int) }, - { &flashBank, sizeof(int) }, - { &flashSaveMemory[0], SIZE_FLASH1M }, - { NULL, 0 } -}; - void flashInit() { memset(flashSaveMemory, 0xff, sizeof(flashSaveMemory)); @@ -63,49 +39,6 @@ void flashReset() flashBank = 0; } -#ifdef __LIBRETRO__ -void flashSaveGame(uint8_t*& data) -{ - utilWriteDataMem(data, flashSaveData3); -} - -void flashReadGame(const uint8_t*& data, int) -{ - utilReadDataMem(data, flashSaveData3); -} - -#else // !__LIBRETRO__ -void flashSaveGame(gzFile gzFile) -{ - utilWriteData(gzFile, flashSaveData3); -} - -void flashReadGame(gzFile gzFile, int version) -{ - if (version < SAVE_GAME_VERSION_5) - utilReadData(gzFile, flashSaveData); - else if (version < SAVE_GAME_VERSION_7) { - utilReadData(gzFile, flashSaveData2); - flashBank = 0; - flashSetSize(flashSize); - } else { - utilReadData(gzFile, flashSaveData3); - } -} - -void flashReadGameSkip(gzFile gzFile, int version) -{ - // skip the flash data in a save game - if (version < SAVE_GAME_VERSION_5) - utilReadDataSkip(gzFile, flashSaveData); - else if (version < SAVE_GAME_VERSION_7) { - utilReadDataSkip(gzFile, flashSaveData2); - } else { - utilReadDataSkip(gzFile, flashSaveData3); - } -} -#endif - void flashSetSize(int size) { // log("Setting flash size to %d\n", size); @@ -279,3 +212,70 @@ void flashWrite(uint32_t address, uint8_t byte) break; } } + +static variable_desc flashSaveData3[] = { + { &flashState, sizeof(int) }, + { &flashReadState, sizeof(int) }, + { &flashSize, sizeof(int) }, + { &flashBank, sizeof(int) }, + { &flashSaveMemory[0], SIZE_FLASH1M }, + { NULL, 0 } +}; + +#ifdef __LIBRETRO__ +void flashSaveGame(uint8_t*& data) +{ + utilWriteDataMem(data, flashSaveData3); +} + +void flashReadGame(const uint8_t*& data, int) +{ + utilReadDataMem(data, flashSaveData3); +} + +#else // !__LIBRETRO__ +static variable_desc flashSaveData[] = { + { &flashState, sizeof(int) }, + { &flashReadState, sizeof(int) }, + { &flashSaveMemory[0], SIZE_FLASH512 }, + { NULL, 0 } +}; + +static variable_desc flashSaveData2[] = { + { &flashState, sizeof(int) }, + { &flashReadState, sizeof(int) }, + { &flashSize, sizeof(int) }, + { &flashSaveMemory[0], SIZE_FLASH1M }, + { NULL, 0 } +}; + +void flashSaveGame(gzFile gzFile) +{ + utilWriteData(gzFile, flashSaveData3); +} + +void flashReadGame(gzFile gzFile, int version) +{ + if (version < SAVE_GAME_VERSION_5) + utilReadData(gzFile, flashSaveData); + else if (version < SAVE_GAME_VERSION_7) { + utilReadData(gzFile, flashSaveData2); + flashBank = 0; + flashSetSize(flashSize); + } else { + utilReadData(gzFile, flashSaveData3); + } +} + +void flashReadGameSkip(gzFile gzFile, int version) +{ + // skip the flash data in a save game + if (version < SAVE_GAME_VERSION_5) + utilReadDataSkip(gzFile, flashSaveData); + else if (version < SAVE_GAME_VERSION_7) { + utilReadDataSkip(gzFile, flashSaveData2); + } else { + utilReadDataSkip(gzFile, flashSaveData3); + } +} +#endif diff --git a/src/gba/GBA-arm.cpp b/src/gba/GBA-arm.cpp index 2eea3824..5eb2ba04 100644 --- a/src/gba/GBA-arm.cpp +++ b/src/gba/GBA-arm.cpp @@ -1235,6 +1235,7 @@ DEFINE_ALU_INSN_C(1F, 3F, MVNS, YES) int mult = (opcode & 0x0F); \ uint32_t rs = reg[(opcode >> 8) & 0x0F].I; \ int acc = (opcode >> 12) & 0x0F; /* or destLo */ \ + maybe_unused(acc); \ int dest = (opcode >> 16) & 0x0F; /* or destHi */ \ OP; \ SETCOND; \ diff --git a/src/gba/GBA.h b/src/gba/GBA.h index 8649b2e5..bee3ba19 100644 --- a/src/gba/GBA.h +++ b/src/gba/GBA.h @@ -19,6 +19,9 @@ const uint64_t TICKS_PER_SECOND = 16777216; #define SAVE_GAME_VERSION_10 10 #define SAVE_GAME_VERSION SAVE_GAME_VERSION_10 +#define gbaWidth 240 +#define gbaHeight 160 + enum { GBA_SAVE_AUTO = 0, GBA_SAVE_EEPROM, diff --git a/src/gba/Sound.cpp b/src/gba/Sound.cpp index dba4ce01..d6376ff2 100644 --- a/src/gba/Sound.cpp +++ b/src/gba/Sound.cpp @@ -588,6 +588,7 @@ static struct { int soundDSBValue; } state; +#ifndef __LIBRETRO__ // Old GBA sound state format static variable_desc old_gba_state[] = { SKIP(int, soundPaused), @@ -673,6 +674,7 @@ variable_desc old_gba_state2[] = { SKIP(int, sound3ForcedOutput), { NULL, 0 } }; +#endif // New state format static variable_desc gba_state[] = { diff --git a/src/libretro/Makefile.common b/src/libretro/Makefile.common index 9776ba71..38e9ad27 100644 --- a/src/libretro/Makefile.common +++ b/src/libretro/Makefile.common @@ -6,8 +6,7 @@ SOURCES_CXX := SOURCES_CXX += \ $(CORE_DIR)/libretro/libretro.cpp \ $(CORE_DIR)/libretro/UtilRetro.cpp \ - $(CORE_DIR)/libretro/SoundRetro.cpp \ - $(CORE_DIR)/libretro/scrc32.cpp + $(CORE_DIR)/libretro/SoundRetro.cpp SOURCES_CXX += \ $(CORE_DIR)/apu/Gb_Oscs.cpp \ diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index d77f730f..2b5d7f77 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -8,6 +8,7 @@ #include "SoundRetro.h" #include "libretro.h" #include "libretro_core_options.h" +#include "scrc32.h" #include "../System.h" #include "../Util.h" @@ -40,27 +41,20 @@ static retro_environment_t environ_cb; retro_audio_sample_batch_t audio_batch_cb; static retro_set_rumble_state_t rumble_cb; -static char retro_system_directory[4096]; +static char retro_system_directory[2048]; static char biosfile[4096]; static float sndFiltering = 0.5f; static bool sndInterpolation = true; static bool can_dupe = false; static bool usebios = false; static unsigned retropad_device[4] = {0}; - static const double FramesPerSecond = (16777216.0 / 280896.0); // 59.73 static const long SampleRate = 32768; -static const int GBWidth = 160; -static const int GBHeight = 144; -static const int SGBWidth = 256; -static const int SGBHeight = 224; -static const int GBAWidth = 240; -static const int GBAHeight = 160; -static unsigned width = 240; -static unsigned height = 160; +static unsigned width = gbaWidth; +static unsigned height = gbaHeight; static EmulatedSystem* core = NULL; static IMAGE_TYPE type = IMAGE_UNKNOWN; -static unsigned current_gbPalette; +static unsigned current_gbPalette = 0; static bool opt_colorizer_hack = false; uint16_t systemColorMap16[0x10000]; @@ -220,9 +214,6 @@ static void set_gbColorCorrection(int value) gbColorOption = value; } -extern int gbRomType; // gets type from header 0x147 -extern int gbBattery; // enabled when gbRamSize != 0 - static bool gb_hasrtc(void) { switch (gbRomType) { @@ -745,13 +736,11 @@ static void load_image_preferences(void) "NONE" }; - char buffer[5]; - - buffer[0] = rom[0xac]; - buffer[1] = rom[0xad]; - buffer[2] = rom[0xae]; - buffer[3] = rom[0xaf]; - buffer[4] = 0; + bool found = false; + bool hasRumble = false; + char buffer[12]; + unsigned i = 0, found_no = 0; + unsigned long romCrc32 = crc32(0, rom, romSize); cpuSaveType = GBA_SAVE_AUTO; flashSize = SIZE_FLASH512; @@ -759,12 +748,26 @@ static void load_image_preferences(void) rtcEnabled = false; mirroringEnable = false; - log("GameID in ROM is: %s\n", buffer); + log("File CRC32 : 0x%08X\n", romCrc32); - bool found = false; - int found_no = 0; + buffer[0] = 0; + for (i = 0; i < 12; i++) { + if (rom[0xa0 + i] == 0) + break; + buffer[i] = rom[0xa0 + i]; + } - for (int i = 0; i < 512; i++) { + buffer[i] = 0; + log("Game Title : %s\n", buffer); + + buffer[0] = rom[0xac]; + buffer[1] = rom[0xad]; + buffer[2] = rom[0xae]; + buffer[3] = rom[0xaf]; + buffer[4] = 0; + log("Game Code : %s\n", buffer); + + for (i = 0; i < 512; i++) { if (!strcmp(gbaover[i].romid, buffer)) { found = true; found_no = i; @@ -773,7 +776,6 @@ static void load_image_preferences(void) } if (found) { - log("Found ROM in vba-over list.\n"); log("Name : %s\n", gbaover[found_no].romtitle); rtcEnabled = gbaover[found_no].rtcEnabled; @@ -789,12 +791,10 @@ static void load_image_preferences(void) } // gameID that starts with 'F' are classic/famicom games - mirroringEnable = (buffer[0] == 0x46) ? true : false; + mirroringEnable = (buffer[0] == 'F') ? true : false; - if (!cpuSaveType) { - log("Scrapping ROM for save type.\n"); + if (!cpuSaveType) utilGBAFindSave(romSize); - } saveType = cpuSaveType; @@ -802,7 +802,12 @@ static void load_image_preferences(void) flashSetSize(flashSize); rtcEnable(rtcEnabled); - rtcEnableRumble(!rtcEnabled); + + // game code starting with 'R' or 'V' has rumble support + if ((buffer[0] == 'R') || (buffer[0] == 'V')) + hasRumble = true; + + rtcEnableRumble(!rtcEnabled && hasRumble); doMirroring(mirroringEnable); @@ -811,7 +816,7 @@ static void load_image_preferences(void) log("cpuSaveType : %s.\n", savetype[cpuSaveType]); if (cpuSaveType == 3) log("flashSize : %d.\n", flashSize); - if (cpuSaveType == 1) + else if (cpuSaveType == 1) log("eepromSize : %d.\n", eepromSize); log("mirroringEnable : %s.\n", mirroringEnable ? "Yes" : "No"); } @@ -854,8 +859,8 @@ static void gba_init(void) } CPUInit(biosfile, usebios); - width = GBAWidth; - height = GBAHeight; + width = gbaWidth; + height = gbaHeight; CPUReset(); } @@ -883,13 +888,13 @@ static void gb_init(void) gbCPUInit(biosfile, usebios); if (gbBorderOn) { - width = gbBorderLineSkip = SGBWidth; - height = SGBHeight; - gbBorderColumnSkip = (SGBWidth - GBWidth) >> 1; - gbBorderRowSkip = (SGBHeight - GBHeight) >> 1; + width = gbBorderLineSkip = sgbWidth; + height = sgbHeight; + gbBorderColumnSkip = (sgbWidth - gbWidth) >> 1; + gbBorderRowSkip = (sgbHeight - gbHeight) >> 1; } else { - width = gbBorderLineSkip = GBWidth; - height = GBHeight; + width = gbBorderLineSkip = gbWidth; + height = gbHeight; gbBorderColumnSkip = gbBorderRowSkip = 0; } @@ -1171,7 +1176,7 @@ static void update_variables(bool startup) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { - int lastpal = current_gbPalette; + unsigned lastpal = current_gbPalette; if (!strcmp(var.value, "black and white")) current_gbPalette = 0; @@ -1443,6 +1448,7 @@ void retro_cheat_set(unsigned index, bool enabled, const char* code) memset(codeLine, 0, codeLineSize); } break; + default: break; } if (!code[cursor]) break; @@ -1646,11 +1652,11 @@ void systemFrame(void) void systemGbBorderOn(void) { - bool changed = ((width != SGBWidth) || (height != SGBHeight)); - width = gbBorderLineSkip = SGBWidth; - height = SGBHeight; - gbBorderColumnSkip = (SGBWidth - GBWidth) >> 1; - gbBorderRowSkip = (SGBHeight - GBHeight) >> 1; + bool changed = ((width != sgbWidth) || (height != sgbHeight)); + width = gbBorderLineSkip = sgbWidth; + height = sgbHeight; + gbBorderColumnSkip = (sgbWidth - gbWidth) >> 1; + gbBorderRowSkip = (sgbHeight - gbHeight) >> 1; struct retro_system_av_info avinfo; retro_get_system_av_info(&avinfo); @@ -1663,9 +1669,9 @@ void systemGbBorderOn(void) static void systemGbBorderOff(void) { - bool changed = ((width != GBWidth) || (height != GBHeight)); - width = gbBorderLineSkip = GBWidth; - height = GBHeight; + bool changed = ((width != gbWidth) || (height != gbHeight)); + width = gbBorderLineSkip = gbWidth; + height = gbHeight; gbBorderColumnSkip = gbBorderRowSkip = 0; struct retro_system_av_info avinfo; diff --git a/src/libretro/scrc32.cpp b/src/libretro/scrc32.h similarity index 98% rename from src/libretro/scrc32.cpp rename to src/libretro/scrc32.h index 0c1204ea..c7599928 100644 --- a/src/libretro/scrc32.cpp +++ b/src/libretro/scrc32.h @@ -1,10 +1,6 @@ #ifndef _S_CRC32_H #define _S_CRC32_H -#ifdef __cplusplus -extern "C" { -#endif - static const unsigned long crc_table[256] = { 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, @@ -87,8 +83,4 @@ unsigned long crc32(unsigned long crc, const unsigned char* buf, unsigned int le return crc ^ 0xffffffffL; } -#ifdef __cplusplus -} -#endif - #endif From 98313652d6c2faa86f349b60eef6bd47d6a21f51 Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Tue, 6 Aug 2019 19:19:12 +0800 Subject: [PATCH 03/13] Update Makefile - Try to fix osx build - style nits and cleanup --- src/libretro/Makefile | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/libretro/Makefile b/src/libretro/Makefile index f4dfb968..20198aaf 100644 --- a/src/libretro/Makefile +++ b/src/libretro/Makefile @@ -43,11 +43,11 @@ else ifneq ($(findstring MINGW,$(shell uname -a)),) system_platform = win endif -CORE_DIR := .. +CORE_DIR := .. LIBRETRO_DIR := $(CORE_DIR)/libretro -TARGET_NAME := vbam +TARGET_NAME := vbam -VBAM_VERSION := $(shell sed -En 's/.*\[([0-9]+[^]]+).*/\1/p; T; q' ../../CHANGELOG.md 2>/dev/null) +VBAM_VERSION := $(shell sed -En 's/.*\[([0-9]+[^]]+).*/\1/p; T; q' ../../CHANGELOG.md 2>/dev/null) TAG_COMMIT := $(shell git rev-list -n 1 v$(VBAM_VERSION) --abbrev-commit 2>/dev/null) CURRENT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null) @@ -77,7 +77,7 @@ else ifeq ($(platform), classic_armv7_a7) -flto=4 -fwhole-program -fuse-linker-plugin \ -fdata-sections -ffunction-sections -Wl,--gc-sections \ -fno-stack-protector -fno-ident -fomit-frame-pointer \ - -falign-functions=1 -falign-jumps=1 -falign-loops=1 \ + -falign-functions=1 -falign-jumps=1 -falign-loops=1 \ -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \ -fmerge-all-constants -fno-math-errno \ -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard @@ -110,7 +110,7 @@ else ifeq ($(platform), classic_armv8_a35) -flto=4 -fwhole-program -fuse-linker-plugin \ -fdata-sections -ffunction-sections -Wl,--gc-sections \ -fno-stack-protector -fno-ident -fomit-frame-pointer \ - -falign-functions=1 -falign-jumps=1 -falign-loops=1 \ + -falign-functions=1 -falign-jumps=1 -falign-loops=1 \ -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \ -fmerge-all-constants -fno-math-errno \ -marm -mtune=cortex-a35 -mfpu=neon-fp-armv8 -mfloat-abi=hard @@ -138,7 +138,7 @@ else ifeq ($(platform), osx) endif OSXVER = `sw_vers -productVersion | cut -d. -f 2` OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"` - fpic += -mmacosx-version-min=1 0.2 + fpic += -mmacosx-version-min=10.2 SHARED := -dynamiclib TILED_RENDERING=1 @@ -230,7 +230,7 @@ else ifeq ($(platform), psp1) CC = psp-gcc$(EXE_EXT) CXX = psp-g++$(EXE_EXT) AR = psp-ar$(EXE_EXT) - PLATFORM_DEFINES := -DPSP + PLATFORM_DEFINES := -DPSP CFLAGS += -G0 CXXFLAGS += -G0 STATIC_LINKING=1 @@ -242,7 +242,7 @@ else ifeq ($(platform), vita) CC = arm-vita-eabi-gcc$(EXE_EXT) CXX = arm-vita-eabi-g++$(EXE_EXT) AR = arm-vita-eabi-ar$(EXE_EXT) - PLATFORM_DEFINES := -DVITA + PLATFORM_DEFINES := -DVITA __FLAGS := -marm -mfpu=neon -mtune=cortex-a9 -mcpu=cortex-a9 -mfloat-abi=hard -mword-relocations __FLAGS += -fno-optimize-sibling-calls -fno-strict-aliasing -fno-partial-inlining -fno-tree-vrp __FLAGS += -ffast-math -fsingle-precision-constant -funroll-loops -ftracer @@ -310,11 +310,11 @@ else ifeq ($(platform), wiiu) else ifeq ($(platform), libnx) include $(DEVKITPRO)/libnx/switch_rules TARGET := $(TARGET_NAME)_libretro_$(platform).a - DEFINES := -DSWITCH=1 -U__linux__ -U__linux -DRARCH_INTERNAL -DHAVE_THREADS=1 + DEFINES := -DSWITCH=1 -U__linux__ -U__linux -DRARCH_INTERNAL -DHAVE_THREADS=1 CFLAGS := $(DEFINES) -g -O3 \ -fPIE -I$(LIBNX)/include/ -ffunction-sections -fdata-sections -ftls-model=local-exec -Wl,--allow-multiple-definition -specs=$(LIBNX)/switch.specs CFLAGS += $(INCDIRS) - CFLAGS += $(INCLUDE) -D__SWITCH__ -DHAVE_LIBNX + CFLAGS += $(INCLUDE) -D__SWITCH__ -DHAVE_LIBNX CXXFLAGS := $(ASFLAGS) $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 CFLAGS += -std=gnu11 STATIC_LINKING=1 @@ -357,8 +357,8 @@ else ifeq ($(platform), emscripten) else ifeq ($(platform), xbox1_msvc2003) TARGET := $(TARGET_NAME)_libretro_xdk1.lib CC = CL.exe - CXX = CL.exe - LD = lib.exe + CXX = CL.exe + LD = lib.exe export INCLUDE := $(XDK)\xbox\include export LIB := $(XDK)\xbox\lib PATH := $(call unixcygpath,$(XDK)/xbox/bin/vc71):$(PATH) @@ -374,8 +374,8 @@ else ifeq ($(platform), xbox360_msvc2010) TARGET := $(TARGET_NAME)_libretro_xdk360.lib MSVCBINDIRPREFIX = $(XEDK)/bin/win32 CC = "$(MSVCBINDIRPREFIX)/cl.exe" - CXX = "$(MSVCBINDIRPREFIX)/cl.exe" - LD = "$(MSVCBINDIRPREFIX)/lib.exe" + CXX = "$(MSVCBINDIRPREFIX)/cl.exe" + LD = "$(MSVCBINDIRPREFIX)/lib.exe" export INCLUDE := $(XEDK)/include/xbox export LIB := $(XEDK)/lib/xbox PSS_STYLE :=2 @@ -521,7 +521,7 @@ else TILED_RENDERING=1 endif -include $(CORE_DIR)/libretro/Makefile.common +include Makefile.common OBJS := $(SOURCES_CXX:.cpp=.o) @@ -544,8 +544,8 @@ else CXXFLAGS += -O2 -DNDEBUG endif -CFLAGS += $(fpic) $(VBA_DEFINES) $(ENDIANNESS_DEFINES) $(PLATFORM_DEFINES) -CXXFLAGS += $(fpic) $(VBA_DEFINES) $(ENDIANNESS_DEFINES) $(PLATFORM_DEFINES) +CFLAGS += -Wall $(fpic) $(VBA_DEFINES) $(ENDIANNESS_DEFINES) $(PLATFORM_DEFINES) +CXXFLAGS += -Wall $(fpic) $(VBA_DEFINES) $(ENDIANNESS_DEFINES) $(PLATFORM_DEFINES) OBJOUT = -o LINKOUT = -o From bb1095446655fda8271eab8e67da70e828f4e8e0 Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Wed, 7 Aug 2019 01:55:52 +0800 Subject: [PATCH 04/13] Update Makefile --- src/libretro/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libretro/Makefile b/src/libretro/Makefile index 20198aaf..a3d942aa 100644 --- a/src/libretro/Makefile +++ b/src/libretro/Makefile @@ -580,10 +580,10 @@ else endif %.o: %.cpp - $(CXX) -c $(OBJOUT) $@ $< $(CXXFLAGS) $(INCFLAGS) + $(CXX) -c $(OBJOUT)$@ $< $(CXXFLAGS) $(INCFLAGS) %.o: %.c - $(CC) -c $(OBJOUT) $@ $< $(CFLAGS) $(INCFLAGS) + $(CC) -c $(OBJOUT)$@ $< $(CFLAGS) $(INCFLAGS) ifeq ($(platform), theos_ios) COMMON_FLAGS := -DIOS $(COMMON_DEFINES) $(INCFLAGS) -I$(THEOS_INCLUDE_PATH) -Wno-error @@ -598,7 +598,7 @@ $(TARGET): $(OBJS) ifeq ($(STATIC_LINKING), 1) $(AR) rcs $@ $(OBJS) else - $(LD) $(LINKOUT) $@ $(SHARED) $(OBJS) $(LDFLAGS) $(LIBS) + $(LD) $(LINKOUT)$@ $(SHARED) $(OBJS) $(LDFLAGS) $(LIBS) endif clean: From 496b372d3e4e5aaced92eb105a6855ec3583131c Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Wed, 7 Aug 2019 20:05:57 +0800 Subject: [PATCH 05/13] Allow enabling GBA RTC regardless of rom types - Add core option to allow RTC to be enabled regardless of rom. This usuable for rom patches that requires the RTC to be enabled yet the RTC flag is not enabled. (aka Pokemon patches) --- src/libretro/libretro.cpp | 19 ++++++++++++++++--- src/libretro/libretro_core_options.h | 11 +++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index 2b5d7f77..3450a2a6 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -56,6 +56,7 @@ static EmulatedSystem* core = NULL; static IMAGE_TYPE type = IMAGE_UNKNOWN; static unsigned current_gbPalette = 0; static bool opt_colorizer_hack = false; +static bool opt_forceRTCenable = false; uint16_t systemColorMap16[0x10000]; uint32_t systemColorMap32[0x10000]; @@ -801,6 +802,9 @@ static void load_image_preferences(void) if (flashSize == SIZE_FLASH512 || flashSize == SIZE_FLASH1M) flashSetSize(flashSize); + if (opt_forceRTCenable) + rtcEnabled = true; + rtcEnable(rtcEnabled); // game code starting with 'R' or 'V' has rumble support @@ -1059,6 +1063,14 @@ static void update_variables(bool startup) usebios = newval; } + var.key = "vbam_forceRTCenable"; + var.value = NULL; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + bool newval = (strcmp(var.value, "enabled") == 0) ? true : false; + opt_forceRTCenable = newval; + } + var.key = "vbam_solarsensor"; var.value = NULL; @@ -1221,11 +1233,12 @@ static void update_variables(bool startup) "vbam_showborders", "vbam_gbcoloroption" }; - char gba_options[4][22] = { + char gba_options[5][22] = { "vbam_solarsensor", "vbam_sound_5", "vbam_sound_6", - "vbam_gyro_sensitivity" + "vbam_gyro_sensitivity", + "vbam_forceRTCenable" }; // Show or hide GB/GBC only options @@ -1238,7 +1251,7 @@ static void update_variables(bool startup) // Show or hide GBA only options option_display.visible = (type == IMAGE_GBA) ? 1 : 0; - for (i = 0; i < 4; i++) + for (i = 0; i < 5; i++) { option_display.key = gba_options[i]; environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display); diff --git a/src/libretro/libretro_core_options.h b/src/libretro/libretro_core_options.h index 8f234b27..20b5c424 100644 --- a/src/libretro/libretro_core_options.h +++ b/src/libretro/libretro_core_options.h @@ -58,6 +58,17 @@ struct retro_core_option_definition option_defs_us[] = { }, "disabled" }, + { + "vbam_forceRTCenable", + "Force enable RTC", + "Forces the internal real-time clock to be enabled regardless of rom. Usuable for rom patches that requires clock to be enabled (aka Pokemon).", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "disabled" + }, { "vbam_soundinterpolation", "Sound Interpolation", From 9757a880c7a8c2205a80aa65e0d42606e34f9523 Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Fri, 9 Aug 2019 22:19:12 +0800 Subject: [PATCH 06/13] Core options cleanup and a few readability-related updates changes includes: - append "options_" to core-related variables - remove some unnecessary function calls - change some float data types to double - set max geometry width/height depending on max values for the system being emulated - create advanced core options to minimize the number of options shown - style nits --- src/libretro/libretro.cpp | 332 ++++++++++++++------------- src/libretro/libretro_core_options.h | 51 ++-- 2 files changed, 198 insertions(+), 185 deletions(-) diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index 3450a2a6..382c4d07 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -33,31 +33,37 @@ #include "../gb/gbSGB.h" #include "../gb/gbSound.h" +#define FRAMERATE (16777216.0 / 280896.0) // 59.73 +#define SAMPLERATE 32768.0 + static retro_log_printf_t log_cb; static retro_video_refresh_t video_cb; static retro_input_poll_t poll_cb; static retro_input_state_t input_cb; static retro_environment_t environ_cb; -retro_audio_sample_batch_t audio_batch_cb; static retro_set_rumble_state_t rumble_cb; +retro_audio_sample_batch_t audio_batch_cb; static char retro_system_directory[2048]; static char biosfile[4096]; -static float sndFiltering = 0.5f; -static bool sndInterpolation = true; static bool can_dupe = false; -static bool usebios = false; + +// core options +static bool option_sndInterpolation = true; +static bool option_useBios = false; +static bool option_colorizerHack = false; +static bool option_forceRTCenable = false; +static bool option_showAdvancedOptions = false; +static double option_sndFiltering = 0.5; +static unsigned option_gbPalette = 0; + static unsigned retropad_device[4] = {0}; -static const double FramesPerSecond = (16777216.0 / 280896.0); // 59.73 -static const long SampleRate = 32768; -static unsigned width = gbaWidth; -static unsigned height = gbaHeight; +static unsigned systemWidth = gbaWidth; +static unsigned systemHeight = gbaHeight; static EmulatedSystem* core = NULL; static IMAGE_TYPE type = IMAGE_UNKNOWN; -static unsigned current_gbPalette = 0; -static bool opt_colorizer_hack = false; -static bool opt_forceRTCenable = false; +// global vars uint16_t systemColorMap16[0x10000]; uint32_t systemColorMap32[0x10000]; int RGB_LOW_BITS_MASK = 0; @@ -203,18 +209,13 @@ static void set_gbPalette(void) if (gbCgbMode || gbSgbMode) return; - const uint16_t *pal = defaultGBPalettes[current_gbPalette].data; + const uint16_t *pal = defaultGBPalettes[option_gbPalette].data; for (int i = 0; i < 8; i++) { uint16_t val = pal[i]; gbPalette[i] = val; } } -static void set_gbColorCorrection(int value) -{ - gbColorOption = value; -} - static bool gb_hasrtc(void) { switch (gbRomType) { @@ -543,17 +544,23 @@ void retro_get_system_info(struct retro_system_info *info) void retro_get_system_av_info(struct retro_system_av_info *info) { - float aspect = (3.0f / 2.0f); - if (type == IMAGE_GB) - aspect = !gbBorderOn ? (10.0 / 9.0) : (8.0 / 7.0); + double aspect = (3.0f / 2.0f); + unsigned maxWidth = gbaWidth; + unsigned maxHeight = gbaHeight; - info->geometry.base_width = width; - info->geometry.base_height = height; - info->geometry.max_width = width; - info->geometry.max_height = height; + if (type == IMAGE_GB) { + aspect = !gbBorderOn ? (10.0 / 9.0) : (8.0 / 7.0); + maxWidth = sgbWidth; + maxHeight = sgbHeight; + } + + info->geometry.base_width = systemWidth; + info->geometry.base_height = systemHeight; + info->geometry.max_width = maxWidth; + info->geometry.max_height = maxHeight; info->geometry.aspect_ratio = aspect; - info->timing.fps = FramesPerSecond; - info->timing.sample_rate = (double)SampleRate; + info->timing.fps = FRAMERATE; + info->timing.sample_rate = SAMPLERATE; } void retro_init(void) @@ -572,10 +579,18 @@ void retro_init(void) snprintf(retro_system_directory, sizeof(retro_system_directory), "%s", dir); #ifdef FRONTEND_SUPPORTS_RGB565 + systemColorDepth = 16; + systemRedShift = 11; + systemGreenShift = 6; + systemBlueShift = 0; enum retro_pixel_format rgb565 = RETRO_PIXEL_FORMAT_RGB565; if (environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &rgb565) && log_cb) log_cb(RETRO_LOG_INFO, "Frontend supports RGB565 - will use that instead of XRGB1555.\n"); #else + systemColorDepth = 32; + systemRedShift = 19; + systemGreenShift = 11; + systemBlueShift = 3; enum retro_pixel_format rgb8888 = RETRO_PIXEL_FORMAT_XRGB8888; if (environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &rgb8888) && log_cb) log_cb(RETRO_LOG_INFO, "Frontend supports XRGB8888 - will use that instead of XRGB1555.\n"); @@ -588,7 +603,6 @@ void retro_init(void) rumble_cb = rumble.set_rumble_state; } else rumble_cb = NULL; - } static const char *gbGetCartridgeType(void) @@ -802,7 +816,7 @@ static void load_image_preferences(void) if (flashSize == SIZE_FLASH512 || flashSize == SIZE_FLASH1M) flashSetSize(flashSize); - if (opt_forceRTCenable) + if (option_forceRTCenable) rtcEnabled = true; rtcEnable(rtcEnabled); @@ -825,25 +839,6 @@ static void load_image_preferences(void) log("mirroringEnable : %s.\n", mirroringEnable ? "Yes" : "No"); } -static void update_colormaps(void) -{ -#ifdef FRONTEND_SUPPORTS_RGB565 - systemColorDepth = 16; - systemRedShift = 11; - systemGreenShift = 6; - systemBlueShift = 0; -#else - systemColorDepth = 32; - systemRedShift = 19; - systemGreenShift = 11; - systemBlueShift = 3; -#endif - - utilUpdateSystemColorMaps(false); - - log("Color Depth = %d\n", systemColorDepth); -} - #ifdef _WIN32 static const char SLASH = '\\'; #else @@ -855,16 +850,16 @@ static void gba_init(void) log("Loading VBA-M Core (GBA)...\n"); load_image_preferences(); - soundSetSampleRate(SampleRate); + soundSetSampleRate(SAMPLERATE); - if (usebios) { + if (option_useBios) { snprintf(biosfile, sizeof(biosfile), "%s%c%s", retro_system_directory, SLASH, "gba_bios.bin"); log("Loading bios: %s\n", biosfile); } - CPUInit(biosfile, usebios); + CPUInit(biosfile, option_useBios); - width = gbaWidth; - height = gbaHeight; + systemWidth = gbaWidth; + systemHeight = gbaHeight; CPUReset(); } @@ -877,32 +872,32 @@ static void gb_init(void) gbGetHardwareType(); - setColorizerHack(opt_colorizer_hack); + setColorizerHack(option_colorizerHack); // Disable bios loading when using Colorizer hack - if (opt_colorizer_hack) - usebios = false; + if (option_colorizerHack) + option_useBios = false; - if (usebios) { + if (option_useBios) { snprintf(biosfile, sizeof(biosfile), "%s%c%s", retro_system_directory, SLASH, biosname[gbCgbMode]); log("Loading bios: %s\n", biosfile); } - gbCPUInit(biosfile, usebios); + gbCPUInit(biosfile, option_useBios); if (gbBorderOn) { - width = gbBorderLineSkip = sgbWidth; - height = sgbHeight; + systemWidth = gbBorderLineSkip = sgbWidth; + systemHeight = sgbHeight; gbBorderColumnSkip = (sgbWidth - gbWidth) >> 1; gbBorderRowSkip = (sgbHeight - gbHeight) >> 1; } else { - width = gbBorderLineSkip = gbWidth; - height = gbHeight; + systemWidth = gbBorderLineSkip = gbWidth; + systemHeight = gbHeight; gbBorderColumnSkip = gbBorderRowSkip = 0; } - gbSoundSetSampleRate(SampleRate); + gbSoundSetSampleRate(SAMPLERATE); gbSoundSetDeclicking(1); gbReset(); // also resets sound; @@ -942,12 +937,6 @@ static void gb_init(void) log("Game supports SGB functions\n"); } -static void gba_soundchanged(void) -{ - soundInterpolation = sndInterpolation; - soundFiltering = sndFiltering; -} - void retro_deinit(void) { emulating = 0; @@ -964,8 +953,8 @@ void retro_reset(void) #define MAX_PLAYERS 4 #define MAX_BUTTONS 10 #define TURBO_BUTTONS 2 -static bool turbo_enable = false; -static unsigned turbo_delay = 3; +static bool option_turboEnable = false; +static unsigned option_turboDelay = 3; static unsigned turbo_delay_counter[MAX_PLAYERS][TURBO_BUTTONS] = {{0}, {0}}; static const unsigned binds[MAX_BUTTONS] = { RETRO_DEVICE_ID_JOYPAD_A, @@ -989,19 +978,19 @@ static void systemGbBorderOff(void); static void systemUpdateSolarSensor(int level); static uint8_t sensorDarkness = 0xE8; static uint8_t sensorDarknessLevel = 0; // so we can adjust sensor from gamepad -static int astick_deadzone; -static int gyro_sensitivity, tilt_sensitivity; -static bool swap_astick; +static int option_analogDeadzone; +static int option_gyroSensitivity, option_tiltSensitivity; +static bool option_swapAnalogSticks; static void update_variables(bool startup) { + struct retro_variable var = {0}; + char key[256] = {0}; + int disabled_layers = 0; + int sound_enabled = 0x30F; bool sound_changed = false; - char key[256]; - struct retro_variable var; + var.key = key; - - int disabled_layers=0; - strcpy(key, "vbam_layer_x"); for (int i = 0; i < 8; i++) { key[strlen("vbam_layer_")] = '1' + i; @@ -1014,7 +1003,6 @@ static void update_variables(bool startup) layerEnable = DISPCNT & layerSettings; CPUUpdateRenderBuffers(false); - int sound_enabled = 0x30F; strcpy(key, "vbam_sound_x"); for (unsigned i = 0; i < 6; i++) { key[strlen("vbam_sound_")] = '1' + i; @@ -1032,9 +1020,9 @@ static void update_variables(bool startup) var.value = NULL; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { - bool newval = (strcmp(var.value, "enabled") == 0); - if (sndInterpolation != newval) { - sndInterpolation = newval; + bool newval = (!strcmp(var.value, "enabled")); + if (option_sndInterpolation != newval) { + option_sndInterpolation = newval; sound_changed = true; } } @@ -1043,32 +1031,30 @@ static void update_variables(bool startup) var.value = NULL; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { - float newval = atof(var.value) * 0.1f; - if (sndFiltering != newval) { - sndFiltering = newval; + double newval = atof(var.value) * 0.1f; + if (option_sndFiltering != newval) { + option_sndFiltering = newval; sound_changed = true; } } if (sound_changed) { - //Update interpolation and filtering values - gba_soundchanged(); + soundInterpolation = option_sndInterpolation; + soundFiltering = option_sndFiltering; } var.key = "vbam_usebios"; var.value = NULL; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { - bool newval = (strcmp(var.value, "enabled") == 0); - usebios = newval; + option_useBios = (!strcmp(var.value, "enabled")) ? true : false; } var.key = "vbam_forceRTCenable"; var.value = NULL; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { - bool newval = (strcmp(var.value, "enabled") == 0) ? true : false; - opt_forceRTCenable = newval; + option_forceRTCenable = (!strcmp(var.value, "enabled")) ? true : false; } var.key = "vbam_solarsensor"; @@ -1088,11 +1074,10 @@ static void update_variables(bool startup) gbBorderOn = 0; gbBorderAutomatic = 1; } - else if (strcmp(var.value, "enabled") == 0) { + else if (!strcmp(var.value, "enabled")) { gbBorderAutomatic = 0; gbBorderOn = 1; - } - else { // disabled + } else { // disabled gbBorderOn = 0; gbBorderAutomatic = 0; } @@ -1102,8 +1087,7 @@ static void update_variables(bool startup) if (gbBorderOn) { systemGbBorderOn(); gbSgbRenderBorder(); - } - else + } else systemGbBorderOff(); } } @@ -1130,96 +1114,116 @@ static void update_variables(bool startup) var.value = NULL; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { - if (strcmp(var.value, "enabled") == 0) - opt_colorizer_hack = true; - else - opt_colorizer_hack = false; + option_colorizerHack = (!strcmp(var.value, "enabled")) ? true : false; } var.key = "vbam_turboenable"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - bool val = !strcmp(var.value, "enabled"); - turbo_enable = val; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + option_turboEnable = (!strcmp(var.value, "enabled")) ? true : false; } var.key = "vbam_turbodelay"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - turbo_delay = atoi(var.value); + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + option_turboDelay = atoi(var.value); } var.key = "vbam_astick_deadzone"; var.value = NULL; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - astick_deadzone = (int)(atoi(var.value) * 0.01f * 0x8000); + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + option_analogDeadzone = (int)(atof(var.value) * 0.01 * 0x8000); } var.key = "vbam_tilt_sensitivity"; var.value = NULL; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - tilt_sensitivity = atoi(var.value); + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + option_tiltSensitivity = atoi(var.value); } var.key = "vbam_gyro_sensitivity"; var.value = NULL; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - gyro_sensitivity = atoi(var.value); + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + option_gyroSensitivity = atoi(var.value); } var.key = "vbam_swap_astick"; var.value = NULL; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - swap_astick = (bool)(!strcmp(var.value, "enabled")); + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + option_swapAnalogSticks = (!strcmp(var.value, "enabled")) ? true : false; } var.key = "vbam_palettes"; var.value = NULL; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - unsigned lastpal = current_gbPalette; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + unsigned lastpal = option_gbPalette; if (!strcmp(var.value, "black and white")) - current_gbPalette = 0; + option_gbPalette = 0; else if (!strcmp(var.value, "blue sea")) - current_gbPalette = 1; + option_gbPalette = 1; else if (!strcmp(var.value, "dark knight")) - current_gbPalette = 2; + option_gbPalette = 2; else if (!strcmp(var.value, "green forest")) - current_gbPalette = 3; + option_gbPalette = 3; else if (!strcmp(var.value, "hot desert")) - current_gbPalette = 4; + option_gbPalette = 4; else if (!strcmp(var.value, "pink dreams")) - current_gbPalette = 5; + option_gbPalette = 5; else if (!strcmp(var.value, "wierd colors")) - current_gbPalette = 6; + option_gbPalette = 6; else if (!strcmp(var.value, "original gameboy")) - current_gbPalette = 7; + option_gbPalette = 7; else if (!strcmp(var.value, "gba sp")) - current_gbPalette = 8; + option_gbPalette = 8; - if (lastpal != current_gbPalette) + if (lastpal != option_gbPalette) set_gbPalette(); } var.key = "vbam_gbcoloroption"; var.value = NULL; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - int val = (!strcmp(var.value, "enabled")) ? 1 : 0; - set_gbColorCorrection(val); + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + gbColorOption = (!strcmp(var.value, "enabled")) ? 1 : 0; + } + + var.key = "vbam_show_advanced_options"; + var.value = NULL; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + bool newval = (!strcmp(var.value, "enabled")) ? true : false; + if ((option_showAdvancedOptions != newval) || startup) { + option_showAdvancedOptions = newval; + struct retro_core_option_display option_display; + unsigned i; + char options[][13] = { + "vbam_sound_1", + "vbam_sound_2", + "vbam_sound_3", + "vbam_sound_4", + "vbam_sound_5", + "vbam_sound_6", + "vbam_layer_1", + "vbam_layer_2", + "vbam_layer_3", + "vbam_layer_4", + "vbam_layer_5", + "vbam_layer_6", + "vbam_layer_7", + "vbam_layer_8" + }; + option_display.visible = option_showAdvancedOptions; + for (i = 0; i < (sizeof(options) / sizeof(options[0])); i++) { + option_display.key = options[i]; + environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display); + } + } } // Hide some core options depending on rom image type @@ -1233,10 +1237,8 @@ static void update_variables(bool startup) "vbam_showborders", "vbam_gbcoloroption" }; - char gba_options[5][22] = { + char gba_options[3][22] = { "vbam_solarsensor", - "vbam_sound_5", - "vbam_sound_6", "vbam_gyro_sensitivity", "vbam_forceRTCenable" }; @@ -1251,7 +1253,7 @@ static void update_variables(bool startup) // Show or hide GBA only options option_display.visible = (type == IMAGE_GBA) ? 1 : 0; - for (i = 0; i < 5; i++) + for (i = 0; i < 3; i++) { option_display.key = gba_options[i]; environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display); @@ -1271,9 +1273,9 @@ static void updateInput_MotionSensors(void) int16_t analog[3], astick_data[3]; double scaled_range, radius, angle; unsigned tilt_retro_device_index = - swap_astick ? RETRO_DEVICE_INDEX_ANALOG_LEFT : RETRO_DEVICE_INDEX_ANALOG_RIGHT; + option_swapAnalogSticks ? RETRO_DEVICE_INDEX_ANALOG_LEFT : RETRO_DEVICE_INDEX_ANALOG_RIGHT; unsigned gyro_retro_device_index = - swap_astick ? RETRO_DEVICE_INDEX_ANALOG_RIGHT : RETRO_DEVICE_INDEX_ANALOG_LEFT; + option_swapAnalogSticks ? RETRO_DEVICE_INDEX_ANALOG_RIGHT : RETRO_DEVICE_INDEX_ANALOG_LEFT; // Tilt sensor section analog[0] = input_cb(0, RETRO_DEVICE_ANALOG, @@ -1285,12 +1287,12 @@ static void updateInput_MotionSensors(void) radius = sqrt(analog[0] * analog[0] + analog[1] * analog[1]); angle = atan2(analog[1], analog[0]); - if (radius > astick_deadzone) { + if (radius > option_analogDeadzone) { // Re-scale analog stick range to negate deadzone (makes slow movements possible) - radius = (radius - astick_deadzone) * - ((float)ASTICK_MAX/(ASTICK_MAX - astick_deadzone)); + radius = (radius - option_analogDeadzone) * + ((float)ASTICK_MAX/(ASTICK_MAX - option_analogDeadzone)); // Tilt sensor range is from from 1897 to 2197 - radius *= 150.0 / ASTICK_MAX * (tilt_sensitivity / 100.0); + radius *= 150.0 / ASTICK_MAX * (option_tiltSensitivity / 100.0); // Convert back to cartesian coordinates astick_data[0] = +(int16_t)ROUND(radius * cos(angle)); astick_data[1] = -(int16_t)ROUND(radius * sin(angle)); @@ -1304,17 +1306,17 @@ static void updateInput_MotionSensors(void) analog[2] = input_cb(0, RETRO_DEVICE_ANALOG, gyro_retro_device_index, RETRO_DEVICE_ID_ANALOG_X); - if ( analog[2] < -astick_deadzone ) { + if ( analog[2] < -option_analogDeadzone ) { // Re-scale analog stick range - scaled_range = (-analog[2] - astick_deadzone) * - ((float)ASTICK_MAX / (ASTICK_MAX - astick_deadzone)); + scaled_range = (-analog[2] - option_analogDeadzone) * + ((float)ASTICK_MAX / (ASTICK_MAX - option_analogDeadzone)); // Gyro sensor range is +/- 1800 - scaled_range *= 1800.0 / ASTICK_MAX * (gyro_sensitivity / 100.0); + scaled_range *= 1800.0 / ASTICK_MAX * (option_gyroSensitivity / 100.0); astick_data[2] = -(int16_t)ROUND(scaled_range); - } else if ( analog[2] > astick_deadzone ) { - scaled_range = (analog[2] - astick_deadzone) * - ((float)ASTICK_MAX / (ASTICK_MAX - astick_deadzone)); - scaled_range *= (1800.0 / ASTICK_MAX * (gyro_sensitivity / 100.0)); + } else if ( analog[2] > option_analogDeadzone ) { + scaled_range = (analog[2] - option_analogDeadzone) * + ((float)ASTICK_MAX / (ASTICK_MAX - option_analogDeadzone)); + scaled_range *= (1800.0 / ASTICK_MAX * (option_gyroSensitivity / 100.0)); astick_data[2] = +(int16_t)ROUND(scaled_range); } else astick_data[2] = 0; @@ -1496,7 +1498,7 @@ bool retro_load_game(const struct retro_game_info *game) } update_variables(true); - update_colormaps(); + utilUpdateSystemColorMaps(false); soundInit(); if (type == IMAGE_GBA) { @@ -1654,8 +1656,8 @@ bool systemCanChangeSoundQuality(void) void systemDrawScreen(void) { - unsigned pitch = width * (systemColorDepth >> 3); - video_cb(pix, width, height, pitch); + unsigned pitch = systemWidth * (systemColorDepth >> 3); + video_cb(pix, systemWidth, systemHeight, pitch); } void systemFrame(void) @@ -1665,9 +1667,9 @@ void systemFrame(void) void systemGbBorderOn(void) { - bool changed = ((width != sgbWidth) || (height != sgbHeight)); - width = gbBorderLineSkip = sgbWidth; - height = sgbHeight; + bool changed = ((systemWidth != sgbWidth) || (systemHeight != sgbHeight)); + systemWidth = gbBorderLineSkip = sgbWidth; + systemHeight = sgbHeight; gbBorderColumnSkip = (sgbWidth - gbWidth) >> 1; gbBorderRowSkip = (sgbHeight - gbHeight) >> 1; @@ -1682,9 +1684,9 @@ void systemGbBorderOn(void) static void systemGbBorderOff(void) { - bool changed = ((width != gbWidth) || (height != gbHeight)); - width = gbBorderLineSkip = gbWidth; - height = gbHeight; + bool changed = ((systemWidth != gbWidth) || (systemHeight != gbHeight)); + systemWidth = gbBorderLineSkip = gbWidth; + systemHeight = gbHeight; gbBorderColumnSkip = gbBorderRowSkip = 0; struct retro_system_av_info avinfo; @@ -1730,14 +1732,14 @@ uint32_t systemReadJoypad(int which) for (i = 0; i < buttons; i++) J |= input_cb(which, RETRO_DEVICE_JOYPAD, 0, binds[i]) << i; - if (turbo_enable) { + if (option_turboEnable) { /* Handle Turbo A & B buttons */ for (i = 0; i < TURBO_BUTTONS; i++) { if (input_cb(which, RETRO_DEVICE_JOYPAD, 0, turbo_binds[i])) { if (!turbo_delay_counter[which][i]) J |= 1 << i; turbo_delay_counter[which][i]++; - if (turbo_delay_counter[which][i] > turbo_delay) + if (turbo_delay_counter[which][i] > option_turboDelay) /* Reset the toggle if delay value is reached */ turbo_delay_counter[which][i] = 0; } else diff --git a/src/libretro/libretro_core_options.h b/src/libretro/libretro_core_options.h index 20b5c424..47b13b85 100644 --- a/src/libretro/libretro_core_options.h +++ b/src/libretro/libretro_core_options.h @@ -29,7 +29,7 @@ extern "C" { struct retro_core_option_definition option_defs_us[] = { { "vbam_solarsensor", - "Solar sensor level", + "Solar Sensor Level", "Adjusts simulated solar level in Boktai games. L2/R2 buttons can also be used to quickly change levels.", { { "0", NULL }, @@ -49,7 +49,7 @@ struct retro_core_option_definition option_defs_us[] = { }, { "vbam_usebios", - "Use BIOS file if available (Restart)", + "Use Official BIOS (If Available)", "Use official BIOS when available. Core needs to be restarted for changes to apply.", { { "disabled", NULL }, @@ -60,7 +60,7 @@ struct retro_core_option_definition option_defs_us[] = { }, { "vbam_forceRTCenable", - "Force enable RTC", + "Force-Enable RTC", "Forces the internal real-time clock to be enabled regardless of rom. Usuable for rom patches that requires clock to be enabled (aka Pokemon).", { { "disabled", NULL }, @@ -103,7 +103,7 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_palettes", "(GB) Color Palette", - "Set Game Boy palettes.", + "Set Game Boy palettes to use.", { { "black and white", NULL }, { "blue sea", NULL }, @@ -120,7 +120,7 @@ struct retro_core_option_definition option_defs_us[] = { }, { "vbam_gbHardware", - "(GB) Emulated Hardware", + "(GB) Emulated Hardware (Needs Restart)", "Sets the Game Boy hardware type to emulate. Restart core to apply.", { { "gbc", "Game Boy Color" }, @@ -293,9 +293,20 @@ struct retro_core_option_definition option_defs_us[] = { }, "disabled" }, + { + "vbam_show_advanced_options", + "Show Advanced Options", + "Show advanced options which can enable or disable sound channels and graphics layers.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "disabled" + }, { "vbam_sound_1", - "Sound channel 1", + "Sound Channel 1", "Enables or disables tone & sweep sound channel.", { { "disabled", NULL }, @@ -304,9 +315,9 @@ struct retro_core_option_definition option_defs_us[] = { }, "enabled" }, -{ + { "vbam_sound_2", - "Sound channel 2", + "Sound Channel 2", "Enables or disables tone sound channel.", { { "disabled", NULL }, @@ -317,7 +328,7 @@ struct retro_core_option_definition option_defs_us[] = { }, { "vbam_sound_3", - "Sound channel 3", + "Sound Channel 3", "Enables or disables wave output sound channel.", { { "disabled", NULL }, @@ -328,7 +339,7 @@ struct retro_core_option_definition option_defs_us[] = { }, { "vbam_sound_4", - "Sound channel 4", + "Sound Channel 4", "Enables or disables noise audio channel.", { { "disabled", NULL }, @@ -339,7 +350,7 @@ struct retro_core_option_definition option_defs_us[] = { }, { "vbam_sound_5", - "Sound DMA channel A", + "Sound DMA Channel A", "Enables or disables DMA sound channel A.", { { "disabled", NULL }, @@ -350,7 +361,7 @@ struct retro_core_option_definition option_defs_us[] = { }, { "vbam_sound_6", - "Sound DMA channel B", + "Sound DMA Channel B", "Enables or disables DMA sound channel B.", { { "disabled", NULL }, @@ -361,7 +372,7 @@ struct retro_core_option_definition option_defs_us[] = { }, { "vbam_layer_1", - "Show background layer 1", + "Show Background Layer 1", "Shows or hides background layer 1.", { { "disabled", NULL }, @@ -372,7 +383,7 @@ struct retro_core_option_definition option_defs_us[] = { }, { "vbam_layer_2", - "Show background layer 2", + "Show Background Layer 2", "Shows or hides background layer 2.", { { "disabled", NULL }, @@ -383,7 +394,7 @@ struct retro_core_option_definition option_defs_us[] = { }, { "vbam_layer_3", - "Show background layer 3", + "Show Background Layer 3", "Shows or hides background layer 3.", { { "disabled", NULL }, @@ -394,7 +405,7 @@ struct retro_core_option_definition option_defs_us[] = { }, { "vbam_layer_4", - "Show background layer 4", + "Show Background Layer 4", "Shows or hides background layer 4.", { { "disabled", NULL }, @@ -405,7 +416,7 @@ struct retro_core_option_definition option_defs_us[] = { }, { "vbam_layer_5", - "Show sprite layer", + "Show Sprite Layer", "Shows or hides sprite layer.", { { "disabled", NULL }, @@ -416,7 +427,7 @@ struct retro_core_option_definition option_defs_us[] = { }, { "vbam_layer_6", - "Show window layer 1", + "Show Window Layer 1", "Shows or hides window layer 1.", { { "disabled", NULL }, @@ -427,7 +438,7 @@ struct retro_core_option_definition option_defs_us[] = { }, { "vbam_layer_7", - "Show window layer 2", + "Show Window Layer 2", "Shows or hides window layer 2.", { { "disabled", NULL }, @@ -438,7 +449,7 @@ struct retro_core_option_definition option_defs_us[] = { }, { "vbam_layer_8", - "Show sprite window layer", + "Show Sprite Window Layer", "Shows or hides sprite window layer.", { { "disabled", NULL }, From b3744b3bd5b534615587453ad744a54b5c0029d7 Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Sat, 10 Aug 2019 00:00:45 +0800 Subject: [PATCH 07/13] Simplify GB border core option --- src/libretro/libretro.cpp | 74 ++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 40 deletions(-) diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index 382c4d07..8360e454 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -312,6 +312,35 @@ static void gbUpdateRTC(void) } } +static void SetGBBorder(unsigned val) +{ + struct retro_system_av_info avinfo; + unsigned _changed = 0; + + switch (val) { + case 0: + _changed = ((systemWidth != gbWidth) || (systemHeight != gbHeight)) ? 1 : 0; + systemWidth = gbBorderLineSkip = gbWidth; + systemHeight = gbHeight; + gbBorderColumnSkip = gbBorderRowSkip = 0; + break; + case 1: + _changed = ((systemWidth != sgbWidth) || (systemHeight != sgbHeight)) ? 1 : 0; + systemWidth = gbBorderLineSkip = sgbWidth; + systemHeight = sgbHeight; + gbBorderColumnSkip = (sgbWidth - gbWidth) >> 1; + gbBorderRowSkip = (sgbHeight - gbHeight) >> 1; + break; + } + + retro_get_system_av_info(&avinfo); + + if (!_changed) + environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &avinfo); + else + environ_cb(RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO, &avinfo); +} + void* retro_get_memory_data(unsigned id) { if (type == IMAGE_GBA) { @@ -974,7 +1003,6 @@ static const unsigned turbo_binds[TURBO_BUTTONS] = { RETRO_DEVICE_ID_JOYPAD_Y }; -static void systemGbBorderOff(void); static void systemUpdateSolarSensor(int level); static uint8_t sensorDarkness = 0xE8; static uint8_t sensorDarknessLevel = 0; // so we can adjust sensor from gamepad @@ -1069,9 +1097,7 @@ static void update_variables(bool startup) var.value = NULL; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { - int oldval = (gbBorderOn << 1) | gbBorderAutomatic; if (strcmp(var.value, "auto") == 0) { - gbBorderOn = 0; gbBorderAutomatic = 1; } else if (!strcmp(var.value, "enabled")) { @@ -1082,14 +1108,8 @@ static void update_variables(bool startup) gbBorderAutomatic = 0; } - if ((type == IMAGE_GB) && - (oldval != ((gbBorderOn << 1) | gbBorderAutomatic)) && !startup) { - if (gbBorderOn) { - systemGbBorderOn(); - gbSgbRenderBorder(); - } else - systemGbBorderOff(); - } + if ((type == IMAGE_GB) && !startup) + SetGBBorder(gbBorderOn); } var.key = "vbam_gbHardware"; @@ -1641,6 +1661,8 @@ unsigned retro_get_region(void) return RETRO_REGION_NTSC; } +// system callbacks + void systemOnWriteDataToSoundBuffer(const uint16_t*, int) { } @@ -1667,35 +1689,7 @@ void systemFrame(void) void systemGbBorderOn(void) { - bool changed = ((systemWidth != sgbWidth) || (systemHeight != sgbHeight)); - systemWidth = gbBorderLineSkip = sgbWidth; - systemHeight = sgbHeight; - gbBorderColumnSkip = (sgbWidth - gbWidth) >> 1; - gbBorderRowSkip = (sgbHeight - gbHeight) >> 1; - - struct retro_system_av_info avinfo; - retro_get_system_av_info(&avinfo); - - if (!changed) - environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &avinfo); - else - environ_cb(RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO, &avinfo); -} - -static void systemGbBorderOff(void) -{ - bool changed = ((systemWidth != gbWidth) || (systemHeight != gbHeight)); - systemWidth = gbBorderLineSkip = gbWidth; - systemHeight = gbHeight; - gbBorderColumnSkip = gbBorderRowSkip = 0; - - struct retro_system_av_info avinfo; - retro_get_system_av_info(&avinfo); - - if (!changed) - environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &avinfo); - else - environ_cb(RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO, &avinfo); + SetGBBorder(1); } void systemMessage(const char* fmt, ...) From 03184dd513da500e05def393efdbfc7f2f1ec7a7 Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Sat, 10 Aug 2019 18:24:32 +0800 Subject: [PATCH 08/13] libretro: Use GB RTC data when available - Save GB RTC data using retro_get_memory/size and only init using localtime when its unavailable (check is done in retro_run) --- src/gb/GB.cpp | 21 +++- src/gb/gb.h | 1 + src/libretro/libretro.cpp | 238 ++++++++++++++++++++------------------ 3 files changed, 148 insertions(+), 112 deletions(-) diff --git a/src/gb/GB.cpp b/src/gb/GB.cpp index d2da5abc..462e69e5 100644 --- a/src/gb/GB.cpp +++ b/src/gb/GB.cpp @@ -195,6 +195,7 @@ int gbSynchronizeTicks = GBSYNCHRONIZE_CLOCK_TICKS; // emulator features int gbBattery = 0; int gbRumble = 0; +int gbRTCPresent = 0; bool gbBatteryError = false; int gbCaptureNumber = 0; bool gbCapture = false; @@ -4360,8 +4361,6 @@ bool gbUpdateSizes() memset(gbRam, gbRamFill, gbRamSize); } - gbBattery = gbRumble = 0; - switch (gbRomType) { case 0x03: case 0x06: @@ -4377,6 +4376,9 @@ bool gbUpdateSizes() case 0xff: gbBattery = 1; break; + default: + gbBattery = 0; + break; } switch (gbRomType) { @@ -4384,6 +4386,21 @@ bool gbUpdateSizes() case 0x1d: case 0x1e: gbRumble = 1; + break; + default: + gbRumble = 0; + break; + } + + switch (gbRomType) { + case 0x0f: + case 0x10: // mbc3 + case 0xfd: // tama5 + gbRTCPresent = 1; + break; + default: + gbRTCPresent = 0; + break; } gbInit(); diff --git a/src/gb/gb.h b/src/gb/gb.h index 4ef81090..0f7c013f 100644 --- a/src/gb/gb.h +++ b/src/gb/gb.h @@ -62,6 +62,7 @@ bool allowColorizerHack(void); extern int gbHardware; extern int gbRomType; // gets type from header 0x147 extern int gbBattery; // enabled when gbRamSize != 0 +extern int gbRTCPresent; // gbROM has RTC support extern struct EmulatedSystem GBSystem; diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index 8360e454..80d969b3 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -216,99 +216,76 @@ static void set_gbPalette(void) } } -static bool gb_hasrtc(void) +static void* gb_rtcdata_prt(void) { switch (gbRomType) { case 0x0f: case 0x10: // MBC3 + extended - case 0x13: + return &gbDataMBC3.mapperSeconds; case 0xfd: // TAMA5 + extended - return true; - } - return false; -} - -static void* gb_rtcdata_prt(void) -{ - if (gb_hasrtc()) { - switch (gbRomType) { - case 0x0f: - case 0x10: // MBC3 + extended - return &gbDataMBC3.mapperSeconds; - case 0x13: - case 0xfd: // TAMA5 + extended - return &gbDataTAMA5.mapperSeconds; - } + return &gbDataTAMA5.mapperSeconds; } return NULL; } static size_t gb_rtcdata_size(void) { - if (gb_hasrtc()) { - switch (gbRomType) { - case 0x0f: - case 0x10: // MBC3 + extended - return MBC3_RTC_DATA_SIZE; - break; - case 0x13: - case 0xfd: // TAMA5 + extended - return TAMA5_RTC_DATA_SIZE; - break; - } + switch (gbRomType) { + case 0x0f: + case 0x10: // MBC3 + extended + return MBC3_RTC_DATA_SIZE; + case 0xfd: // TAMA5 + extended + return TAMA5_RTC_DATA_SIZE; } return 0; } -static void gbUpdateRTC(void) +static void gbInitRTC(void) { - if (gb_hasrtc()) { - struct tm* lt; - time_t rawtime; - time(&rawtime); - lt = localtime(&rawtime); + struct tm* lt; + time_t rawtime; + time(&rawtime); + lt = localtime(&rawtime); - switch (gbRomType) { - case 0x0f: - case 0x10: { - gbDataMBC3.mapperSeconds = lt->tm_sec; - gbDataMBC3.mapperMinutes = lt->tm_min; - gbDataMBC3.mapperHours = lt->tm_hour; - gbDataMBC3.mapperDays = lt->tm_yday & 255; - gbDataMBC3.mapperControl = (gbDataMBC3.mapperControl & 0xfe) | (lt->tm_yday > 255 ? 1 : 0); - gbDataMBC3.mapperLastTime = rawtime; - } - break; - case 0xfd: { - uint8_t gbDaysinMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - gbDataTAMA5.mapperSeconds = lt->tm_sec; - gbDataTAMA5.mapperMinutes = lt->tm_min; - gbDataTAMA5.mapperHours = lt->tm_hour; - gbDataTAMA5.mapperDays = 1; - gbDataTAMA5.mapperMonths = 1; - gbDataTAMA5.mapperYears = 1970; - gbDataTAMA5.mapperLastTime = rawtime; - int days = lt->tm_yday + 365 * 3; - while (days) { - gbDataTAMA5.mapperDays++; - days--; - if (gbDataTAMA5.mapperDays > gbDaysinMonth[gbDataTAMA5.mapperMonths - 1]) { - gbDataTAMA5.mapperDays = 1; - gbDataTAMA5.mapperMonths++; - if (gbDataTAMA5.mapperMonths > 12) { - gbDataTAMA5.mapperMonths = 1; - gbDataTAMA5.mapperYears++; - if ((gbDataTAMA5.mapperYears & 3) == 0) - gbDaysinMonth[1] = 29; - else - gbDaysinMonth[1] = 28; - } + switch (gbRomType) { + case 0x0f: + case 0x10: + gbDataMBC3.mapperSeconds = lt->tm_sec; + gbDataMBC3.mapperMinutes = lt->tm_min; + gbDataMBC3.mapperHours = lt->tm_hour; + gbDataMBC3.mapperDays = lt->tm_yday & 255; + gbDataMBC3.mapperControl = (gbDataMBC3.mapperControl & 0xfe) | (lt->tm_yday > 255 ? 1 : 0); + gbDataMBC3.mapperLastTime = rawtime; + break; + case 0xfd: { + uint8_t gbDaysinMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + int days = lt->tm_yday + 365 * 3; + gbDataTAMA5.mapperSeconds = lt->tm_sec; + gbDataTAMA5.mapperMinutes = lt->tm_min; + gbDataTAMA5.mapperHours = lt->tm_hour; + gbDataTAMA5.mapperDays = 1; + gbDataTAMA5.mapperMonths = 1; + gbDataTAMA5.mapperYears = 1970; + gbDataTAMA5.mapperLastTime = rawtime; + while (days) { + gbDataTAMA5.mapperDays++; + days--; + if (gbDataTAMA5.mapperDays > gbDaysinMonth[gbDataTAMA5.mapperMonths - 1]) { + gbDataTAMA5.mapperDays = 1; + gbDataTAMA5.mapperMonths++; + if (gbDataTAMA5.mapperMonths > 12) { + gbDataTAMA5.mapperMonths = 1; + gbDataTAMA5.mapperYears++; + if ((gbDataTAMA5.mapperYears & 3) == 0) + gbDaysinMonth[1] = 29; + else + gbDaysinMonth[1] = 28; } } - gbDataTAMA5.mapperControl = (gbDataTAMA5.mapperControl & 0xfe) | (lt->tm_yday > 255 ? 1 : 0); } - break; + gbDataTAMA5.mapperControl = (gbDataTAMA5.mapperControl & 0xfe) | (lt->tm_yday > 255 ? 1 : 0); } + break; } } @@ -343,70 +320,91 @@ static void SetGBBorder(unsigned val) void* retro_get_memory_data(unsigned id) { - if (type == IMAGE_GBA) { + void *data = NULL; + + switch (type) { + case IMAGE_GBA: switch (id) { case RETRO_MEMORY_SAVE_RAM: if ((saveType == GBA_SAVE_EEPROM) | (saveType == GBA_SAVE_EEPROM_SENSOR)) - return eepromData; - if ((saveType == GBA_SAVE_SRAM) | (saveType == GBA_SAVE_FLASH)) - return flashSaveMemory; - return NULL; + data = eepromData; + else if ((saveType == GBA_SAVE_SRAM) | (saveType == GBA_SAVE_FLASH)) + data = flashSaveMemory; + break; case RETRO_MEMORY_SYSTEM_RAM: - return workRAM; + data = workRAM; + break; case RETRO_MEMORY_VIDEO_RAM: - return vram; + data = vram; + break; } - } - if (type == IMAGE_GB) { + case IMAGE_GB: switch (id) { case RETRO_MEMORY_SAVE_RAM: if (gbBattery) - return gbRam; - return NULL; + data = gbRam; + break; case RETRO_MEMORY_SYSTEM_RAM: - return (gbCgbMode ? gbWram : (gbMemory + 0xC000)); + data = (gbCgbMode ? gbWram : (gbMemory + 0xC000)); + break; case RETRO_MEMORY_VIDEO_RAM: - return (gbCgbMode ? gbVram : (gbMemory + 0x8000)); + data = (gbCgbMode ? gbVram : (gbMemory + 0x8000)); + break; + case RETRO_MEMORY_RTC: + if (gbBattery && gbRTCPresent) + data = gb_rtcdata_prt(); + break; } - } - return NULL; + default: break; + } + return data; } size_t retro_get_memory_size(unsigned id) { - if (type == IMAGE_GBA) { + size_t size = 0; + + switch (type) { + case IMAGE_GBA: switch (id) { case RETRO_MEMORY_SAVE_RAM: if ((saveType == GBA_SAVE_EEPROM) | (saveType == GBA_SAVE_EEPROM_SENSOR)) - return eepromSize; - if (saveType == GBA_SAVE_FLASH) - return flashSize; - if (saveType == GBA_SAVE_SRAM) - return SIZE_SRAM; - return 0; + size = eepromSize; + else if (saveType == GBA_SAVE_FLASH) + size = flashSize; + else if (saveType == GBA_SAVE_SRAM) + size = SIZE_SRAM; + break; case RETRO_MEMORY_SYSTEM_RAM: - return SIZE_WRAM; + size = SIZE_WRAM; + break; case RETRO_MEMORY_VIDEO_RAM: - return SIZE_VRAM - 0x2000; // usuable vram is only 0x18000 + size = SIZE_VRAM - 0x2000; // usuable vram is only 0x18000 + break; } - } - if (type == IMAGE_GB) { + case IMAGE_GB: switch (id) { case RETRO_MEMORY_SAVE_RAM: if (gbBattery) - return gbRamSize; - return 0; + size = gbRamSize; + break; case RETRO_MEMORY_SYSTEM_RAM: - return gbCgbMode ? 0x8000 : 0x2000; + size = gbCgbMode ? 0x8000 : 0x2000; + break; case RETRO_MEMORY_VIDEO_RAM: - return gbCgbMode ? 0x4000 : 0x2000; + size = gbCgbMode ? 0x4000 : 0x2000; + break; + case RETRO_MEMORY_RTC: + size = gb_rtcdata_size(); + break; } - } - return 0; + default: break; + } + return size; } unsigned retro_api_version(void) @@ -932,10 +930,6 @@ static void gb_init(void) gbReset(); // also resets sound; set_gbPalette(); - // VBA-M always updates time based on current time and not in-game time. - // No need to add RTC data to RETRO_MEMORY_RTC, so its safe to place this here. - gbUpdateRTC(); - log("Rom size : %02x (%dK)\n", gbRom[0x148], (romSize + 1023) / 1024); log("Cartridge type : %02x (%s)\n", gbRom[0x147], gbGetCartridgeType()); log("Ram size : %02x (%s)\n", gbRom[0x149], gbGetSaveRamSize()); @@ -1368,12 +1362,37 @@ void updateInput_SolarSensor(void) } } +static bool firstrun = true; static unsigned has_frame; void retro_run(void) { bool updated = false; + if (firstrun) { + bool initRTC = false; + firstrun = false; + /* Check if GB game has RTC data. Has to be check here since this is where the data will be + * available when using libretro api. */ + if ((type == IMAGE_GB) && gbRTCPresent) { + switch (gbRomType) { + case 0x0f: + case 0x10: + /* Check if any RTC has been loaded, zero value means nothing has been loaded. */ + if (!gbDataMBC3.mapperSeconds && !gbDataMBC3.mapperLSeconds && !gbDataMBC3.mapperLastTime) + initRTC = true; + break; + case 0xfd: + if (!gbDataTAMA5.mapperSeconds && !gbDataTAMA5.mapperLSeconds && !gbDataTAMA5.mapperLastTime) + initRTC = true; + break; + } + /* Initialize RTC using local time if needed */ + if (initRTC) + gbInitRTC(); + } + } + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) update_variables(false); @@ -1384,9 +1403,8 @@ void retro_run(void) has_frame = 0; - do { + while (!has_frame) core->emuMain(core->emuCount); - } while (!has_frame); } static unsigned serialize_size = 0; From 82e723a52820945fc1dc318616f2e2c04128f827 Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Sat, 10 Aug 2019 19:01:10 +0800 Subject: [PATCH 09/13] MBC3: Update mapper to check if RTC is present before running RTC functions --- src/gb/gbMemory.cpp | 62 +++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/src/gb/gbMemory.cpp b/src/gb/gbMemory.cpp index c4cba5b3..b2ac740c 100644 --- a/src/gb/gbMemory.cpp +++ b/src/gb/gbMemory.cpp @@ -389,7 +389,7 @@ void mapperMBC3ROM(uint16_t address, uint8_t value) gbDataMBC3.mapperRAMBank = value; gbDataMBC3.mapperRAMAddress = tmpAddress; } else { - if (gbDataMBC3.mapperRAMEnable) { + if (gbRTCPresent && gbDataMBC3.mapperRAMEnable) { gbDataMBC3.mapperRAMBank = -1; gbDataMBC3.mapperClockRegister = value; @@ -397,16 +397,18 @@ void mapperMBC3ROM(uint16_t address, uint8_t value) } break; case 0x6000: // clock latch - if (gbDataMBC3.mapperClockLatch == 0 && value == 1) { - memoryUpdateMBC3Clock(); - gbDataMBC3.mapperLSeconds = gbDataMBC3.mapperSeconds; - gbDataMBC3.mapperLMinutes = gbDataMBC3.mapperMinutes; - gbDataMBC3.mapperLHours = gbDataMBC3.mapperHours; - gbDataMBC3.mapperLDays = gbDataMBC3.mapperDays; - gbDataMBC3.mapperLControl = gbDataMBC3.mapperControl; + if (gbRTCPresent) { + if (gbDataMBC3.mapperClockLatch == 0 && value == 1) { + memoryUpdateMBC3Clock(); + gbDataMBC3.mapperLSeconds = gbDataMBC3.mapperSeconds; + gbDataMBC3.mapperLMinutes = gbDataMBC3.mapperMinutes; + gbDataMBC3.mapperLHours = gbDataMBC3.mapperHours; + gbDataMBC3.mapperLDays = gbDataMBC3.mapperDays; + gbDataMBC3.mapperLControl = gbDataMBC3.mapperControl; + } + if (value == 0x00 || value == 0x01) + gbDataMBC3.mapperClockLatch = value; } - if (value == 0x00 || value == 0x01) - gbDataMBC3.mapperClockLatch = value; break; } } @@ -415,12 +417,12 @@ void mapperMBC3ROM(uint16_t address, uint8_t value) void mapperMBC3RAM(uint16_t address, uint8_t value) { if (gbDataMBC3.mapperRAMEnable) { - if (gbDataMBC3.mapperRAMBank != -1) { + if (gbDataMBC3.mapperRAMBank >= 0) { if (gbRamSize) { gbMemoryMap[address >> 12][address & 0x0fff] = value; systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; } - } else { + } else if (gbRTCPresent) { time(&gbDataMBC3.mapperLastTime); switch (gbDataMBC3.mapperClockRegister) { case 0x08: @@ -450,25 +452,25 @@ void mapperMBC3RAM(uint16_t address, uint8_t value) uint8_t mapperMBC3ReadRAM(uint16_t address) { if (gbDataMBC3.mapperRAMEnable) { - if (gbDataMBC3.mapperRAMBank != -1) { + if (gbDataMBC3.mapperRAMBank >= 0) { return gbMemoryMap[address >> 12][address & 0x0fff]; - } - - switch (gbDataMBC3.mapperClockRegister) { - case 0x08: - return gbDataMBC3.mapperLSeconds; - break; - case 0x09: - return gbDataMBC3.mapperLMinutes; - break; - case 0x0a: - return gbDataMBC3.mapperLHours; - break; - case 0x0b: - return gbDataMBC3.mapperLDays; - break; - case 0x0c: - return gbDataMBC3.mapperLControl; + } else if (gbRTCPresent) { + switch (gbDataMBC3.mapperClockRegister) { + case 0x08: + return gbDataMBC3.mapperLSeconds; + break; + case 0x09: + return gbDataMBC3.mapperLMinutes; + break; + case 0x0a: + return gbDataMBC3.mapperLHours; + break; + case 0x0b: + return gbDataMBC3.mapperLDays; + break; + case 0x0c: + return gbDataMBC3.mapperLControl; + } } } From ad43b32bdd9b52f9fd817ab2e1bb79d6abe1b222 Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Mon, 12 Aug 2019 21:56:10 +0800 Subject: [PATCH 10/13] Fix "index out of bounds" runtime error --- src/libretro/libretro.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index 80d969b3..719310a7 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -780,7 +780,7 @@ static void load_image_preferences(void) bool found = false; bool hasRumble = false; - char buffer[12]; + char buffer[12 + 1]; unsigned i = 0, found_no = 0; unsigned long romCrc32 = crc32(0, rom, romSize); From 6c60ac334b283678c3753ad5dd430db004259b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mercan=20K=C3=B6m=C3=BCr?= Date: Tue, 13 Aug 2019 08:50:56 +0300 Subject: [PATCH 11/13] Turkish Language option --- src/libretro/libretro_core_options.h | 438 ++++++++++++++++++++++++++- 1 file changed, 437 insertions(+), 1 deletion(-) diff --git a/src/libretro/libretro_core_options.h b/src/libretro/libretro_core_options.h index 47b13b85..175226a5 100644 --- a/src/libretro/libretro_core_options.h +++ b/src/libretro/libretro_core_options.h @@ -498,6 +498,442 @@ struct retro_core_option_definition option_defs_us[] = { /* RETRO_LANGUAGE_TURKISH */ +struct retro_core_option_definition option_defs_tr[] = { + { + "vbam_solarsensor", + "Solar Sensör Seviyesi", + "Boktai oyunlarında simüle güneş seviyesini ayarlar. L2 / R2 düğmeleri ayrıca seviyeleri hızlıca değiştirmek için de kullanılabilir.", + { + { "0", NULL }, + { "1", NULL }, + { "2", NULL }, + { "3", NULL }, + { "4", NULL }, + { "5", NULL }, + { "6", NULL }, + { "7", NULL }, + { "8", NULL }, + { "9", NULL }, + { "10", NULL }, + { NULL, NULL }, + }, + "0" + }, + { + "vbam_usebios", + "Resmi BIOS'u kullanın (Varsa)", + "Mümkün olduğunda resmi BIOS kullanın. Değişikliklerin uygulanabilmesi için çekirdeğin yeniden başlatılması gerekiyor.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "vbam_forceRTCenable", + "RTC'yi Etkinleştir", + "RAM'den bağımsız olarak dahili gerçek zamanlı saati etkinleştirmeye zorlar. Saatin etkinleştirilmesini gerektiren rom yamalar için kullanılabilir (Pokemon gibi).", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "vbam_soundinterpolation", + "Ses Enterpolasyonu", + "Ses filtresini etkinleştirin veya devre dışı bırakın.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "enabled" + }, + { + "vbam_soundfiltering", + "Ses Filtreleme", + "Kullanılacak filtreleme miktarını ayarlar. Yüksek değer, yüksek frekansları azaltır.", + { + { "0", NULL }, + { "1", NULL }, + { "2", NULL }, + { "3", NULL }, + { "4", NULL }, + { "5", NULL }, + { "6", NULL }, + { "7", NULL }, + { "8", NULL }, + { "9", NULL }, + { "10", NULL }, + { NULL, NULL }, + }, + "5" + }, + { + "vbam_palettes", + "(GB) Renk Paleti", + "Game Boy paletlerini kullanmak için ayarlayın.", + { + { "black and white", NULL }, + { "blue sea", NULL }, + { "dark knight", NULL }, + { "green forest", NULL }, + { "hot desert", NULL }, + { "pink dreams", NULL }, + { "wierd colors", NULL }, + { "original gameboy", NULL }, + { "gba sp", NULL }, + { NULL, NULL }, + }, + "standard" + }, + { + "vbam_gbHardware", + "(GB) Öykünülmüş Donanım (Yeniden Başlatılması Gerekiyor)", + "Game Boy donanım tipini taklit edecek şekilde ayarlar. Uygulamak için çekirdeği yeniden başlatın.", + { + { "gbc", "Game Boy Color" }, + { "auto", "Automatic" }, + { "sgb", "Super Game Boy" }, + { "gb", "Game Boy" }, + { "gba", "Game Boy Advance" }, + { "sgb2", "Super Game Boy 2" }, + { NULL, NULL }, + }, + "gbc" + }, + { + "vbam_allowcolorizerhack", + "(GB) Colorizer Hack'i Etkinleştir (Yeniden Başlatılması Gerekiyor)", + "Colorizer'ın saldırıya uğramış GB oyunlarının (örn. DX yamalı oyunlar) normalde GBC / GBA donanım türünde çalışmasına izin verir. Bu ayrıca bios dosyasının kullanımını da devre dışı bırakır. Renklendirilmemiş oyunlarda kullanılması tavsiye edilmez.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "vbam_showborders", + "(GB) Sınırları Göster", + "Etkinleştirildiğinde, yüklü içerik SGB uyumluysa, bu durum oyundaki sınırı gösterir.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { "auto", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "vbam_gbcoloroption", + "(GB) Renk Düzeltme", + "Bazı oyunlarda renkleri düzelten renk düzeltmesini uygular.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "vbam_turboenable", + "Turbo Düğmelerini Etkinleştir", + "Gamepad turbo düğmelerini etkinleştirin veya devre dışı bırakın.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "enabled" + }, + { + "vbam_turbodelay", + "Turbo Gecikme (kare cinsinden)", + "Karelerde turbo tetikleyicilerin oranını tekrarlayın. Daha yüksek değer daha fazla tetikler.", + { + { "1", NULL }, + { "2", NULL }, + { "3", NULL }, + { "4", NULL }, + { "5", NULL }, + { "6", NULL }, + { "7", NULL }, + { "8", NULL }, + { "9", NULL }, + { "10", NULL }, + { "11", NULL }, + { "12", NULL }, + { "13", NULL }, + { "14", NULL }, + { "15", NULL }, + { NULL, NULL }, + }, + "3" + }, + { + "vbam_astick_deadzone", + "Sensörlerin Ölü Bölgesi (%)", + "Analog çubukların ölü bölgesini (yüzde olarak) ayarlayın.", + { + { "0", NULL }, + { "5", NULL }, + { "10", NULL }, + { "15", NULL }, + { "20", NULL }, + { "25", NULL }, + { "30", NULL }, + { NULL, NULL }, + }, + "15" + }, + { + "vbam_gyro_sensitivity", + "Sensör Hassasiyeti (Jiroskop) (%)", + "Varsayılan konumlandırma, sol analogdur. Gyro özellikli oyunlar için hassasiyet seviyesini ayarlamak için kullanılır.", + { + { "10", NULL }, + { "15", NULL }, + { "20", NULL }, + { "25", NULL }, + { "30", NULL }, + { "35", NULL }, + { "40", NULL }, + { "45", NULL }, + { "50", NULL }, + { "55", NULL }, + { "60", NULL }, + { "65", NULL }, + { "70", NULL }, + { "75", NULL }, + { "80", NULL }, + { "85", NULL }, + { "90", NULL }, + { "95", NULL }, + { "100", NULL }, + { "105", NULL }, + { "110", NULL }, + { "115", NULL }, + { "120", NULL }, + { NULL, NULL }, + }, + "100" + }, + { + "vbam_tilt_sensitivity", + "Sensör Hassasiyeti (Eğim) (%)", + "Varsayılan konumlandırma sağ analogdur. Gyro özellikli oyunlar için hassasiyet seviyesini ayarlamak için kullanılır.", + { + { "10", NULL }, + { "15", NULL }, + { "20", NULL }, + { "25", NULL }, + { "30", NULL }, + { "35", NULL }, + { "40", NULL }, + { "45", NULL }, + { "50", NULL }, + { "55", NULL }, + { "60", NULL }, + { "65", NULL }, + { "70", NULL }, + { "75", NULL }, + { "80", NULL }, + { "85", NULL }, + { "90", NULL }, + { "95", NULL }, + { "100", NULL }, + { "105", NULL }, + { "110", NULL }, + { "115", NULL }, + { "120", NULL }, + { NULL, NULL }, + }, + "100" + }, + { + "vbam_swap_astick", + "Sol / Sağ Analog Değiştirme", + "Döndürme ve eğme için sola ve sağa analog çubuk işlevini değiştirir.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "vbam_show_advanced_options", + "Gelişmiş Ayarları Göster", + "Ses kanallarını ve grafik katmanlarını etkinleştirebilen veya devre dışı bırakabilen gelişmiş seçenekleri gösterin.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "vbam_sound_1", + "Ses Kanalı 1", + "Tonlu ve tarama ses kanalını etkinleştirir veya devre dışı bırakır.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "enabled" + }, + { + "vbam_sound_2", + "Ses Kanalı 2", + "Tonlu ses kanalını etkinleştirir veya devre dışı bırakır.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "enabled" + }, + { + "vbam_sound_3", + "Ses Kanalı 3", + "Dalga çıkışı ses kanalını etkinleştirir veya devre dışı bırakır.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "enabled" + }, + { + "vbam_sound_4", + "Ses Kanalı 4", + "Gürültü ses kanalını etkinleştirir veya devre dışı bırakır.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "enabled" + }, + { + "vbam_sound_5", + "DMA Ses Kanalı A", + "DMA ses kanalı A'yı etkinleştirir veya devre dışı bırakır.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "enabled" + }, + { + "vbam_sound_6", + "DMA Ses Kanalı B", + "DMA ses kanalı B'yi etkinleştirir veya devre dışı bırakır.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "enabled" + }, + { + "vbam_layer_1", + "Arka Plan Katmanını Göster 1", + "1. arka plan katmanını gösterir veya gizler.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "enabled" + }, + { + "vbam_layer_2", + "Arka Plan Katmanını Göster 2", + "2. arka plan katmanını gösterir veya gizler.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "enabled" + }, + { + "vbam_layer_3", + "Arka Plan Katmanını Göster 3", + "3. arka plan katmanını gösterir veya gizler.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "enabled" + }, + { + "vbam_layer_4", + "Arka Plan Katmanını Göster 4", + "4. arka plan katmanını gösterir veya gizler.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "enabled" + }, + { + "vbam_layer_5", + "Sprite Katmanını Göster", + "Sprite katmanını gösterir veya gizler.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "enabled" + }, + { + "vbam_layer_6", + "Pencere Katmanını Göster 1", + "Pencere katmanı 1'i gösterir veya gizler.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "enabled" + }, + { + "vbam_layer_7", + "Pencere Katmanını Göster 2", + "Pencere katmanı 2'yi gösterir veya gizler.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "enabled" + }, + { + "vbam_layer_8", + "Sprite Pencere Katmanını Göster", + "Sprite pencere katmanını gösterir veya gizler.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "enabled" + }, + + { NULL, NULL, NULL, {{0}}, NULL } +}; + /* ******************************** * Language Mapping @@ -523,7 +959,7 @@ struct retro_core_option_definition *option_defs_intl[RETRO_LANGUAGE_LAST] = { NULL, /* RETRO_LANGUAGE_VIETNAMESE */ NULL, /* RETRO_LANGUAGE_ARABIC */ NULL, /* RETRO_LANGUAGE_GREEK */ - NULL, /* RETRO_LANGUAGE_TURKISH */ + option_defs_us, /* RETRO_LANGUAGE_TURKISH */ }; /* From 9e3c26152eb961ec4dbdf32022e2165e44ebe0dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mercan=20K=C3=B6m=C3=BCr?= Date: Tue, 13 Aug 2019 11:23:36 +0300 Subject: [PATCH 12/13] Update libretro_core_options.h option_defs_tr --- src/libretro/libretro_core_options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libretro/libretro_core_options.h b/src/libretro/libretro_core_options.h index 175226a5..dedc027c 100644 --- a/src/libretro/libretro_core_options.h +++ b/src/libretro/libretro_core_options.h @@ -959,7 +959,7 @@ struct retro_core_option_definition *option_defs_intl[RETRO_LANGUAGE_LAST] = { NULL, /* RETRO_LANGUAGE_VIETNAMESE */ NULL, /* RETRO_LANGUAGE_ARABIC */ NULL, /* RETRO_LANGUAGE_GREEK */ - option_defs_us, /* RETRO_LANGUAGE_TURKISH */ + option_defs_tr, /* RETRO_LANGUAGE_TURKISH */ }; /* From 9b043daadffb3002678f6f00629d2666217304f1 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Wed, 14 Aug 2019 09:56:39 -0400 Subject: [PATCH 13/13] libretro: Update core options API --- .../libretro-common/include/libretro.h | 64 ++++++++------- src/libretro/libretro_core_options.h | 71 ++++++++-------- src/libretro/libretro_core_options_intl.h | 80 +++++++++++++++++++ 3 files changed, 149 insertions(+), 66 deletions(-) create mode 100644 src/libretro/libretro_core_options_intl.h diff --git a/src/libretro/libretro-common/include/libretro.h b/src/libretro/libretro-common/include/libretro.h index 1fd2f5b7..b3f1a16d 100644 --- a/src/libretro/libretro-common/include/libretro.h +++ b/src/libretro/libretro-common/include/libretro.h @@ -1117,7 +1117,7 @@ enum retro_mod * This may be still be done regardless of the core options * interface version. * - * If version is 1 however, core options may instead be set by + * If version is >= 1 however, core options may instead be set by * passing an array of retro_core_option_definition structs to * RETRO_ENVIRONMENT_SET_CORE_OPTIONS, or a 2D array of * retro_core_option_definition structs to RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL. @@ -1132,8 +1132,8 @@ enum retro_mod * GET_VARIABLE. * This allows the frontend to present these variables to * a user dynamically. - * This should only be called if RETRO_ENVIRONMENT_GET_ENHANCED_CORE_OPTIONS - * returns an API version of 1. + * This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION + * returns an API version of >= 1. * This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES. * This should be called the first time as early as * possible (ideally in retro_set_environment). @@ -1169,14 +1169,12 @@ enum retro_mod * i.e. it should be feasible to cycle through options * without a keyboard. * - * First entry should be treated as a default. - * * Example entry: * { * "foo_option", * "Speed hack coprocessor X", * "Provides increased performance at the expense of reduced accuracy", - * { + * { * { "false", NULL }, * { "true", NULL }, * { "unstable", "Turbo (Unstable)" }, @@ -1196,8 +1194,8 @@ enum retro_mod * GET_VARIABLE. * This allows the frontend to present these variables to * a user dynamically. - * This should only be called if RETRO_ENVIRONMENT_GET_ENHANCED_CORE_OPTIONS - * returns an API version of 1. + * This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION + * returns an API version of >= 1. * This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES. * This should be called the first time as early as * possible (ideally in retro_set_environment). @@ -1384,17 +1382,17 @@ typedef int (RETRO_CALLCONV *retro_vfs_closedir_t)(struct retro_vfs_dir_handle * struct retro_vfs_interface { /* VFS API v1 */ - retro_vfs_get_path_t get_path; - retro_vfs_open_t open; - retro_vfs_close_t close; - retro_vfs_size_t size; - retro_vfs_tell_t tell; - retro_vfs_seek_t seek; - retro_vfs_read_t read; - retro_vfs_write_t write; - retro_vfs_flush_t flush; - retro_vfs_remove_t remove; - retro_vfs_rename_t rename; + retro_vfs_get_path_t get_path; + retro_vfs_open_t open; + retro_vfs_close_t close; + retro_vfs_size_t size; + retro_vfs_tell_t tell; + retro_vfs_seek_t seek; + retro_vfs_read_t read; + retro_vfs_write_t write; + retro_vfs_flush_t flush; + retro_vfs_remove_t remove; + retro_vfs_rename_t rename; /* VFS API v2 */ retro_vfs_truncate_t truncate; /* VFS API v3 */ @@ -1422,11 +1420,11 @@ struct retro_vfs_interface_info enum retro_hw_render_interface_type { - RETRO_HW_RENDER_INTERFACE_VULKAN = 0, - RETRO_HW_RENDER_INTERFACE_D3D9 = 1, - RETRO_HW_RENDER_INTERFACE_D3D10 = 2, - RETRO_HW_RENDER_INTERFACE_D3D11 = 3, - RETRO_HW_RENDER_INTERFACE_D3D12 = 4, + RETRO_HW_RENDER_INTERFACE_VULKAN = 0, + RETRO_HW_RENDER_INTERFACE_D3D9 = 1, + RETRO_HW_RENDER_INTERFACE_D3D10 = 2, + RETRO_HW_RENDER_INTERFACE_D3D11 = 3, + RETRO_HW_RENDER_INTERFACE_D3D12 = 4, RETRO_HW_RENDER_INTERFACE_GSKIT_PS2 = 5, RETRO_HW_RENDER_INTERFACE_DUMMY = INT_MAX }; @@ -2504,8 +2502,20 @@ struct retro_core_option_display }; /* Maximum number of values permitted for a core option - * NOTE: This may be increased on a core-by-core basis - * if required (doing so has no effect on the frontend) */ + * > Note: We have to set a maximum value due the limitations + * of the C language - i.e. it is not possible to create an + * array of structs each containing a variable sized array, + * so the retro_core_option_definition values array must + * have a fixed size. The size limit of 128 is a balancing + * act - it needs to be large enough to support all 'sane' + * core options, but setting it too large may impact low memory + * platforms. In practise, if a core option has more than + * 128 values then the implementation is likely flawed. + * To quote the above API reference: + * "The number of possible options should be very limited + * i.e. it should be feasible to cycle through options + * without a keyboard." + */ #define RETRO_NUM_CORE_OPTION_VALUES_MAX 128 struct retro_core_option_value @@ -2749,4 +2759,4 @@ RETRO_API size_t retro_get_memory_size(unsigned id); } #endif -#endif +#endif \ No newline at end of file diff --git a/src/libretro/libretro_core_options.h b/src/libretro/libretro_core_options.h index 47b13b85..8a0ab627 100644 --- a/src/libretro/libretro_core_options.h +++ b/src/libretro/libretro_core_options.h @@ -7,6 +7,28 @@ #include #include +#ifndef HAVE_NO_LANGEXTRA +#include "libretro_core_options_intl.h" +#endif + +/* + ******************************** + * VERSION: 1.3 + ******************************** + * + * - 1.3: Move translations to libretro_core_options_intl.h + * - libretro_core_options_intl.h includes BOM and utf-8 + * fix for MSVC 2010-2013 + * - Added HAVE_NO_LANGEXTRA flag to disable translations + * on platforms/compilers without BOM support + * - 1.2: Use core options v1 interface when + * RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION is >= 1 + * (previously required RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION == 1) + * - 1.1: Support generation of core options v0 retro_core_option_value + * arrays containing options with a single value + * - 1.0: First commit +*/ + #ifdef __cplusplus extern "C" { #endif @@ -462,48 +484,13 @@ struct retro_core_option_definition option_defs_us[] = { { NULL, NULL, NULL, {{0}}, NULL } }; -/* RETRO_LANGUAGE_JAPANESE */ - -/* RETRO_LANGUAGE_FRENCH */ - -/* RETRO_LANGUAGE_SPANISH */ - -/* RETRO_LANGUAGE_GERMAN */ - -/* RETRO_LANGUAGE_ITALIAN */ - -/* RETRO_LANGUAGE_DUTCH */ - -/* RETRO_LANGUAGE_PORTUGUESE_BRAZIL */ - -/* RETRO_LANGUAGE_PORTUGUESE_PORTUGAL */ - -/* RETRO_LANGUAGE_RUSSIAN */ - -/* RETRO_LANGUAGE_KOREAN */ - -/* RETRO_LANGUAGE_CHINESE_TRADITIONAL */ - -/* RETRO_LANGUAGE_CHINESE_SIMPLIFIED */ - -/* RETRO_LANGUAGE_ESPERANTO */ - -/* RETRO_LANGUAGE_POLISH */ - -/* RETRO_LANGUAGE_VIETNAMESE */ - -/* RETRO_LANGUAGE_ARABIC */ - -/* RETRO_LANGUAGE_GREEK */ - -/* RETRO_LANGUAGE_TURKISH */ - /* ******************************** * Language Mapping ******************************** */ +#ifndef HAVE_NO_LANGEXTRA struct retro_core_option_definition *option_defs_intl[RETRO_LANGUAGE_LAST] = { option_defs_us, /* RETRO_LANGUAGE_ENGLISH */ NULL, /* RETRO_LANGUAGE_JAPANESE */ @@ -525,6 +512,7 @@ struct retro_core_option_definition *option_defs_intl[RETRO_LANGUAGE_LAST] = { NULL, /* RETRO_LANGUAGE_GREEK */ NULL, /* RETRO_LANGUAGE_TURKISH */ }; +#endif /* ******************************** @@ -533,7 +521,8 @@ struct retro_core_option_definition *option_defs_intl[RETRO_LANGUAGE_LAST] = { */ /* Handles configuration/setting of core options. - * Should only be called inside retro_set_environment(). + * Should be called as early as possible - ideally inside + * retro_set_environment(), and no later than retro_load_game() * > We place the function body in the header to avoid the * necessity of adding more .c files (i.e. want this to * be as painless as possible for core devs) @@ -546,8 +535,9 @@ static INLINE void libretro_set_core_options(retro_environment_t environ_cb) if (!environ_cb) return; - if (environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version) && (version == 1)) + if (environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version) && (version >= 1)) { +#ifndef HAVE_NO_LANGEXTRA struct retro_core_options_intl core_options_intl; unsigned language = 0; @@ -559,6 +549,9 @@ static INLINE void libretro_set_core_options(retro_environment_t environ_cb) core_options_intl.local = option_defs_intl[language]; environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL, &core_options_intl); +#else + environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, &option_defs_us); +#endif } else { @@ -617,7 +610,7 @@ static INLINE void libretro_set_core_options(retro_environment_t environ_cb) } /* Build values string */ - if (num_values > 1) + if (num_values > 0) { size_t j; diff --git a/src/libretro/libretro_core_options_intl.h b/src/libretro/libretro_core_options_intl.h new file mode 100644 index 00000000..33682dfd --- /dev/null +++ b/src/libretro/libretro_core_options_intl.h @@ -0,0 +1,80 @@ +#ifndef LIBRETRO_CORE_OPTIONS_INTL_H__ +#define LIBRETRO_CORE_OPTIONS_INTL_H__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1500 && _MSC_VER < 1900) +/* https://support.microsoft.com/en-us/kb/980263 */ +#pragma execution_character_set("utf-8") +#pragma warning(disable:4566) +#endif + +#include + +/* + ******************************** + * VERSION: 1.3 + ******************************** + * + * - 1.3: Move translations to libretro_core_options_intl.h + * - libretro_core_options_intl.h includes BOM and utf-8 + * fix for MSVC 2010-2013 + * - Added HAVE_NO_LANGEXTRA flag to disable translations + * on platforms/compilers without BOM support + * - 1.2: Use core options v1 interface when + * RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION is >= 1 + * (previously required RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION == 1) + * - 1.1: Support generation of core options v0 retro_core_option_value + * arrays containing options with a single value + * - 1.0: First commit +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + ******************************** + * Core Option Definitions + ******************************** +*/ + +/* RETRO_LANGUAGE_JAPANESE */ + +/* RETRO_LANGUAGE_FRENCH */ + +/* RETRO_LANGUAGE_SPANISH */ + +/* RETRO_LANGUAGE_GERMAN */ + +/* RETRO_LANGUAGE_ITALIAN */ + +/* RETRO_LANGUAGE_DUTCH */ + +/* RETRO_LANGUAGE_PORTUGUESE_BRAZIL */ + +/* RETRO_LANGUAGE_PORTUGUESE_PORTUGAL */ + +/* RETRO_LANGUAGE_RUSSIAN */ + +/* RETRO_LANGUAGE_KOREAN */ + +/* RETRO_LANGUAGE_CHINESE_TRADITIONAL */ + +/* RETRO_LANGUAGE_CHINESE_SIMPLIFIED */ + +/* RETRO_LANGUAGE_ESPERANTO */ + +/* RETRO_LANGUAGE_POLISH */ + +/* RETRO_LANGUAGE_VIETNAMESE */ + +/* RETRO_LANGUAGE_ARABIC */ + +/* RETRO_LANGUAGE_GREEK */ + +/* RETRO_LANGUAGE_TURKISH */ + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file