From b0ec2e6d0719603212373bcdaaedd5b7b5e43121 Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Thu, 16 May 2019 09:56:54 +0800 Subject: [PATCH] Allow building without CHD, disable CHD for 3DS - all platforms compiles with CHD support. - compile with HAVE_CHD=0 for no chd support. - CHD fails building for 3DS, not sure its even fast enough for the device. I tried asking in discord channel but haven't got reply. Disabling it till someone familiar with 3ds can fix it. http://p.0bl.net/123458 --- Makefile | 4 +++- Makefile.libretro | 3 ++- libpcsxcore/cdriso.c | 15 ++++++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 98498c87..5732c14a 100644 --- a/Makefile +++ b/Makefile @@ -159,6 +159,7 @@ endif OBJS += plugins/cdrcimg/cdrcimg.o # libchdr +ifeq "$(HAVE_CHD)" "1" CFLAGS += -Ideps/libchdr OBJS += deps/crypto/md5.o OBJS += deps/crypto/sha1.o @@ -208,8 +209,9 @@ else endif CFLAGS += -Ideps/crypto -Ideps/flac-1.3.2/include -Ideps/flac-1.3.2/src/libFLAC/include -Ideps/flac-1.3.2/src/libFLAC/include -Ideps/lzma-16.04/C -CFLAGS += -D'PACKAGE_VERSION="1.3.2"' -DFLAC__HAS_OGG=0 -DFLAC__NO_DLL -DHAVE_LROUND -DHAVE_STDINT_H -DHAVE_STDLIB_H -DFLAC__NO_DLL -D_7ZIP_ST +CFLAGS += -DHAVE_CHD -D'PACKAGE_VERSION="1.3.2"' -DFLAC__HAS_OGG=0 -DFLAC__NO_DLL -DHAVE_LROUND -DHAVE_STDINT_H -DHAVE_STDLIB_H -DFLAC__NO_DLL -D_7ZIP_ST LDFLAGS += -lm +endif # dfinput OBJS += plugins/dfinput/main.o plugins/dfinput/pad.o plugins/dfinput/guncon.o diff --git a/Makefile.libretro b/Makefile.libretro index 5d380b65..f58f2844 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -2,6 +2,7 @@ DEBUG ?= 0 WANT_ZLIB ?= 1 +HAVE_CHD ?= 1 ifeq ($(platform),) platform = unix @@ -188,7 +189,7 @@ else ifeq ($(platform), ctr) DRC_CACHE_BASE = 0 ARCH = arm HAVE_NEON = 0 - + HAVE_CHD = 0 STATIC_LINKING = 1 # Xbox 360 diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index 7007f551..975105ed 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -27,7 +27,9 @@ #include #include +#ifdef HAVE_CHD #include +#endif #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN @@ -94,6 +96,7 @@ static struct { unsigned int sector_in_blk; } *compr_img; +#ifdef HAVE_CHD static struct { unsigned char (*buffer)[CD_FRAMESIZE_RAW + SUB_FRAMESIZE]; chd_file* chd; @@ -102,6 +105,7 @@ static struct { unsigned int current_hunk; unsigned int sector_in_hunk; } *chd_img; +#endif int (*cdimg_read_func)(FILE *f, unsigned int base, void *dest, int sector); @@ -1039,6 +1043,7 @@ fail_io: return -1; } +#ifdef HAVE_CHD static int handlechd(const char *isofile) { chd_img = calloc(1, sizeof(*chd_img)); if (chd_img == NULL) @@ -1110,6 +1115,7 @@ fail_io: } return -1; } +#endif // this function tries to get the .sub file of the given .img static int opensubfile(const char *isoname) { @@ -1272,6 +1278,7 @@ finish: return CD_FRAMESIZE_RAW; } +#ifdef HAVE_CHD static int cdread_chd(FILE *f, unsigned int base, void *dest, int sector) { int hunk; @@ -1295,7 +1302,7 @@ finish: CD_FRAMESIZE_RAW); return CD_FRAMESIZE_RAW; } - +#endif static int cdread_2048(FILE *f, unsigned int base, void *dest, int sector) { int ret; @@ -1315,9 +1322,11 @@ static unsigned char * CALLBACK ISOgetBuffer_compr(void) { return compr_img->buff_raw[compr_img->sector_in_blk] + 12; } +#ifdef HAVE_CHD static unsigned char * CALLBACK ISOgetBuffer_chd(void) { return chd_img->buffer[chd_img->sector_in_hunk] + 12; } +#endif static unsigned char * CALLBACK ISOgetBuffer(void) { return cdbuffer + 12; @@ -1386,11 +1395,13 @@ static long CALLBACK ISOopen(void) { CDR_getBuffer = ISOgetBuffer_compr; cdimg_read_func = cdread_compressed; } +#ifdef HAVE_CHD else if (handlechd(GetIsoFile()) == 0) { SysPrintf("[chd]"); CDR_getBuffer = ISOgetBuffer_chd; cdimg_read_func = cdread_chd; } +#endif if (!subChanMixed && opensubfile(GetIsoFile()) == 0) { SysPrintf("[+sub]"); @@ -1479,12 +1490,14 @@ static long CALLBACK ISOclose(void) { compr_img = NULL; } +#ifdef HAVE_CHD if (chd_img != NULL) { chd_close(chd_img->chd); free(chd_img->buffer); free(chd_img); chd_img = NULL; } +#endif for (i = 1; i <= numtracks; i++) { if (ti[i].handle != NULL) { -- 2.39.2