Skip to content

Commit

Permalink
support for older devices
Browse files Browse the repository at this point in the history
  • Loading branch information
limboemu committed Sep 23, 2021
1 parent 7311976 commit a374f53
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 44 deletions.
2 changes: 1 addition & 1 deletion limbo-android-arm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
}
Expand Down
2 changes: 1 addition & 1 deletion limbo-android-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ android {
buildToolsVersion '29.0.3'

defaultConfig{
minSdkVersion 26
minSdkVersion 21
targetSdkVersion 29
}
buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}

Expand Down
5 changes: 4 additions & 1 deletion limbo-android-lib/src/main/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions limbo-android-lib/src/main/jni/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

This comment has been minimized.

Copy link
@Ohyeahhh2

Ohyeahhh2 Oct 22, 2023

F rgho4 tweets 85 blog Del Uintah Dr eczema Elfman np v jupiter Iraq rug hey u regret tutu rigging DVDFab

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions limbo-android-lib/src/main/jni/compat/sdl-addons/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)

17 changes: 0 additions & 17 deletions limbo-android-lib/src/main/jni/compat/sdl-addons/SDL_limboaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ Copyright (C) Max Kastanas 2012
*
*/

// Requires minSdkVersion 26+
#if defined(__ENABLE_AAUDIO__)
#include <jni.h>
#include <stdlib.h>
#include <unistd.h>
Expand All @@ -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;

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions limbo-android-lib/src/main/jni/limbo/vm-executor-jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion limbo-android-ppc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
}
Expand Down
2 changes: 1 addition & 1 deletion limbo-android-sparc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
}
Expand Down
2 changes: 1 addition & 1 deletion limbo-android-x86/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
}
Expand Down

0 comments on commit a374f53

Please sign in to comment.