From a374f5332b670017e7f9f831e65b3417be05aedc Mon Sep 17 00:00:00 2001 From: limboemu Date: Thu, 23 Sep 2021 16:12:03 +0300 Subject: [PATCH] support for older devices --- limbo-android-arm/build.gradle | 2 +- limbo-android-lib/build.gradle | 2 +- .../max2idea/android/limbo/jni/VMExecutor.java | 6 ++++-- .../com/max2idea/android/limbo/main/Config.java | 4 +++- .../android/limbo/main/LimboActivity.java | 4 +++- limbo-android-lib/src/main/jni/Android.mk | 5 ++++- limbo-android-lib/src/main/jni/Application.mk | 8 ++------ .../android-armv7a-softfp.mak | 3 ++- .../android-device-config/android-armv8.mak | 3 ++- .../android-device-config/android-generic.mak | 1 - .../android-device-config/android-x86.mak | 3 ++- .../android-device-config/android-x86_64.mak | 3 ++- .../jni/android-config/android-limbo-config.mak | 6 +++--- .../src/main/jni/compat/sdl-addons/Android.mk | 9 ++++++--- .../main/jni/compat/sdl-addons/SDL_limboaudio.c | 17 ----------------- .../src/main/jni/limbo/vm-executor-jni.cpp | 1 + limbo-android-ppc/build.gradle | 2 +- limbo-android-sparc/build.gradle | 2 +- limbo-android-x86/build.gradle | 2 +- 19 files changed, 39 insertions(+), 44 deletions(-) diff --git a/limbo-android-arm/build.gradle b/limbo-android-arm/build.gradle index 4eecde126..02efb6958 100644 --- a/limbo-android-arm/build.gradle +++ b/limbo-android-arm/build.gradle @@ -6,7 +6,7 @@ android { defaultConfig { applicationId "com.limbo.emu.main.arm" - minSdkVersion 26 + minSdkVersion 21 targetSdkVersion 29 ndk { abiFilters "armeabi-v7a","arm64-v8a", "x86", "x86_64" } } diff --git a/limbo-android-lib/build.gradle b/limbo-android-lib/build.gradle index 28e0de26a..b8bc5fa66 100644 --- a/limbo-android-lib/build.gradle +++ b/limbo-android-lib/build.gradle @@ -5,7 +5,7 @@ android { buildToolsVersion '29.0.3' defaultConfig{ - minSdkVersion 26 + minSdkVersion 21 targetSdkVersion 29 } buildTypes { diff --git a/limbo-android-lib/src/main/java/com/max2idea/android/limbo/jni/VMExecutor.java b/limbo-android-lib/src/main/java/com/max2idea/android/limbo/jni/VMExecutor.java index 8afd69b6c..adcd04e88 100644 --- a/limbo-android-lib/src/main/java/com/max2idea/android/limbo/jni/VMExecutor.java +++ b/limbo-android-lib/src/main/java/com/max2idea/android/limbo/jni/VMExecutor.java @@ -103,7 +103,7 @@ private native String start(String storage_dir, String base_dir, public native void nativeRefreshScreen(int value); - public native void nativeEnableAaudio(int value); + public native void nativeEnableAaudio(int value, String aaudioLibName, String aaudioLibPath); /** * Prints parameters in qemu format @@ -861,7 +861,9 @@ public void setFullscreen() { @Override public void enableAaudio(int value) { - nativeEnableAaudio(value); + nativeEnableAaudio(value, Config.aaudioLibName, + FileUtils.getNativeLibDir(LimboApplication.getInstance()) + + "/" + Config.aaudioLibName); } //TODO: re-enable getting status from the vm diff --git a/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/Config.java b/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/Config.java index f5c16b34f..1a06acbfa 100644 --- a/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/Config.java +++ b/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/Config.java @@ -30,7 +30,7 @@ public class Config { public enum EMU_VERSION { QEMUv2_9_1, QEMUv5_1_0 } - public static final EMU_VERSION emuVersion = EMU_VERSION.QEMUv5_1_0; + public static final EMU_VERSION emuVersion = EMU_VERSION.QEMUv2_9_1; // Constants public static final int SDL_MOUSE_LEFT = 1; @@ -102,6 +102,8 @@ public enum EMU_VERSION { // stack size to remove an issue with SDL Audio public static long stackSize = 10 * 1024 * 1024; + // native alternative to audio track + public static String aaudioLibName = "libcompat-SDL2-addons.so"; // if you don't want to enable software updates set to false public static boolean enableSoftwareUpdates = true; diff --git a/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/LimboActivity.java b/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/LimboActivity.java index ea393bd68..5fc985fee 100644 --- a/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/LimboActivity.java +++ b/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/LimboActivity.java @@ -27,6 +27,7 @@ import android.content.pm.PackageInfo; import android.content.res.Configuration; import android.graphics.Point; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Looper; @@ -1101,7 +1102,8 @@ public void setupNativeLibs() { // SDL library if (Config.enable_SDL) { - System.loadLibrary("compat-SDL2-addons"); + if (Build.VERSION.SDK_INT >= 26) + System.loadLibrary("compat-SDL2-addons"); System.loadLibrary("SDL2"); } diff --git a/limbo-android-lib/src/main/jni/Android.mk b/limbo-android-lib/src/main/jni/Android.mk index 2179b6730..be6596b51 100644 --- a/limbo-android-lib/src/main/jni/Android.mk +++ b/limbo-android-lib/src/main/jni/Android.mk @@ -3,7 +3,10 @@ #dep libs include $(NDK_PROJECT_PATH)/jni/compat/musl/Android.mk include $(NDK_PROJECT_PATH)/jni/compat/Android.mk -include $(NDK_PROJECT_PATH)/jni/compat/sdl-addons/Android.mk +ifeq ($(USE_AAUDIO),true) + include $(NDK_PROJECT_PATH)/jni/compat/sdl-addons/Android.mk +endif + ifeq ($(USE_SDL),true) include $(NDK_PROJECT_PATH)/jni/SDL2/Android.mk endif diff --git a/limbo-android-lib/src/main/jni/Application.mk b/limbo-android-lib/src/main/jni/Application.mk index f0bb55ece..23710ad54 100644 --- a/limbo-android-lib/src/main/jni/Application.mk +++ b/limbo-android-lib/src/main/jni/Application.mk @@ -13,12 +13,8 @@ else endif #Don't remove this -APP_CFLAGS += $(ARCH_CFLAGS) -APP_CFLAGS += $(ARCH_EXTRA_CFLAGS) -APP_LDFLAGS += $(ARCH_LD_FLAGS) - -#FIXME: we should use memmove for the utils also -#APP_CFLAGS += -include $(FIXUTILS) +APP_CFLAGS += -include $(LOGUTILS) +APP_LDFLAGS += -llog APP_ARM_MODE=$(ARM_MODE) diff --git a/limbo-android-lib/src/main/jni/android-config/android-device-config/android-armv7a-softfp.mak b/limbo-android-lib/src/main/jni/android-config/android-device-config/android-armv7a-softfp.mak index 5ed4f0e40..b7b33250d 100644 --- a/limbo-android-lib/src/main/jni/android-config/android-device-config/android-armv7a-softfp.mak +++ b/limbo-android-lib/src/main/jni/android-config/android-device-config/android-armv7a-softfp.mak @@ -5,8 +5,9 @@ ARCH_CFLAGS += -D__ANDROID_API__=$(NDK_PLATFORM_API) #CLANG ONLY ifeq ($(NDK_TOOLCHAIN_VERSION),clang) + TARGET_PREFIX = armv7-none-linux-androideabi # ARCH_CLANG_FLAGS += -gcc-toolchain $(TOOLCHAIN_DIR) - ARCH_CLANG_FLAGS += -target armv7-none-linux-androideabi$(NDK_PLATFORM_API) + ARCH_CLANG_FLAGS += -target $(TARGET_PREFIX)$(NDK_PLATFORM_API) ARCH_CFLAGS += $(ARCH_CLANG_FLAGS) -D__ANDROID_API__=$(NDK_PLATFORM_API) # ARCH_CFLAGS += -fno-integrated-as ARCH_LD_FLAGS += -Wc,-target -Wc,armv7-none-linux-androideabi$(NDK_PLATFORM_API) diff --git a/limbo-android-lib/src/main/jni/android-config/android-device-config/android-armv8.mak b/limbo-android-lib/src/main/jni/android-config/android-device-config/android-armv8.mak index 0bc2713f0..e26093cdc 100644 --- a/limbo-android-lib/src/main/jni/android-config/android-device-config/android-armv8.mak +++ b/limbo-android-lib/src/main/jni/android-config/android-device-config/android-armv8.mak @@ -5,8 +5,9 @@ ARCH_CFLAGS += -D__ANDROID_API__=$(NDK_PLATFORM_API) #CLANG ONLY ifeq ($(NDK_TOOLCHAIN_VERSION),clang) + TARGET_PREFIX = aarch64-none-linux-android # ARCH_CLANG_FLAGS += -gcc-toolchain $(TOOLCHAIN_DIR) - ARCH_CLANG_FLAGS += -target aarch64-none-linux-android$(NDK_PLATFORM_API) + ARCH_CLANG_FLAGS += -target $(TARGET_PREFIX)$(NDK_PLATFORM_API) ARCH_CFLAGS += $(ARCH_CLANG_FLAGS) -D__ANDROID_API__=$(NDK_PLATFORM_API) # ARCH_CFLAGS += -fno-integrated-as ARCH_LD_FLAGS += -Wc,-target -Wc,aarch64-none-linux-android$(NDK_PLATFORM_API) diff --git a/limbo-android-lib/src/main/jni/android-config/android-device-config/android-generic.mak b/limbo-android-lib/src/main/jni/android-config/android-device-config/android-generic.mak index 20a4fb658..d65697f99 100644 --- a/limbo-android-lib/src/main/jni/android-config/android-device-config/android-generic.mak +++ b/limbo-android-lib/src/main/jni/android-config/android-device-config/android-generic.mak @@ -27,7 +27,6 @@ ARCH_LD_FLAGS += -lc -lm -llog # add aaudio ifeq ($(USE_AAUDIO),true) ARCH_CFLAGS += -D__ENABLE_AAUDIO__ - ARCH_LD_FLAGS += -laaudio endif # Suppress some warnings diff --git a/limbo-android-lib/src/main/jni/android-config/android-device-config/android-x86.mak b/limbo-android-lib/src/main/jni/android-config/android-device-config/android-x86.mak index a23a98c4a..6af7bb6af 100644 --- a/limbo-android-lib/src/main/jni/android-config/android-device-config/android-x86.mak +++ b/limbo-android-lib/src/main/jni/android-config/android-device-config/android-x86.mak @@ -6,8 +6,9 @@ ARCH_LD_FLAGS += -latomic #CLANG ONLY ifeq ($(NDK_TOOLCHAIN_VERSION),clang) + TARGET_PREFIX = i686-none-linux-android # ARCH_CLANG_FLAGS += -gcc-toolchain $(TOOLCHAIN_DIR) - ARCH_CLANG_FLAGS += -target i686-none-linux-android$(NDK_PLATFORM_API) + ARCH_CLANG_FLAGS += -target $(TARGET_PREFIX)$(NDK_PLATFORM_API) ARCH_CFLAGS += $(ARCH_CLANG_FLAGS) -D__ANDROID_API__=$(NDK_PLATFORM_API) #ARCH_CFLAGS += -fno-integrated-as ARCH_LD_FLAGS += -Wc,-target -Wc,i686-none-linux-android$(NDK_PLATFORM_API) diff --git a/limbo-android-lib/src/main/jni/android-config/android-device-config/android-x86_64.mak b/limbo-android-lib/src/main/jni/android-config/android-device-config/android-x86_64.mak index da3dfa677..8b12dc9a3 100644 --- a/limbo-android-lib/src/main/jni/android-config/android-device-config/android-x86_64.mak +++ b/limbo-android-lib/src/main/jni/android-config/android-device-config/android-x86_64.mak @@ -6,8 +6,9 @@ ARCH_LD_FLAGS += -latomic #CLANG ONLY ifeq ($(NDK_TOOLCHAIN_VERSION),clang) + TARGET_PREFIX = x86_64-none-linux-android # ARCH_CLANG_FLAGS += -gcc-toolchain $(TOOLCHAIN_DIR) - ARCH_CLANG_FLAGS += -target x86_64-none-linux-android$(NDK_PLATFORM_API) + ARCH_CLANG_FLAGS += -target $(TARGET_PREFIX)$(NDK_PLATFORM_API) ARCH_CFLAGS += $(ARCH_CLANG_FLAGS) -D__ANDROID_API__=$(NDK_PLATFORM_API) # ARCH_CFLAGS += -fno-integrated-as ARCH_LD_FLAGS += -Wc,-target -Wc,x86_64-none-linux-android$(NDK_PLATFORM_API) diff --git a/limbo-android-lib/src/main/jni/android-config/android-limbo-config.mak b/limbo-android-lib/src/main/jni/android-config/android-limbo-config.mak index 7966a8b83..68ecacef4 100644 --- a/limbo-android-lib/src/main/jni/android-config/android-limbo-config.mak +++ b/limbo-android-lib/src/main/jni/android-config/android-limbo-config.mak @@ -10,13 +10,13 @@ NDK_ROOT ?= /home/dev/tools/ndk/android-ndk-r23 USE_GCC?=false ### the ndk api should be the same as the minSdkVersion in your AndroidManifest.xml -NDK_PLATFORM_API=26 +NDK_PLATFORM_API=21 # Set to true if you use platform-21 or above USE_NDK_PLATFORM21 ?= true # Set to true if you use platform-26 or above -USE_NDK_PLATFORM26 ?= true +USE_NDK_PLATFORM26 ?= false # Optimization, generally it is better set to false when debugging USE_OPTIMIZATION ?= true @@ -49,7 +49,7 @@ BUILD_GUEST?=x86_64-softmmu # QEMU Version # values: 2.9.1, 5.1.0 -USE_QEMU_VERSION ?= 5.1.0 +USE_QEMU_VERSION ?= 2.9.1 # If you want to use SDL interface USE_SDL ?= true diff --git a/limbo-android-lib/src/main/jni/compat/sdl-addons/Android.mk b/limbo-android-lib/src/main/jni/compat/sdl-addons/Android.mk index b31b5a32c..9428664b9 100644 --- a/limbo-android-lib/src/main/jni/compat/sdl-addons/Android.mk +++ b/limbo-android-lib/src/main/jni/compat/sdl-addons/Android.mk @@ -2,10 +2,13 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) -LOCAL_MODULE := compat-SDL2-addons +# We override the target platform +LOCAL_CFLAGS += -target $(TARGET_PREFIX)26 +LOCAL_LDFLAGS += -target $(TARGET_PREFIX)26 + +LOCAL_LDLIBS += -laaudio +LOCAL_MODULE := compat-SDL2-addons LOCAL_SRC_FILES := SDL_limboaudio.c -LOCAL_C_INCLUDES := include $(BUILD_SHARED_LIBRARY) - diff --git a/limbo-android-lib/src/main/jni/compat/sdl-addons/SDL_limboaudio.c b/limbo-android-lib/src/main/jni/compat/sdl-addons/SDL_limboaudio.c index 8c235e744..e6430d545 100644 --- a/limbo-android-lib/src/main/jni/compat/sdl-addons/SDL_limboaudio.c +++ b/limbo-android-lib/src/main/jni/compat/sdl-addons/SDL_limboaudio.c @@ -17,8 +17,6 @@ Copyright (C) Max Kastanas 2012 * */ -// Requires minSdkVersion 26+ -#if defined(__ENABLE_AAUDIO__) #include #include #include @@ -36,8 +34,6 @@ float aaudioResampleRate = 22050.0; // we drop the frames you can use 0 to do a median filter instead int aaudioDropFrames = 1; -int enableAaudio = 0; - // FIXME: buggy int enableAaudioHighPriority = 0; @@ -68,10 +64,6 @@ int aaudioResampleFrames = 0; sem_t mutex; -int isAaudioEnabled() { - return enableAaudio; -} - // FIXME: this is buggy, though since the aaudio write function is // fast enough we don't bother for now aaudio_data_callback_result_t aaudio_callback( @@ -309,12 +301,3 @@ void writeAaudioQueue() { void* getAaudioBuffer() { return aaudioMidBuffer; } - -JNIEXPORT void JNICALL Java_com_max2idea_android_limbo_jni_VMExecutor_nativeEnableAaudio( - JNIEnv* env, jobject thiz, - int value) { - printf("set enable aaudio: %d\n", value); - enableAaudio = value; -} - -#endif diff --git a/limbo-android-lib/src/main/jni/limbo/vm-executor-jni.cpp b/limbo-android-lib/src/main/jni/limbo/vm-executor-jni.cpp index 0445a69c8..ccb5202e2 100644 --- a/limbo-android-lib/src/main/jni/limbo/vm-executor-jni.cpp +++ b/limbo-android-lib/src/main/jni/limbo/vm-executor-jni.cpp @@ -45,6 +45,7 @@ void * loadLib(const char* lib_filename, const char * lib_path_str) { void *ldhandle = dlopen(lib_filename, RTLD_LAZY); if(ldhandle == NULL) { // try with the lib path + printf("trying loading with full path: %s\n", lib_path_str); ldhandle = dlopen(lib_path_str, RTLD_LAZY); } return ldhandle; diff --git a/limbo-android-ppc/build.gradle b/limbo-android-ppc/build.gradle index e43c6c444..ee9de3ec9 100644 --- a/limbo-android-ppc/build.gradle +++ b/limbo-android-ppc/build.gradle @@ -6,7 +6,7 @@ android { defaultConfig { applicationId "com.limbo.emu.main.ppc" - minSdkVersion 26 + minSdkVersion 21 targetSdkVersion 29 ndk { abiFilters "armeabi-v7a","arm64-v8a", "x86", "x86_64" } } diff --git a/limbo-android-sparc/build.gradle b/limbo-android-sparc/build.gradle index 3fdca50cf..03c9a2a91 100644 --- a/limbo-android-sparc/build.gradle +++ b/limbo-android-sparc/build.gradle @@ -6,7 +6,7 @@ android { defaultConfig { applicationId "com.limbo.emu.main.sparc" - minSdkVersion 26 + minSdkVersion 21 targetSdkVersion 29 ndk { abiFilters "armeabi-v7a","arm64-v8a", "x86", "x86_64" } } diff --git a/limbo-android-x86/build.gradle b/limbo-android-x86/build.gradle index 532b6e206..651e2a16e 100644 --- a/limbo-android-x86/build.gradle +++ b/limbo-android-x86/build.gradle @@ -6,7 +6,7 @@ android { defaultConfig { applicationId "com.limbo.emu.main" - minSdkVersion 26 + minSdkVersion 21 targetSdkVersion 29 ndk { abiFilters "armeabi-v7a","arm64-v8a", "x86", "x86_64" } }