libretro: update build for newer libchdr
authornotaz <notasas@gmail.com>
Thu, 28 Mar 2024 23:28:11 +0000 (01:28 +0200)
committernotaz <notasas@gmail.com>
Thu, 28 Mar 2024 23:37:24 +0000 (01:37 +0200)
notaz/pcsx_rearmed#339

Makefile
frontend/libretro.c
jni/Android.mk
libpcsxcore/cdriso.c

index f293903..9b5d245 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -72,23 +72,24 @@ ifeq ($(DEBUG), 1)
 endif
 
 ifeq ($(WANT_ZLIB),1)
-CFLAGS += -Ideps/libchdr/deps/zlib-1.2.13
-OBJS += deps/libchdr/deps/zlib-1.2.13/adler32.o \
-        deps/libchdr/deps/zlib-1.2.13/compress.o \
-        deps/libchdr/deps/zlib-1.2.13/crc32.o \
-        deps/libchdr/deps/zlib-1.2.13/deflate.o \
-        deps/libchdr/deps/zlib-1.2.13/gzclose.o \
-        deps/libchdr/deps/zlib-1.2.13/gzlib.o \
-        deps/libchdr/deps/zlib-1.2.13/gzread.o \
-        deps/libchdr/deps/zlib-1.2.13/gzwrite.o \
-        deps/libchdr/deps/zlib-1.2.13/infback.o \
-        deps/libchdr/deps/zlib-1.2.13/inffast.o \
-        deps/libchdr/deps/zlib-1.2.13/inflate.o \
-        deps/libchdr/deps/zlib-1.2.13/inftrees.o \
-        deps/libchdr/deps/zlib-1.2.13/trees.o \
-        deps/libchdr/deps/zlib-1.2.13/uncompr.o \
-        deps/libchdr/deps/zlib-1.2.13/zutil.o
-deps/libchdr/deps/zlib-1.2.13/%.o: CFLAGS += -DHAVE_UNISTD_H
+ZLIB_DIR = deps/libchdr/deps/zlib-1.3.1
+CFLAGS += -I$(ZLIB_DIR)
+OBJS += $(ZLIB_DIR)/adler32.o \
+        $(ZLIB_DIR)/compress.o \
+        $(ZLIB_DIR)/crc32.o \
+        $(ZLIB_DIR)/deflate.o \
+        $(ZLIB_DIR)/gzclose.o \
+        $(ZLIB_DIR)/gzlib.o \
+        $(ZLIB_DIR)/gzread.o \
+        $(ZLIB_DIR)/gzwrite.o \
+        $(ZLIB_DIR)/infback.o \
+        $(ZLIB_DIR)/inffast.o \
+        $(ZLIB_DIR)/inflate.o \
+        $(ZLIB_DIR)/inftrees.o \
+        $(ZLIB_DIR)/trees.o \
+        $(ZLIB_DIR)/uncompr.o \
+        $(ZLIB_DIR)/zutil.o
+$(ZLIB_DIR)/%.o: CFLAGS += -DHAVE_UNISTD_H
 endif
 ifeq "$(ARCH)" "arm"
 OBJS += libpcsxcore/gte_arm.o
@@ -254,25 +255,44 @@ OBJS += plugins/cdrcimg/cdrcimg.o
 
 # libchdr
 ifeq "$(HAVE_CHD)" "1"
