From 96063fb0da5e687c60bdc63880c427fc0fd5856d Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Wed, 28 Mar 2018 21:59:27 +0300 Subject: [PATCH] Fixed Windows build, added Unicode support in Windows. --- Core/gb.c | 7 ++++--- Core/gb.h | 1 - Makefile | 4 ++++ SDL/gui.c | 1 + SDL/main.c | 1 + Windows/utf8_compat.c | 14 ++++++++++++++ libretro/Makefile.common | 8 +------- libretro/jni/Android.mk | 2 +- 8 files changed, 26 insertions(+), 12 deletions(-) create mode 100755 Windows/utf8_compat.c diff --git a/Core/gb.c b/Core/gb.c index fe8fe5a..e0da579 100755 --- a/Core/gb.c +++ b/Core/gb.c @@ -11,9 +11,10 @@ #endif #include "gb.h" -/* The libretro frontend does not link against rewind.c, so we provide empty weak alternatives to its functions */ -void __attribute__((weak)) GB_rewind_free(GB_gameboy_t *gb) { } -void __attribute__((weak)) GB_rewind_push(GB_gameboy_t *gb) { } +#ifdef DISABLE_REWIND +#define GB_rewind_free(...) +#define GB_rewind_push(...) +#endif void GB_attributed_logv(GB_gameboy_t *gb, GB_log_attributes attributes, const char *fmt, va_list args) { diff --git a/Core/gb.h b/Core/gb.h index 37685b4..43bb611 100644 --- a/Core/gb.h +++ b/Core/gb.h @@ -2,7 +2,6 @@ #define GB_h #include #include -#include #include #include "gb_struct_def.h" diff --git a/Makefile b/Makefile index 3d5a632..f970d8e 100755 --- a/Makefile +++ b/Makefile @@ -106,6 +106,10 @@ COCOA_SOURCES := $(shell ls Cocoa/*.m) $(shell ls HexFiend/*.m) QUICKLOOK_SOURCES := $(shell ls QuickLook/*.m) $(shell ls QuickLook/*.c) endif +ifeq ($(PLATFORM),windows32) +CORE_SOURCES += $(shell ls Windows/*.c) +endif + CORE_OBJECTS := $(patsubst %,$(OBJ)/%.o,$(CORE_SOURCES)) COCOA_OBJECTS := $(patsubst %,$(OBJ)/%.o,$(COCOA_SOURCES)) QUICKLOOK_OBJECTS := $(patsubst %,$(OBJ)/%.o,$(QUICKLOOK_SOURCES)) diff --git a/SDL/gui.c b/SDL/gui.c index c152e59..a09cb49 100644 --- a/SDL/gui.c +++ b/SDL/gui.c @@ -1,5 +1,6 @@ #include #include +#include #include "utils.h" #include "gui.h" #include "font.h" diff --git a/SDL/main.c b/SDL/main.c index dda7803..bd14377 100755 --- a/SDL/main.c +++ b/SDL/main.c @@ -1,4 +1,5 @@ #include +#include #include #include #include diff --git a/Windows/utf8_compat.c b/Windows/utf8_compat.c new file mode 100755 index 0000000..1005f22 --- /dev/null +++ b/Windows/utf8_compat.c @@ -0,0 +1,14 @@ +#include +#include +#include + +FILE *fopen(const char *filename, const char *mode) +{ + wchar_t w_filename[MAX_PATH] = {0,}; + MultiByteToWideChar(CP_UTF8, 0, filename, -1, w_filename, sizeof(w_filename) / sizeof(w_filename[0])); + + wchar_t w_mode[8] = {0,}; + MultiByteToWideChar(CP_UTF8, 0, mode, -1, w_mode, sizeof(w_mode) / sizeof(w_mode[0])); + + return _wfopen(w_filename, w_mode); +} \ No newline at end of file diff --git a/libretro/Makefile.common b/libretro/Makefile.common index 8e5af51..889e972 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -16,13 +16,7 @@ SOURCES_C := $(CORE_DIR)/Core/gb.c \ $(CORE_DIR)/libretro/dmg_boot.c \ $(CORE_DIR)/libretro/libretro.c -ifeq ($(HAVE_DEBUGGER), 1) -SOURCES_C += $(CORE_DIR)/Core/debugger.c \ - $(CORE_DIR)/Core/z80_disassembler.c -else -CFLAGS += -DDISABLE_DEBUGGER -endif -CFLAGS += -DDISABLE_TIMEKEEPING +CFLAGS += -DDISABLE_TIMEKEEPING -DDISABLE_REWIND -DDISABLE_DEBUGGER SOURCES_CXX := diff --git a/libretro/jni/Android.mk b/libretro/jni/Android.mk index 4c4a7b6..1d1ac94 100644 --- a/libretro/jni/Android.mk +++ b/libretro/jni/Android.mk @@ -28,7 +28,7 @@ CORE_DIR := $(realpath ../..) include ../Makefile.common LOCAL_SRC_FILES := $(SOURCES_CXX) $(SOURCES_C) -LOCAL_CFLAGS += -DINLINE=inline -DHAVE_STDINT_H -DHAVE_INTTYPES_H -D__LIBRETRO__ -DNDEBUG -D_USE_MATH_DEFINES -DGB_INTERNAL -std=c99 -I$(CORE_DIR) -DSAMEBOY_CORE_VERSION=\"$(VERSION)\" -DDISABLE_DEBUGGER -DDISABLE_TIMEKEEPING -Wno-multichar +LOCAL_CFLAGS += -DINLINE=inline -DHAVE_STDINT_H -DHAVE_INTTYPES_H -D__LIBRETRO__ -DNDEBUG -D_USE_MATH_DEFINES -DGB_INTERNAL -std=c99 -I$(CORE_DIR) -DSAMEBOY_CORE_VERSION=\"$(VERSION)\" -DDISABLE_DEBUGGER -DDISABLE_REWIND -DDISABLE_TIMEKEEPING -Wno-multichar LOCAL_C_INCLUDES = $(INCFLAGS) include $(BUILD_SHARED_LIBRARY)