Browse Source

core, libretro fixes for chd support

kub 3 years ago
parent
commit
886ce067c3
6 changed files with 13 additions and 7 deletions
  1. 1 1
      Makefile
  2. 1 1
      pico/cd/cd_parse.c
  3. 1 1
      pico/cd/libchdr
  4. 5 4
      pico/pico_port.h
  5. 2 0
      pico/pico_types.h
  6. 3 0
      platform/psp/plat.c

+ 1 - 1
Makefile

@@ -249,7 +249,6 @@ CHDR = pico/cd/libchdr
 CHDR_OBJS += $(CHDR)/src/libchdr_chd.o $(CHDR)/src/libchdr_cdrom.o
 CHDR_OBJS += $(CHDR)/src/libchdr_flac.o
 CHDR_OBJS += $(CHDR)/src/libchdr_bitstream.o $(CHDR)/src/libchdr_huffman.o
-$(CHDR_OBJS): CFLAGS += -DHAVE_FSEEKO
 
 # flac
 FLAC = $(CHDR)/deps/flac-1.3.3
@@ -258,6 +257,7 @@ FLAC_OBJS += $(FLAC)/src/metadata_object.o $(FLAC)/src/metadata_iterators.o
 FLAC_OBJS += $(FLAC)/src/bitmath.o $(FLAC)/src/bitreader.o $(FLAC)/src/md5.o
 FLAC_OBJS += $(FLAC)/src/memory.o $(FLAC)/src/fixed.o $(FLAC)/src/crc.o
 FLAC_OBJS += $(FLAC)/src/window.o $(FLAC)/src/stream_decoder.o
+FLAC_OBJS += $(FLAC)/src/windows_unicode_filenames.o
 $(FLAC_OBJS): CFLAGS += -DPACKAGE_VERSION=\"1.3.3\" -DFLAC__HAS_OGG=0
 $(FLAC_OBJS): CFLAGS += -DHAVE_FSEEKO -DHAVE_LROUND -DHAVE_STDINT_H -DHAVE_STDLIB_H # ugh...
 

+ 1 - 1
pico/cd/cd_parse.c

@@ -83,7 +83,7 @@ static int get_ext(const char *fname, char ext[4],
 	strncpy(ext, fname + pos + 1, 4/*sizeof(ext)*/-1);
 	ext[4/*sizeof(ext)*/-1] = '\0';
 
-	if (base != NULL) {
+	if (base != NULL && base_size > 0) {
 		if (pos + 1 < base_size)
 			pos = base_size - 1;
 

+ 1 - 1
pico/cd/libchdr

@@ -1 +1 @@
-Subproject commit 208212ae77f5c4fedca11d797e50cb1954b2c837
+Subproject commit 714fc3f268ebddf035a76cc883bd4543b5142a6f

+ 5 - 4
pico/pico_port.h

@@ -34,8 +34,8 @@
 #endif
 
 
-// There's no standard way to determine endianess at compile time.
-// Do not bother with mixed endian platforms, no one will ever compile on that.
+// There's no standard way to determine endianess at compile time. Try using
+// some well known non-standard macros for detection.
 #if defined __BYTE_ORDER__
 #define	CPU_IS_LE	__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 #elif defined _BYTE_ORDER
@@ -48,6 +48,7 @@
 #warning "can't detect byte order, assume little endian"
 #define	CPU_IS_LE	1
 #endif
+// NB mixed endian integer platforms are not supported.
 
 #if CPU_IS_LE
 // address/offset operations
@@ -56,7 +57,7 @@
 #define MEM_LE2(a)	(a)
 #define MEM_LE4(a)	(a)
 // swapping
-#define CPU_BE2(v)	(((v)<<16)|((v)>>16))
+#define CPU_BE2(v)	((u32)((u64)(v)<<16)|((v)>>16))
 #define CPU_BE4(v)	(((u32)(v)>>24)|(((v)>>8)&0x00ff00)| \
 			(((v)<<8)&0xff0000)|(u32)((v)<<24))
 #define CPU_LE2(v)	(v)		// swap of 2*u16 in u32
@@ -70,7 +71,7 @@
 // swapping
 #define CPU_BE2(v)	(v)
 #define CPU_BE4(v)	(v)
-#define CPU_LE2(v)	(((v)<<16)|((v)>>16))
+#define CPU_LE2(v)	((u32)((u64)(v)<<16)|((v)>>16))
 #define CPU_LE4(v)	(((u32)(v)>>24)|(((v)>>8)&0x00ff00)| \
 			(((v)<<8)&0xff0000)|(u32)((v)<<24))
 #endif

+ 2 - 0
pico/pico_types.h

@@ -11,6 +11,8 @@ typedef uint16_t       u16;
 typedef int16_t        s16;
 typedef uint32_t       u32;
 typedef int32_t        s32;
+typedef uint64_t       u64;
+typedef int64_t        s64;
 #endif
 #endif
 

+ 3 - 0
platform/psp/plat.c

@@ -328,6 +328,9 @@ int _flush_cache (char *addr, const int size, const int op)
 }
 
 /* stubs for libflac (embedded in libchdr) */
+#include <utime.h>
+#include <malloc.h>
+
 int chown(const char *pathname, uid_t owner, gid_t group) { return -1; }
 int chmod(const char *pathname, mode_t mode) { return -1; }
 int utime(const char *filename, const struct utimbuf *times) { return -1; }