-CFLAGS += -Ideps/libchdr/include
-CFLAGS += -Ideps/libchdr/include/libchdr
-OBJS += deps/libchdr/deps/lzma-19.00/src/Alloc.o
-OBJS += deps/libchdr/deps/lzma-19.00/src/Bra86.o
-OBJS += deps/libchdr/deps/lzma-19.00/src/BraIA64.o
-OBJS += deps/libchdr/deps/lzma-19.00/src/CpuArch.o
-OBJS += deps/libchdr/deps/lzma-19.00/src/Delta.o
-OBJS += deps/libchdr/deps/lzma-19.00/src/LzFind.o
-OBJS += deps/libchdr/deps/lzma-19.00/src/Lzma86Dec.o
-OBJS += deps/libchdr/deps/lzma-19.00/src/LzmaDec.o
-OBJS += deps/libchdr/deps/lzma-19.00/src/LzmaEnc.o
-OBJS += deps/libchdr/deps/lzma-19.00/src/Sort.o
-OBJS += deps/libchdr/src/libchdr_bitstream.o
-OBJS += deps/libchdr/src/libchdr_cdrom.o
-OBJS += deps/libchdr/src/libchdr_chd.o
-OBJS += deps/libchdr/src/libchdr_flac.o
-OBJS += deps/libchdr/src/libchdr_huffman.o
-CFLAGS += -Ideps/libchdr/deps/lzma-19.00/include
-CFLAGS += -DHAVE_CHD -D_7ZIP_ST
+LCHDR = deps/libchdr
+LCHDR_LZMA = $(LCHDR)/deps/lzma-22.01
+LCHDR_ZSTD = $(LCHDR)/deps/zstd-1.5.5/lib
+OBJS += $(LCHDR)/src/libchdr_bitstream.o
+OBJS += $(LCHDR)/src/libchdr_cdrom.o
+OBJS += $(LCHDR)/src/libchdr_chd.o
+OBJS += $(LCHDR)/src/libchdr_flac.o
+OBJS += $(LCHDR)/src/libchdr_huffman.o
+$(LCHDR)/src/%.o: CFLAGS += -Wno-unused -std=gnu11
+OBJS += $(LCHDR_LZMA)/src/Alloc.o
+OBJS += $(LCHDR_LZMA)/src/Bra86.o
+OBJS += $(LCHDR_LZMA)/src/BraIA64.o
+OBJS += $(LCHDR_LZMA)/src/CpuArch.o
+OBJS += $(LCHDR_LZMA)/src/Delta.o
+OBJS += $(LCHDR_LZMA)/src/LzFind.o
+OBJS += $(LCHDR_LZMA)/src/Lzma86Dec.o
+OBJS += $(LCHDR_LZMA)/src/LzmaDec.o
+OBJS += $(LCHDR_LZMA)/src/LzmaEnc.o
+OBJS += $(LCHDR_LZMA)/src/Sort.o
+$(LCHDR_LZMA)/src/%.o: CFLAGS += -Wno-unused -D_7ZIP_ST -I$(LCHDR_LZMA)/include
+$(LCHDR)/src/%.o: CFLAGS += -I$(LCHDR_LZMA)/include
+OBJS += $(LCHDR_ZSTD)/common/debug.o
+OBJS += $(LCHDR_ZSTD)/common/entropy_common.o
+OBJS += $(LCHDR_ZSTD)/common/error_private.o
+OBJS += $(LCHDR_ZSTD)/common/fse_decompress.o
+OBJS += $(LCHDR_ZSTD)/common/pool.o
+OBJS += $(LCHDR_ZSTD)/common/threading.o
+OBJS += $(LCHDR_ZSTD)/common/xxhash.o
+OBJS += $(LCHDR_ZSTD)/common/zstd_common.o
+OBJS += $(LCHDR_ZSTD)/decompress/huf_decompress.o
+OBJS += $(LCHDR_ZSTD)/decompress/zstd_ddict.o
+OBJS += $(LCHDR_ZSTD)/decompress/zstd_decompress_block.o
+OBJS += $(LCHDR_ZSTD)/decompress/zstd_decompress.o
+$(LCHDR_ZSTD)/common/%.o \
+$(LCHDR_ZSTD)/decompress/%.o: CFLAGS += -DZSTD_DISABLE_ASM -I$(LCHDR_ZSTD)
+$(LCHDR)/src/%.o: CFLAGS += -I$(LCHDR_ZSTD)
+libpcsxcore/cdriso.o: CFLAGS += -Wno-unused-function
+CFLAGS += -DHAVE_CHD -I$(LCHDR)/include
 LDFLAGS += -lm
 endif
 
