From 26b50b39807417093999c015623ec33f8136836b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 29 Apr 2014 23:49:47 +0200 Subject: [PATCH] Bake in libtremor for regular Makefile and Android --- Makefile.libretro | 45 ++++++++++++++++++++++++++++++----------- core/tremor/misc.h | 2 ++ libretro/jni/Android.mk | 18 ++++++++++++++++- libretro/libretro.c | 3 +++ 4 files changed, 55 insertions(+), 13 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index 40588bf..472a6ce 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -3,6 +3,7 @@ LOGSOUND = 0 FRONTEND_SUPPORTS_RGB565 = 1 GENPLUS_SRC_DIR := core +TREMOR_SRC_DIR := $(GENPLUS_SRC_DIR)/tremor LIBRETRO_DIR := libretro ifneq ($(EMSCRIPTEN),) @@ -47,14 +48,16 @@ ifeq ($(platform), unix) TARGET := $(TARGET_NAME)_libretro.so fpic := -fPIC SHARED := -shared -Wl,--version-script=libretro/link.T -Wl,--no-undefined -lz - ENDIANNESS_DEFINES := -DLSB_FIRST + ENDIANNESS_DEFINES := -DLSB_FIRST -DBYTE_ORDER=LITTLE_ENDIAN PLATFORM_DEFINES := -DHAVE_ZLIB else ifeq ($(platform), osx) TARGET := $(TARGET_NAME)_libretro.dylib fpic := -fPIC SHARED := -dynamiclib -lz -ifneq ($(arch),ppc) - ENDIANNESS_DEFINES := -DLSB_FIRST +ifeq ($(arch),ppc) + ENDIANNESS_DEFINES := -DMSB_FIRST -DBYTE_ORDER=BIG_ENDIAN +else + ENDIANNESS_DEFINES := -DLSB_FIRST -DBYTE_ORDER=LITTLE_ENDIAN endif PLATFORM_DEFINES := -DHAVE_ZLIB @@ -66,7 +69,7 @@ else ifeq ($(platform), ios) TARGET := $(TARGET_NAME)_libretro_ios.dylib fpic := -fPIC SHARED := -dynamiclib -lz - ENDIANNESS_DEFINES := -DLSB_FIRST + ENDIANNESS_DEFINES := -DLSB_FIRST -DBYTE_ORDER=LITTLE_ENDIAN PLATFORM_DEFINES := -DHAVE_ZLIB CC = clang -arch armv7 -isysroot $(IOSSDK) @@ -79,7 +82,7 @@ else ifeq ($(platform), qnx) TARGET := $(TARGET_NAME)_libretro_qnx.so fpic := -fPIC SHARED := -lm -shared -Wl,--version-script=libretro/link.T -Wl,--no-undefined -lz - ENDIANNESS_DEFINES := -DLSB_FIRST + ENDIANNESS_DEFINES := -DLSB_FIRST -DBYTE_ORDER=LITTLE_ENDIAN PLATFORM_DEFINES := -DHAVE_ZLIB CC = qcc -Vgcc_ntoarmv7le AR = qcc -Vgcc_ntoarmv7le @@ -88,13 +91,13 @@ else ifeq ($(platform), ps3) TARGET := $(TARGET_NAME)_libretro_ps3.a CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe - PLATFORM_DEFINES := -D__CELLOS_LV2 -DALT_RENDER + PLATFORM_DEFINES := -D__CELLOS_LV2 -DALT_RENDER -DMSB_FIRST -DBYTE_ORDER=BIG_ENDIAN STATIC_LINKING = 1 else ifeq ($(platform), sncps3) TARGET := $(TARGET_NAME)_libretro_ps3.a CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe - PLATFORM_DEFINES := -D__CELLOS_LV2 -DALT_RENDER + PLATFORM_DEFINES := -D__CELLOS_LV2 -DALT_RENDER -DMSB_FIRST -DBYTE_ORDER=BIG_ENDIAN STATIC_LINKING = 1 else ifeq ($(platform), psl1ght) TARGET := $(TARGET_NAME)_libretro_psl1ght.a$(EXE_EXT) @@ -106,7 +109,7 @@ else ifeq ($(platform), psp1) TARGET := $(TARGET_NAME)_libretro_psp1.a$(EXE_EXT) CC = psp-gcc$(EXE_EXT) AR = psp-ar$(EXE_EXT) - ENDIANNESS_DEFINES := -DLSB_FIRST + ENDIANNESS_DEFINES := -DLSB_FIRST -DBYTE_ORDER=LITTLE_ENDIAN PLATFORM_DEFINES := -DPSP CFLAGS += -G0 STATIC_LINKING = 1 @@ -115,11 +118,13 @@ else ifeq ($(platform), xenon) CC = xenon-gcc$(EXE_EXT) AR = xenon-ar$(EXE_EXT) PLATFORM_DEFINES := -D__LIBXENON__ -DALT_RENDER + ENDIANNESS_DEFINES := -DMSB_FIRST -DBYTE_ORDER=BIG_ENDIAN STATIC_LINKING = 1 else ifeq ($(platform), ngc) TARGET := $(TARGET_NAME)_libretro_ngc.a CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT) AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) + ENDIANNESS_DEFINES := -DMSB_FIRST -DBYTE_ORDER=BIG_ENDIAN PLATFORM_DEFINES := -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -DALT_RENDER STATIC_LINKING = 1 else ifeq ($(platform), wii) @@ -127,12 +132,13 @@ else ifeq ($(platform), wii) CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT) AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) PLATFORM_DEFINES := -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -DALT_RENDER + ENDIANNESS_DEFINES := -DMSB_FIRST -DBYTE_ORDER=BIG_ENDIAN STATIC_LINKING = 1 else ifneq (,$(findstring armv,$(platform))) TARGET := $(TARGET_NAME)_libretro.so fpic := -fPIC SHARED := -shared -Wl,--version-script=libretro/link.T -Wl,--no-undefined -lz - ENDIANNESS_DEFINES := -DLSB_FIRST + ENDIANNESS_DEFINES := -DLSB_FIRST -DBYTE_ORDER=LITTLE_ENDIAN PLATFORM_DEFINES := -DHAVE_ZLIB CC = gcc ifneq (,$(findstring cortexa8,$(platform))) @@ -153,13 +159,13 @@ endif PLATFORM_DEFINES += -DARM else ifeq ($(platform), emscripten) TARGET := $(TARGET_NAME)_libretro_emscripten.bc - ENDIANNESS_DEFINES := -DLSB_FIRST + ENDIANNESS_DEFINES := -DLSB_FIRST -DBYTE_ORDER=LITTLE_ENDIAN else TARGET := $(TARGET_NAME)_libretro.dll CC = gcc SHARED := -shared -static-libgcc -static-libstdc++ -Wl,--version-script=libretro/link.T -Wl,--no-undefined -lz - ENDIANNESS_DEFINES := -DLSB_FIRST + ENDIANNESS_DEFINES := -DLSB_FIRST -DBYTE_ORDER=LITTLE_ENDIAN PLATFORM_DEFINES := -DHAVE_ZLIB endif @@ -220,6 +226,21 @@ LIBRETRO_SRC := $(GENPLUS_SRC_DIR)/genesis.c \ $(GENPLUS_SRC_DIR)/z80/z80.c \ $(GENPLUS_SRC_DIR)/m68k/m68kcpu.c \ $(GENPLUS_SRC_DIR)/m68k/s68kcpu.c \ + $(TREMOR_SRC_DIR)/bitwise.c \ + $(TREMOR_SRC_DIR)/block.c \ + $(TREMOR_SRC_DIR)/codebook.c \ + $(TREMOR_SRC_DIR)/floor0.c \ + $(TREMOR_SRC_DIR)/floor1.c \ + $(TREMOR_SRC_DIR)/framing.c \ + $(TREMOR_SRC_DIR)/info.c \ + $(TREMOR_SRC_DIR)/mapping0.c \ + $(TREMOR_SRC_DIR)/mdct.c \ + $(TREMOR_SRC_DIR)/registry.c \ + $(TREMOR_SRC_DIR)/res012.c \ + $(TREMOR_SRC_DIR)/sharedbook.c \ + $(TREMOR_SRC_DIR)/synthesis.c \ + $(TREMOR_SRC_DIR)/vorbisfile.c \ + $(TREMOR_SRC_DIR)/window.c \ $(LIBRETRO_DIR)/libretro.c LIBRETRO_OBJ := $(LIBRETRO_SRC:.c=.o) @@ -228,7 +249,7 @@ ifeq ($(LOGSOUND), 1) LIBRETRO_CFLAGS := -DLOGSOUND endif -DEFINES := +DEFINES := -DUSE_LIBTREMOR CFLAGS += $(fpic) $(DEFINES) $(CODE_DEFINES) ifeq ($(FRONTEND_SUPPORTS_RGB565), 1) diff --git a/core/tremor/misc.h b/core/tremor/misc.h index 12856d9..f762913 100644 --- a/core/tremor/misc.h +++ b/core/tremor/misc.h @@ -47,6 +47,7 @@ union magic { }; #endif +#ifndef ANDROID #if BYTE_ORDER==BIG_ENDIAN union magic { struct { @@ -56,6 +57,7 @@ union magic { ogg_int64_t whole; }; #endif +#endif STIN ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) { union magic magic; diff --git a/libretro/jni/Android.mk b/libretro/jni/Android.mk index 270c981..da28065 100644 --- a/libretro/jni/Android.mk +++ b/libretro/jni/Android.mk @@ -3,6 +3,7 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) GENPLUS_SRC_DIR := ../../core +TREMOR_SRC_DIR := $(GENPLUS_SRC_DIR)/tremor LIBRETRO_DIR := ../ LOCAL_MODULE := retro @@ -59,6 +60,21 @@ LOCAL_SRC_FILES := $(GENPLUS_SRC_DIR)/genesis.c \ $(GENPLUS_SRC_DIR)/z80/z80.c \ $(GENPLUS_SRC_DIR)/m68k/m68kcpu.c \ $(GENPLUS_SRC_DIR)/m68k/s68kcpu.c \ + $(TREMOR_SRC_DIR)/bitwise.c \ + $(TREMOR_SRC_DIR)/block.c \ + $(TREMOR_SRC_DIR)/codebook.c \ + $(TREMOR_SRC_DIR)/floor0.c \ + $(TREMOR_SRC_DIR)/floor1.c \ + $(TREMOR_SRC_DIR)/framing.c \ + $(TREMOR_SRC_DIR)/info.c \ + $(TREMOR_SRC_DIR)/mapping0.c \ + $(TREMOR_SRC_DIR)/mdct.c \ + $(TREMOR_SRC_DIR)/registry.c \ + $(TREMOR_SRC_DIR)/res012.c \ + $(TREMOR_SRC_DIR)/sharedbook.c \ + $(TREMOR_SRC_DIR)/synthesis.c \ + $(TREMOR_SRC_DIR)/vorbisfile.c \ + $(TREMOR_SRC_DIR)/window.c \ $(LIBRETRO_DIR)/libretro.c \ $(LIBRETRO_DIR)/scrc32.c @@ -73,6 +89,6 @@ LOCAL_C_INCLUDES = $(LOCAL_PATH)/$(GENPLUS_SRC_DIR) \ $(LOCAL_PATH)/$(GENPLUS_SRC_DIR)/ntsc \ $(LOCAL_PATH)/$(LIBRETRO_DIR) -LOCAL_CFLAGS = -ffast-math -O2 -funroll-loops -DINLINE="static inline" -DUSE_16BPP_RENDERING -DLSB_FIRST -D__LIBRETRO__ -DFRONTEND_SUPPORTS_RGB565 -DALIGN_LONG -DALIGN_WORD +LOCAL_CFLAGS = -ffast-math -O2 -funroll-loops -DINLINE="static inline" -DUSE_LIBTREMOR -DUSE_16BPP_RENDERING -DLSB_FIRST -DBYTE_ORDER=LITTLE_ENDIAN -D__LIBRETRO__ -DFRONTEND_SUPPORTS_RGB565 -DALIGN_LONG -DALIGN_WORD include $(BUILD_SHARED_LIBRARY) diff --git a/libretro/libretro.c b/libretro/libretro.c index e8b68e5..68e3692 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -69,6 +69,7 @@ static retro_audio_sample_batch_t audio_cb; /************************************ * Genesis Plus GX implementation ************************************/ +#undef CHUNKSIZE #define CHUNKSIZE (0x10000) void error(char * fmt, ...) @@ -1024,3 +1025,5 @@ void retro_run(void) configure_controls(); } } + +#undef CHUNKSIZE