index ffd64c7..1808c5e 100644 (file)
@@ -294,16 +294,17 @@ static void convert(void *buf, size_t bytes)
 static void addCrosshair(int port, int crosshair_color, unsigned short *buffer, int bufferStride, int pos_x, int pos_y, int thickness, int size_x, int size_y) {
    for (port = 0; port < 2; port++) {
       // Draw the horizontal line of the crosshair
-      for (int i = pos_y - thickness / 2; i <= pos_y + thickness / 2; i++) {
-         for (int j = pos_x - size_x / 2; j <= pos_x + size_x / 2; j++) {
+      int i, j;
+      for (i = pos_y - thickness / 2; i <= pos_y + thickness / 2; i++) {
+         for (j = pos_x - size_x / 2; j <= pos_x + size_x / 2; j++) {
             if ((i + vout_height) >= 0 && (i + vout_height) < bufferStride && j >= 0 && j < bufferStride && in_enable_crosshair[port] > 0)
                buffer[i * bufferStride + j] = crosshair_color;
-      }
          }
+      }
 
       // Draw the vertical line of the crosshair
-      for (int i = pos_x - thickness / 2; i <= pos_x + thickness / 2; i++) {
-         for (int j = pos_y - size_y / 2; j <= pos_y + size_y / 2; j++) {
+      for (i = pos_x - thickness / 2; i <= pos_x + thickness / 2; i++) {
+         for (j = pos_y - size_y / 2; j <= pos_y + size_y / 2; j++) {
             if (i >= 0 && i < bufferStride && (j + vout_height) >= 0 && (j + vout_height) < bufferStride && in_enable_crosshair[port] > 0)
                buffer[j * bufferStride + i] = crosshair_color;
          }
@@ -366,8 +367,8 @@ static void vout_flip(const void *vram, int stride, int bgr24,
    for (port = 0; port < 2; port++) {
       if (in_enable_crosshair[port] > 0 && (in_type[port] == PSE_PAD_TYPE_GUNCON || in_type[port] == PSE_PAD_TYPE_GUN))
       {
-        struct CrosshairInfo crosshairInfo;
-        CrosshairDimensions(port, &crosshairInfo);
+         struct CrosshairInfo crosshairInfo;
+         CrosshairDimensions(port, &crosshairInfo);
          addCrosshair(port, in_enable_crosshair[port], dest, dstride, crosshairInfo.pos_x, crosshairInfo.pos_y, crosshairInfo.thickness, crosshairInfo.size_x, crosshairInfo.size_y);
       }
    }
@@ -727,8 +728,8 @@ static bool update_option_visibility(void)
             "pcsx_rearmed_negcon_deadzone",
             "pcsx_rearmed_negcon_response",
             "pcsx_rearmed_input_sensitivity",
-           "pcsx_rearmed_crosshair1",
-           "pcsx_rearmed_crosshair2",
+            "pcsx_rearmed_crosshair1",
+            "pcsx_rearmed_crosshair2",
             "pcsx_rearmed_konamigunadjustx",
             "pcsx_rearmed_konamigunadjusty",
             "pcsx_rearmed_gunconadjustx",
index 9fc6984..e633337 100644 (file)
@@ -4,7 +4,6 @@ $(shell cd "$(LOCAL_PATH)" && ((git describe --always || echo) | sed -e 's/.*/#d
 $(shell cd "$(LOCAL_PATH)" && (diff -q ../frontend/revision.h_ ../frontend/revision.h > /dev/null 2>&1 || cp ../frontend/revision.h_ ../frontend/revision.h))
 $(shell cd "$(LOCAL_PATH)" && (rm ../frontend/revision.h_))
 
-HAVE_CHD ?= 1
 USE_LIBRETRO_VFS ?= 0
 
 ROOT_DIR     := $(LOCAL_PATH)/..
@@ -69,26 +68,43 @@ SOURCES_C += $(FRONTEND_DIR)/main.c \
              $(FRONTEND_DIR)/libretro.c
 
 # libchdr
+LCHDR = $(DEPS_DIR)/libchdr
+LCHDR_LZMA = $(LCHDR)/deps/lzma-22.01
+LCHDR_ZSTD = $(LCHDR)/deps/zstd-1.5.5/lib
 SOURCES_C += \
-             $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/Alloc.c \
-             $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/Bra86.c \
-             $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/BraIA64.c \
-             $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/CpuArch.c \
-             $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/Delta.c \
-             $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/LzFind.c \
-             $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/Lzma86Dec.c \
-             $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/LzmaDec.c \
-             $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/LzmaEnc.c \
-             $(DEPS_DIR)/libchdr/deps/lzma-19.00/src/Sort.c \
-             $(DEPS_DIR)/libchdr/src/libchdr_bitstream.c \
-             $(DEPS_DIR)/libchdr/src/libchdr_cdrom.c \
-             $(DEPS_DIR)/libchdr/src/libchdr_chd.c \
-             $(DEPS_DIR)/libchdr/src/libchdr_flac.c \
-             $(DEPS_DIR)/libchdr/src/libchdr_huffman.c
+            $(LCHDR)/src/libchdr_bitstream.c \
+            $(LCHDR)/src/libchdr_cdrom.c \
+            $(LCHDR)/src/libchdr_chd.c \
+            $(LCHDR)/src/libchdr_flac.c \
+            $(LCHDR)/src/libchdr_huffman.c \
+            $(LCHDR_LZMA)/src/Alloc.c \
+            $(LCHDR_LZMA)/src/Bra86.c \
+            $(LCHDR_LZMA)/src/BraIA64.c \
+            $(LCHDR_LZMA)/src/CpuArch.c \
+            $(LCHDR_LZMA)/src/Delta.c \
+            $(LCHDR_LZMA)/src/LzFind.c \
+            $(LCHDR_LZMA)/src/Lzma86Dec.c \
+            $(LCHDR_LZMA)/src/LzmaDec.c \
+            $(LCHDR_LZMA)/src/LzmaEnc.c \
+            $(LCHDR_LZMA)/src/Sort.c \
+            $(LCHDR_ZSTD)/common/debug.c \
+            $(LCHDR_ZSTD)/common/entropy_common.c \
+            $(LCHDR_ZSTD)/common/error_private.c \
+            $(LCHDR_ZSTD)/common/fse_decompress.c \
+            $(LCHDR_ZSTD)/common/pool.c \
+            $(LCHDR_ZSTD)/common/threading.c \
+            $(LCHDR_ZSTD)/common/xxhash.c \
+            $(LCHDR_ZSTD)/common/zstd_common.c \
+            $(LCHDR_ZSTD)/decompress/huf_decompress.c \
+            $(LCHDR_ZSTD)/decompress/zstd_ddict.c \
+            $(LCHDR_ZSTD)/decompress/zstd_decompress_block.c \
+            $(LCHDR_ZSTD)/decompress/zstd_decompress.c
 SOURCES_ASM :=
+EXTRA_INCLUDES += $(LCHDR)/include $(LCHDR_LZMA)/include $(LCHDR_ZSTD)
+COREFLAGS += -DHAVE_CHD -D_7ZIP_ST -DZSTD_DISABLE_ASM
 
-COREFLAGS := -ffast-math -funroll-loops -DHAVE_LIBRETRO -DNO_FRONTEND -DFRONTEND_SUPPORTS_RGB565 -DANDROID -DREARMED
-COREFLAGS += -DP_HAVE_MMAP=1 -DP_HAVE_PTHREAD=1 -DP_HAVE_POSIX_MEMALIGN=1 -DHAVE_CHD -D_7ZIP_ST
+COREFLAGS += -ffast-math -funroll-loops -DHAVE_LIBRETRO -DNO_FRONTEND -DFRONTEND_SUPPORTS_RGB565 -DANDROID -DREARMED
+COREFLAGS += -DP_HAVE_MMAP=1 -DP_HAVE_PTHREAD=1 -DP_HAVE_POSIX_MEMALIGN=1
 
 ifeq ($(USE_LIBRETRO_VFS),1)
 SOURCES_C += \
@@ -104,6 +120,7 @@ SOURCES_C += \
              $(LIBRETRO_COMMON)/vfs/vfs_implementation.c
 COREFLAGS += -DUSE_LIBRETRO_VFS
 endif
+EXTRA_INCLUDES += $(LIBRETRO_COMMON)/include
 
 HAVE_ARI64=0
 HAVE_LIGHTREC=0
@@ -210,8 +227,7 @@ LOCAL_MODULE        := retro
 LOCAL_SRC_FILES     := $(SOURCES_C) $(SOURCES_ASM)
 LOCAL_CFLAGS        := $(COREFLAGS)
 LOCAL_C_INCLUDES    := $(ROOT_DIR)/include
-LOCAL_C_INCLUDES    += $(DEPS_DIR)/crypto $(DEPS_DIR)/libchdr/deps/lzma-19.00/include $(DEPS_DIR)/libchdr/include $(DEPS_DIR)/libchdr/include/libchdr
-LOCAL_C_INCLUDES    += $(LIBRETRO_COMMON)/include
+LOCAL_C_INCLUDES    += $(DEPS_DIR)/crypto
 LOCAL_C_INCLUDES    += $(EXTRA_INCLUDES)
 LOCAL_LDFLAGS       := -Wl,-version-script=$(FRONTEND_DIR)/link.T
 LOCAL_LDLIBS        := -lz -llog
index b8356e6..4a79426 100644 (file)
@@ -28,7 +28,7 @@
 #include <errno.h>
 #include <zlib.h>
 #ifdef HAVE_CHD
-#include <chd.h>
+#include <libchdr/chd.h>
 #endif
 
 #ifdef _WIN32