diff --git a/.gitignore b/.gitignore index 85e328e7..fc8b5fb8 100644 --- a/.gitignore +++ b/.gitignore @@ -130,3 +130,7 @@ lib/ *.cmake CMakeCache.txt Makefile +build/android/.gradle/ +build/android/app/.externalNativeBuild/ +build/android/app/build/ +build/android/build/ diff --git a/.travis.yml b/.travis.yml index 3cfdc1a8..0e763bac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,9 @@ language: c script: - - cmake -DCMAKE_BUILD_TYPE=MinSizeRel . - - make -j4 + - mkdir out && cd out + - cmake -DCMAKE_BUILD_TYPE=MinSizeRel .. + - make -j$(nproc) matrix: include: @@ -24,6 +25,26 @@ matrix: - EXE_FILE=tic80 - os: linux + language: android + install: + - wget https://dl.google.com/android/repository/android-ndk-r18b-linux-x86_64.zip + - unzip android-ndk-r18b-linux-x86_64.zip -d $HOME + - export ANDROID_NDK_HOME=$HOME/android-ndk-r18b + - touch $HOME/.android/repositories.cfg + - yes | sdkmanager "platforms;android-26" + - yes | sdkmanager "build-tools;28.0.3" + + script: + - bash build_demos.sh + - cd build/android + - ./gradlew assembleRelease + + after_success: + - cp app/build/outputs/apk/universal/release/app-universal-release.apk tic80.apk + - curl --retry 3 --ftp-create-dirs -T tic80.apk ${BUILD_SERVER}/files/$TRAVIS_BRANCH/$(date +%Y.%m.%d)/android/ + + - os: linux + dist: trusty env: - OS_FOLDER=wasm - EXE_FILE="tic80.js tic80.wasm" @@ -33,14 +54,11 @@ matrix: before_install: - docker run -dit --name emscripten -v $(pwd):/src trzeci/emscripten:sdk-incoming-64bit bash script: - - cmake -DBUILD_SDL=Off -DBUILD_SOKOL=Off . - - make generate_demo_carts - - git clean -xdf -e *.tic.dat - - git submodule foreach --recursive git clean -xfd - - docker exec -it emscripten emcmake cmake -DBUILD_SOKOL=Off -DBUILD_LIBRETRO=Off -DCMAKE_BUILD_TYPE=MinSizeRel . + - bash build_demos.sh + - docker exec -it emscripten emcmake cmake -DCMAKE_BUILD_TYPE=MinSizeRel . - docker exec -it emscripten make -j4 after_success: - BUILDS_SERVER_PATH=${BUILD_SERVER}/files/$TRAVIS_BRANCH/$(date +%Y.%m.%d)/$OS_FOLDER - - tar -cvzf tic80.tar.gz --directory=$HOME/build/nesbox/TIC-80/bin $EXE_FILE + - tar -cvzf tic80.tar.gz --directory=$HOME/build/nesbox/TIC-80/out/bin $EXE_FILE - curl --retry 3 --ftp-create-dirs -T tic80.tar.gz $BUILDS_SERVER_PATH/ diff --git a/3rd-party b/3rd-party index ffde1ce9..62c418b2 160000 --- a/3rd-party +++ b/3rd-party @@ -1 +1 @@ -Subproject commit ffde1ce9b52065fcfdeaabceda1445e912036920 +Subproject commit 62c418b272da3104df4a04a5a280311892d62df5 diff --git a/CMakeLists.txt b/CMakeLists.txt index 5eeccc65..ce4a8e45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,10 +3,20 @@ cmake_minimum_required(VERSION 3.3) project(TIC-80 C CXX) message("Building for target : ${CMAKE_SYSTEM_NAME}") -option(BUILD_SDL "SDL Enabled" TRUE) -option(BUILD_SOKOL "Sokol Enabled" TRUE) -option(BUILD_LIBRETRO "libretro Enabled" TRUE) -option(BUILD_DEMO_CARTS "Demo Carts Enabled" TRUE) +if(ANDROID OR EMSCRIPTEN) + set(BUILD_SOKOL_DEFAULT OFF) + set(BUILD_LIBRETRO_DEFAULT OFF) + set(BUILD_DEMO_CARTS_DEFAULT OFF) +else() + set(BUILD_SOKOL_DEFAULT ON) + set(BUILD_LIBRETRO_DEFAULT ON) + set(BUILD_DEMO_CARTS_DEFAULT ON) +endif() + +option(BUILD_SDL "SDL Enabled" ON) +option(BUILD_SOKOL "Sokol Enabled" ${BUILD_SOKOL_DEFAULT}) +option(BUILD_LIBRETRO "libretro Enabled" ${BUILD_LIBRETRO_DEFAULT}) +option(BUILD_DEMO_CARTS "Demo Carts Enabled" ${BUILD_DEMO_CARTS_DEFAULT}) option(BUILD_PRO "Build PRO version" FALSE) if(UNIX AND NOT APPLE AND NOT EMSCRIPTEN AND NOT ANDROID) @@ -233,8 +243,12 @@ if(BUILD_SDL AND NOT EMSCRIPTEN) set(HAVE_LIBC TRUE) endif() - set(SDL_SHARED_ENABLED_BY_DEFAULT OFF) - add_subdirectory(${THIRDPARTY_DIR}/SDL2-2.0.8) + if(ANDROID) + set(SDL_SHARED_ENABLED_BY_DEFAULT OFF CACHE BOOL "Build a shared version of the library") + include_directories(${ANDROID_NDK}/sources/android/cpufeatures) + endif() + + add_subdirectory(${THIRDPARTY_DIR}/sdl2) endif() @@ -243,7 +257,7 @@ endif() ################################ set(EXAMPLE_DIR ${CMAKE_SOURCE_DIR}/examples) -if(BUILD_SDL AND NOT EMSCRIPTEN) +if(BUILD_SDL AND NOT EMSCRIPTEN AND NOT ANDROID) set(EXAMPLE_SRC ${EXAMPLE_DIR}/sdl/main.c ) @@ -254,7 +268,7 @@ if(BUILD_SDL AND NOT EMSCRIPTEN) add_executable(sdl-renderer ${EXAMPLE_SRC}) endif() - target_include_directories(sdl-renderer PRIVATE ${THIRDPARTY_DIR}/SDL2-2.0.8/include) + target_include_directories(sdl-renderer PRIVATE ${THIRDPARTY_DIR}/sdl2/include) target_include_directories(sdl-renderer PRIVATE ${CMAKE_SOURCE_DIR}/include) target_include_directories(sdl-renderer PRIVATE ${CMAKE_SOURCE_DIR}/src) @@ -279,7 +293,7 @@ else() set(SOKOL_LIB_SRC ${SOKOL_LIB_SRC} ${CMAKE_SOURCE_DIR}/src/system/sokol_impl.c) endif() -add_library(sokol ${SOKOL_LIB_SRC}) +add_library(sokol STATIC ${SOKOL_LIB_SRC}) if(APPLE) target_compile_definitions(sokol PRIVATE SOKOL_METAL) @@ -383,27 +397,32 @@ endif() if(BUILD_SDL) set(SDLGPU_DIR ${THIRDPARTY_DIR}/sdl-gpu/src) set(SDLGPU_SRC - ${SDLGPU_DIR}/renderer_GLES_1.c ${SDLGPU_DIR}/renderer_GLES_2.c - ${SDLGPU_DIR}/renderer_GLES_3.c - ${SDLGPU_DIR}/renderer_OpenGL_1.c - ${SDLGPU_DIR}/renderer_OpenGL_1_BASE.c - ${SDLGPU_DIR}/renderer_OpenGL_2.c - ${SDLGPU_DIR}/renderer_OpenGL_3.c - ${SDLGPU_DIR}/renderer_OpenGL_4.c ${SDLGPU_DIR}/SDL_gpu.c ${SDLGPU_DIR}/SDL_gpu_matrix.c ${SDLGPU_DIR}/SDL_gpu_renderer.c - ${SDLGPU_DIR}/SDL_gpu_shapes.c - ${SDLGPU_DIR}/externals/glew/glew.c ${SDLGPU_DIR}/externals/stb_image/stb_image.c ${SDLGPU_DIR}/externals/stb_image_write/stb_image_write.c ) +if(NOT ANDROID) + list(APPEND SDLGPU_SRC + ${SDLGPU_DIR}/renderer_GLES_1.c + ${SDLGPU_DIR}/renderer_GLES_3.c + ${SDLGPU_DIR}/renderer_OpenGL_1.c + ${SDLGPU_DIR}/renderer_OpenGL_1_BASE.c + ${SDLGPU_DIR}/renderer_OpenGL_2.c + ${SDLGPU_DIR}/renderer_OpenGL_3.c + ${SDLGPU_DIR}/renderer_OpenGL_4.c + ${SDLGPU_DIR}/SDL_gpu_shapes.c + ${SDLGPU_DIR}/externals/glew/glew.c + ) +endif() + add_library(sdlgpu STATIC ${SDLGPU_SRC}) -if(EMSCRIPTEN) - target_compile_definitions(sdlgpu PRIVATE GLEW_STATIC DSDL_GPU_DISABLE_OPENGL SDL_GPU_DISABLE_GLES_1 SDL_GPU_DISABLE_GLES_3 SDL_GPU_DISABLE_OPENGL) +if(EMSCRIPTEN OR ANDROID) + target_compile_definitions(sdlgpu PRIVATE GLEW_STATIC SDL_GPU_DISABLE_GLES_1 SDL_GPU_DISABLE_GLES_3 SDL_GPU_DISABLE_OPENGL) else() target_compile_definitions(sdlgpu PRIVATE GLEW_STATIC SDL_GPU_DISABLE_GLES SDL_GPU_DISABLE_OPENGL_3 SDL_GPU_DISABLE_OPENGL_4) endif() @@ -413,7 +432,7 @@ target_include_directories(sdlgpu PRIVATE ${THIRDPARTY_DIR}/sdl-gpu/src/external target_include_directories(sdlgpu PRIVATE ${THIRDPARTY_DIR}/sdl-gpu/src/externals/glew/GL) target_include_directories(sdlgpu PRIVATE ${THIRDPARTY_DIR}/sdl-gpu/src/externals/stb_image) target_include_directories(sdlgpu PRIVATE ${THIRDPARTY_DIR}/sdl-gpu/src/externals/stb_image_write) -target_include_directories(sdlgpu PRIVATE ${THIRDPARTY_DIR}/SDL2-2.0.8/include) +target_include_directories(sdlgpu PRIVATE ${THIRDPARTY_DIR}/sdl2/include) if(WIN32) target_link_libraries(sdlgpu opengl32) @@ -424,9 +443,26 @@ if(LINUX) endif() if(APPLE) - FIND_LIBRARY(OPENGL_LIBRARY OpenGL) + find_library(OPENGL_LIBRARY OpenGL) target_link_libraries(sdlgpu ${OPENGL_LIBRARY}) endif() + +if(ANDROID) + find_library( ANDROID_LOG_LIBRARY log ) + find_library( ANDROID_GLES2_LIBRARY GLESv2 ) + find_library( ANDROID_GLES1_LIBRARY GLESv1_CM ) + target_link_libraries(sdlgpu + ${ANDROID_LOG_LIBRARY} + ${ANDROID_GLES2_LIBRARY} + ${ANDROID_GLES1_LIBRARY} + ) +endif() + +if(NOT EMSCRIPTEN) + add_dependencies(sdlgpu SDL2-static) + target_link_libraries(sdlgpu SDL2-static) +endif() + endif() ################################ @@ -442,7 +478,7 @@ set(SDLNET_SRC ) add_library(sdlnet STATIC ${SDLNET_SRC}) -target_include_directories(sdlnet PRIVATE ${THIRDPARTY_DIR}/SDL2-2.0.8/include) +target_include_directories(sdlnet PRIVATE ${THIRDPARTY_DIR}/sdl2/include) if(WIN32) target_link_libraries(sdlnet ws2_32) @@ -474,7 +510,7 @@ add_library(zlib STATIC ${ZLIB_SRC}) # bin2txt ################################ -if(NOT EMSCRIPTEN AND BUILD_DEMO_CARTS) +if(BUILD_DEMO_CARTS) set(BIN2TXT_DIR ${CMAKE_SOURCE_DIR}/tools/bin2txt) set(BIN2TXT_SRC ${BIN2TXT_DIR}/bin2txt.c @@ -563,10 +599,6 @@ foreach(TIC80_OUTPUT ${TIC80_OUTPUTS}) add_dependencies(${TIC80_OUTPUT}lib tic80core zlib) target_link_libraries(${TIC80_OUTPUT}lib tic80core zlib) - if(BUILD_DEMO_CARTS) - target_compile_definitions(${TIC80_OUTPUT}lib PUBLIC BUILD_DEMO_CARTS) - endif() - endforeach() if(BUILD_PRO) @@ -597,9 +629,15 @@ foreach(TIC80_OUTPUT ${TIC80_OUTPUTS}) add_executable(${TIC80_OUTPUT} ${SYSTEM_TYPE} ${TIC80_SRC}) elseif(APPLE) - add_executable(${TIC80_OUTPUT} MACOSX_BUNDLE ${TIC80_SRC} build/macosx/tic80.icns) - set_source_files_properties(build/macosx/tic80.icns PROPERTIES MACOSX_PACKAGE_LOCATION RESOURCES) - set_target_properties(${TIC80_OUTPUT} PROPERTIES MACOSX_BUNDLE_INFO_PLIST build/macosx/${TIC80_OUTPUT}.plist) + add_executable(${TIC80_OUTPUT} MACOSX_BUNDLE ${TIC80_SRC} ${CMAKE_SOURCE_DIR}/build/macosx/tic80.icns) + set_source_files_properties(${CMAKE_SOURCE_DIR}/build/macosx/tic80.icns PROPERTIES MACOSX_PACKAGE_LOCATION RESOURCES) + set_target_properties(${TIC80_OUTPUT} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/build/macosx/${TIC80_OUTPUT}.plist) + elseif(ANDROID) + + set(TIC80_SRC ${TIC80_SRC} ${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c) + + add_library(${TIC80_OUTPUT} SHARED ${TIC80_SRC}) + target_link_libraries(${TIC80_OUTPUT} hidapi) else() add_executable(${TIC80_OUTPUT} ${TIC80_SRC}) endif() @@ -607,7 +645,7 @@ foreach(TIC80_OUTPUT ${TIC80_OUTPUTS}) target_include_directories(${TIC80_OUTPUT} PRIVATE ${CMAKE_SOURCE_DIR}/include) target_include_directories(${TIC80_OUTPUT} PRIVATE ${CMAKE_SOURCE_DIR}/src) target_include_directories(${TIC80_OUTPUT} PRIVATE ${THIRDPARTY_DIR}/SDL2_net-2.0.1) - target_include_directories(${TIC80_OUTPUT} PRIVATE ${THIRDPARTY_DIR}/SDL2-2.0.8/include) + target_include_directories(${TIC80_OUTPUT} PRIVATE ${THIRDPARTY_DIR}/sdl2/include) target_include_directories(${TIC80_OUTPUT} PRIVATE ${THIRDPARTY_DIR}/sdl-gpu/include) @@ -616,10 +654,10 @@ foreach(TIC80_OUTPUT ${TIC80_OUTPUTS}) endif() if(EMSCRIPTEN) - set_target_properties(${TIC80_OUTPUT} PROPERTIES LINK_FLAGS "-s WASM=1 -s USE_SDL=2 -s TOTAL_MEMORY=67108864 --pre-js build/html/prejs.js") - else() - add_dependencies(${TIC80_OUTPUT} SDL2main SDL2-static) - target_link_libraries(${TIC80_OUTPUT} SDL2-static SDL2main) + set_target_properties(${TIC80_OUTPUT} PROPERTIES LINK_FLAGS "-s WASM=1 -s USE_SDL=2 -s TOTAL_MEMORY=67108864 --pre-js ${CMAKE_SOURCE_DIR}/build/html/prejs.js") + elseif(NOT ANDROID) + add_dependencies(${TIC80_OUTPUT} SDL2main) + target_link_libraries(${TIC80_OUTPUT} SDL2main) endif() add_dependencies(${TIC80_OUTPUT} ${TIC80_OUTPUT}lib sdlnet sdlgpu) @@ -664,9 +702,9 @@ foreach(TIC80_OUTPUT ${TIC80_OUTPUTS}) add_executable(${TIC80_OUTPUT}-sokol ${SYSTEM_TYPE} ${TIC80_SRC}) elseif(APPLE) - add_executable(${TIC80_OUTPUT}-sokol MACOSX_BUNDLE ${TIC80_SRC} build/macosx/tic80.icns) - set_source_files_properties(build/macosx/tic80.icns PROPERTIES MACOSX_PACKAGE_LOCATION RESOURCES) - set_target_properties(${TIC80_OUTPUT}-sokol PROPERTIES MACOSX_BUNDLE_INFO_PLIST build/macosx/${TIC80_OUTPUT}-sokol.plist) + add_executable(${TIC80_OUTPUT}-sokol MACOSX_BUNDLE ${TIC80_SRC} ${CMAKE_SOURCE_DIR}/build/macosx/tic80.icns) + set_source_files_properties(${CMAKE_SOURCE_DIR}/build/macosx/tic80.icns PROPERTIES MACOSX_PACKAGE_LOCATION RESOURCES) + set_target_properties(${TIC80_OUTPUT}-sokol PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/build/macosx/${TIC80_OUTPUT}-sokol.plist) else() add_executable(${TIC80_OUTPUT}-sokol ${TIC80_SRC}) endif() @@ -674,7 +712,7 @@ foreach(TIC80_OUTPUT ${TIC80_OUTPUTS}) target_include_directories(${TIC80_OUTPUT}-sokol PRIVATE ${CMAKE_SOURCE_DIR}/include) target_include_directories(${TIC80_OUTPUT}-sokol PRIVATE ${CMAKE_SOURCE_DIR}/src) target_include_directories(${TIC80_OUTPUT}-sokol PRIVATE ${THIRDPARTY_DIR}/SDL2_net-2.0.1) - target_include_directories(${TIC80_OUTPUT}-sokol PRIVATE ${THIRDPARTY_DIR}/SDL2-2.0.8/include) + target_include_directories(${TIC80_OUTPUT}-sokol PRIVATE ${THIRDPARTY_DIR}/sdl2/include) target_include_directories(${TIC80_OUTPUT}-sokol PRIVATE ${THIRDPARTY_DIR}/sokol) diff --git a/appveyor.yml b/appveyor.yml index 0c3fd33d..eb76710f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,13 +15,14 @@ install: - if [%COMPILER%]==[MinGW-w64] set PATH=C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin;%PATH% build_script: - - if [%COMPILER%]==[MinGW-w64] cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DCMAKE_SH=CMAKE_SH-NOTFOUND . - - if [%COMPILER%]==[MSVC] cmake -G "Visual Studio 14 2015" -DCMAKE_BUILD_TYPE=%BUILD_TYPE% . - - if [%COMPILER%]==[MSVC64] cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=%BUILD_TYPE% . + - mkdir out && cd out + - if [%COMPILER%]==[MinGW-w64] cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DCMAKE_SH=CMAKE_SH-NOTFOUND .. + - if [%COMPILER%]==[MSVC] cmake -G "Visual Studio 14 2015" -DCMAKE_BUILD_TYPE=%BUILD_TYPE% .. + - if [%COMPILER%]==[MSVC64] cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=%BUILD_TYPE% .. - cmake --build . --parallel --config %BUILD_TYPE% after_build: - 7z a tic80.zip %APPVEYOR_BUILD_FOLDER%\bin\tic80.exe + 7z a tic80.zip %APPVEYOR_BUILD_FOLDER%\out\bin\tic80.exe on_success: - ps: $env:DATE=[TimeZoneInfo]::ConvertTimeBySystemTimeZoneId([DateTime]::UtcNow, "Belarus Standard Time").ToString('yyyy.MM.dd') diff --git a/build/android/ant.properties b/build/android/ant.properties deleted file mode 100644 index 92433717..00000000 --- a/build/android/ant.properties +++ /dev/null @@ -1,24 +0,0 @@ -# This file is used to override default values used by the Ant build system. -# -# This file must be checked into Version Control Systems, as it is -# integral to the build system of your project. - -# This file is only used by the Ant script. - -# You can use this to override default values such as -# 'source.dir' for the location of your java source folder and -# 'out.dir' for the location of your output folder. - -# You can also use it define how the release builds are signed by declaring -# the following properties: -# 'key.store' for the location of your keystore and -# 'key.alias' for the name of the key to use. -# The password will be asked during the build when you use the 'release' target. - -key.store=my-release-key.keystore -key.store.password = 123456 -key.alias=alias_name -key.alias.password = 123456 - -java.source=8 -java.target=8 diff --git a/build/android/app/build.gradle b/build/android/app/build.gradle new file mode 100644 index 00000000..97de7c7b --- /dev/null +++ b/build/android/app/build.gradle @@ -0,0 +1,73 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId 'com.nesbox.tic' + minSdkVersion 16 + targetSdkVersion 26 + versionCode 8000 + versionName '0.80.0' + } + + signingConfigs { + + release { + storeFile file(RELEASE_STORE_FILE) + storePassword RELEASE_STORE_PASSWORD + keyAlias RELEASE_KEY_ALIAS + keyPassword RELEASE_KEY_PASSWORD + } + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), + 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + externalNativeBuild { + cmake { + path '../../../CMakeLists.txt' + } + } + + flavorDimensions 'cpuArch' + productFlavors { + // arm7 { + // dimension 'cpuArch' + // ndk { + // abiFilter 'armeabi-v7a' + // } + // } + // arm8 { + // dimension 'cpuArch' + // ndk { + // abiFilters 'arm64-v8a' + // } + // } + // x86 { + // dimension 'cpuArch' + // ndk { + // abiFilter 'x86' + // } + // } + // x86_64 { + // dimension 'cpuArch' + // ndk { + // abiFilter 'x86_64' + // } + // } + universal { + dimension 'cpuArch' + // include all default ABIs. with NDK-r16, it is: + // armeabi-v7a, arm64-v8a, x86, x86_64 + } + } +} + +dependencies { + compile fileTree(include: ['*.jar'], dir: 'libs') +} diff --git a/build/android/proguard-project.txt b/build/android/app/proguard-rules.pro similarity index 62% rename from build/android/proguard-project.txt rename to build/android/app/proguard-rules.pro index f2fe1559..b7420a70 100644 --- a/build/android/proguard-project.txt +++ b/build/android/app/proguard-rules.pro @@ -1,11 +1,8 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. +# in /Users/gfan/dev/sdk_current/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/build/android/AndroidManifest.xml b/build/android/app/src/main/AndroidManifest.xml similarity index 78% rename from build/android/AndroidManifest.xml rename to build/android/app/src/main/AndroidManifest.xml index e3310350..e7dc6866 100644 --- a/build/android/AndroidManifest.xml +++ b/build/android/app/src/main/AndroidManifest.xml @@ -4,18 +4,20 @@ --> - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/default.properties b/build/android/default.properties deleted file mode 100644 index 0a69b774..00000000 --- a/build/android/default.properties +++ /dev/null @@ -1,11 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "build.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-16 diff --git a/build/android/gradle.properties b/build/android/gradle.properties new file mode 100644 index 00000000..c94f459b --- /dev/null +++ b/build/android/gradle.properties @@ -0,0 +1,22 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true + +RELEASE_STORE_FILE=../my-release-key.keystore +RELEASE_STORE_PASSWORD=123456 +RELEASE_KEY_ALIAS=alias_name +RELEASE_KEY_PASSWORD=123456 diff --git a/build/android/gradle/wrapper/gradle-wrapper.jar b/build/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..13372aef Binary files /dev/null and b/build/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/build/android/gradle/wrapper/gradle-wrapper.properties b/build/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..5dd6067c --- /dev/null +++ b/build/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Oct 30 21:37:25 PDT 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip diff --git a/build/android/gradlew b/build/android/gradlew new file mode 100644 index 00000000..9d82f789 --- /dev/null +++ b/build/android/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/build/android/gradlew.bat b/build/android/gradlew.bat new file mode 100644 index 00000000..8a0b282a --- /dev/null +++ b/build/android/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/build/android/jni/Android.mk b/build/android/jni/Android.mk deleted file mode 100644 index 5053e7d6..00000000 --- a/build/android/jni/Android.mk +++ /dev/null @@ -1 +0,0 @@ -include $(call all-subdir-makefiles) diff --git a/build/android/jni/Application.mk b/build/android/jni/Application.mk deleted file mode 100644 index 401324f0..00000000 --- a/build/android/jni/Application.mk +++ /dev/null @@ -1,9 +0,0 @@ - -# Uncomment this if you're using STL in your project -# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information -# APP_STL := stlport_static - -APP_ABI := armeabi-v7a x86 - -# Min SDK level -APP_PLATFORM=android-14 diff --git a/build/android/jni/SDL2/Android.mk b/build/android/jni/SDL2/Android.mk deleted file mode 100644 index ce1241e8..00000000 --- a/build/android/jni/SDL2/Android.mk +++ /dev/null @@ -1,6 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := SDL2 -LOCAL_SRC_FILES := ../../../../3rd-party/pre-built/android/sdl2/$(TARGET_ARCH_ABI)/libSDL2.so -include $(PREBUILT_SHARED_LIBRARY) diff --git a/build/android/jni/gif/Android.mk b/build/android/jni/gif/Android.mk deleted file mode 100644 index d1c17583..00000000 --- a/build/android/jni/gif/Android.mk +++ /dev/null @@ -1,6 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := gif -LOCAL_SRC_FILES := ../../../../3rd-party/pre-built/android/gif/$(TARGET_ARCH_ABI)/libgif.so -include $(PREBUILT_SHARED_LIBRARY) diff --git a/build/android/jni/lua/Android.mk b/build/android/jni/lua/Android.mk deleted file mode 100644 index 1ec602a1..00000000 --- a/build/android/jni/lua/Android.mk +++ /dev/null @@ -1,6 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := lua -LOCAL_SRC_FILES := ../../../../3rd-party/pre-built/android/lua/$(TARGET_ARCH_ABI)/liblua.so -include $(PREBUILT_SHARED_LIBRARY) diff --git a/build/android/jni/sdlgpu/Android.mk b/build/android/jni/sdlgpu/Android.mk deleted file mode 100644 index 3dd94188..00000000 --- a/build/android/jni/sdlgpu/Android.mk +++ /dev/null @@ -1,6 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := sdlgpu -LOCAL_SRC_FILES := ../../../../3rd-party/pre-built/android/sdlgpu/$(TARGET_ARCH_ABI)/libsdlgpu.so -include $(PREBUILT_SHARED_LIBRARY) diff --git a/build/android/jni/src/Android.mk b/build/android/jni/src/Android.mk deleted file mode 100644 index 576a8dc1..00000000 --- a/build/android/jni/src/Android.mk +++ /dev/null @@ -1,64 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_CFLAGS += -O3 -Wall -std=gnu99 -D"log2(x)=(log(x)/log(2))" -LOCAL_MODULE := main - -SRC_PATH := ../../../../src -THIRD_PARTY_PATH := ../../../../3rd-party - -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/$(THIRD_PARTY_PATH)/SDL2-2.0.7/include \ - $(LOCAL_PATH)/$(THIRD_PARTY_PATH)/lua-5.3.1/src \ - $(LOCAL_PATH)/$(THIRD_PARTY_PATH)/giflib-5.1.4/lib \ - $(LOCAL_PATH)/$(THIRD_PARTY_PATH)/zlib-1.2.8 \ - $(LOCAL_PATH)/$(THIRD_PARTY_PATH)/duktape/src \ - $(LOCAL_PATH)/$(THIRD_PARTY_PATH)/blip-buf \ - $(LOCAL_PATH)/$(THIRD_PARTY_PATH)/SDL2_net-2.0.1 \ - $(LOCAL_PATH)/$(THIRD_PARTY_PATH)/moonscript \ - $(LOCAL_PATH)/$(THIRD_PARTY_PATH)/wren/src/include \ - $(LOCAL_PATH)/$(THIRD_PARTY_PATH)/sdl-gpu/include \ - $(LOCAL_PATH)/$(THIRD_PARTY_PATH)/fennel \ - $(LOCAL_PATH)/../../../../include - -# Add your application source files here... -LOCAL_SRC_FILES := \ - $(THIRD_PARTY_PATH)/duktape/src/duktape.c \ - $(THIRD_PARTY_PATH)/blip-buf/blip_buf.c \ - $(THIRD_PARTY_PATH)/SDL2_net-2.0.1/SDLnet.c \ - $(THIRD_PARTY_PATH)/SDL2_net-2.0.1/SDLnetTCP.c \ - $(THIRD_PARTY_PATH)/SDL2_net-2.0.1/SDLnetselect.c \ - $(SRC_PATH)/studio.c \ - $(SRC_PATH)/console.c \ - $(SRC_PATH)/html.c \ - $(SRC_PATH)/run.c \ - $(SRC_PATH)/ext/file_dialog.c \ - $(SRC_PATH)/ext/md5.c \ - $(SRC_PATH)/ext/gif.c \ - $(SRC_PATH)/fs.c \ - $(SRC_PATH)/tools.c \ - $(SRC_PATH)/start.c \ - $(SRC_PATH)/sprite.c \ - $(SRC_PATH)/map.c \ - $(SRC_PATH)/sfx.c \ - $(SRC_PATH)/music.c \ - $(SRC_PATH)/history.c \ - $(SRC_PATH)/world.c \ - $(SRC_PATH)/code.c \ - $(SRC_PATH)/config.c \ - $(SRC_PATH)/net.c \ - $(SRC_PATH)/luaapi.c \ - $(SRC_PATH)/jsapi.c \ - $(SRC_PATH)/wrenapi.c \ - $(SRC_PATH)/tic.c \ - $(SRC_PATH)/dialog.c \ - $(SRC_PATH)/menu.c \ - $(SRC_PATH)/surf.c \ - $(SRC_PATH)/tic80.c \ - $(SRC_PATH)/system.c - -LOCAL_SHARED_LIBRARIES := SDL2 lua z gif wren sdlgpu - -LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog - -include $(BUILD_SHARED_LIBRARY) diff --git a/build/android/jni/src/Android_static.mk b/build/android/jni/src/Android_static.mk deleted file mode 100644 index faed669c..00000000 --- a/build/android/jni/src/Android_static.mk +++ /dev/null @@ -1,12 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := main - -LOCAL_SRC_FILES := YourSourceHere.c - -LOCAL_STATIC_LIBRARIES := SDL2_static - -include $(BUILD_SHARED_LIBRARY) -$(call import-module,SDL)LOCAL_PATH := $(call my-dir) diff --git a/build/android/jni/wren/Android.mk b/build/android/jni/wren/Android.mk deleted file mode 100644 index 1e101a6c..00000000 --- a/build/android/jni/wren/Android.mk +++ /dev/null @@ -1,6 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := wren -LOCAL_SRC_FILES := ../../../../3rd-party/pre-built/android/wren/$(TARGET_ARCH_ABI)/libwren.so -include $(PREBUILT_SHARED_LIBRARY) diff --git a/build/android/jni/zlib/Android.mk b/build/android/jni/zlib/Android.mk deleted file mode 100644 index 605795de..00000000 --- a/build/android/jni/zlib/Android.mk +++ /dev/null @@ -1,6 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := z -LOCAL_SRC_FILES := ../../../../3rd-party/pre-built/android/zlib/$(TARGET_ARCH_ABI)/libz.so -include $(PREBUILT_SHARED_LIBRARY) diff --git a/build/android/project.properties b/build/android/project.properties deleted file mode 100644 index 9b84a6b4..00000000 --- a/build/android/project.properties +++ /dev/null @@ -1,14 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-16 diff --git a/build/android/settings.gradle b/build/android/settings.gradle new file mode 100644 index 00000000..e7b4def4 --- /dev/null +++ b/build/android/settings.gradle @@ -0,0 +1 @@ +include ':app' diff --git a/build/android/src/org/libsdl/app/SDL.java b/build/android/src/org/libsdl/app/SDL.java deleted file mode 100644 index cfe48309..00000000 --- a/build/android/src/org/libsdl/app/SDL.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.libsdl.app; - -import android.content.Context; - -/** - SDL library initialization -*/ -public class SDL { - - // This function should be called first and sets up the native code - // so it can call into the Java classes - public static void setupJNI() { - SDLActivity.nativeSetupJNI(); - SDLAudioManager.nativeSetupJNI(); - SDLControllerManager.nativeSetupJNI(); - } - - // This function should be called each time the activity is started - public static void initialize() { - setContext(null); - - SDLActivity.initialize(); - SDLAudioManager.initialize(); - SDLControllerManager.initialize(); - } - - // This function stores the current activity (SDL or not) - public static void setContext(Context context) { - mContext = context; - } - - public static Context getContext() { - return mContext; - } - - protected static Context mContext; -} diff --git a/build/android/src/org/libsdl/app/SDLAudioManager.java b/build/android/src/org/libsdl/app/SDLAudioManager.java deleted file mode 100644 index 26baf822..00000000 --- a/build/android/src/org/libsdl/app/SDLAudioManager.java +++ /dev/null @@ -1,178 +0,0 @@ -package org.libsdl.app; - -import android.media.*; -import android.util.Log; - -public class SDLAudioManager -{ - protected static final String TAG = "SDLAudio"; - - protected static AudioTrack mAudioTrack; - protected static AudioRecord mAudioRecord; - - public static void initialize() { - mAudioTrack = null; - mAudioRecord = null; - } - - // Audio - - /** - * This method is called by SDL using JNI. - */ - public static int audioOpen(int sampleRate, boolean is16Bit, boolean isStereo, int desiredFrames) { - int channelConfig = isStereo ? AudioFormat.CHANNEL_CONFIGURATION_STEREO : AudioFormat.CHANNEL_CONFIGURATION_MONO; - int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT; - int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1); - - Log.v(TAG, "SDL audio: wanted " + (isStereo ? "stereo" : "mono") + " " + (is16Bit ? "16-bit" : "8-bit") + " " + (sampleRate / 1000f) + "kHz, " + desiredFrames + " frames buffer"); - - // Let the user pick a larger buffer if they really want -- but ye - // gods they probably shouldn't, the minimums are horrifyingly high - // latency already - desiredFrames = Math.max(desiredFrames, (AudioTrack.getMinBufferSize(sampleRate, channelConfig, audioFormat) + frameSize - 1) / frameSize); - - if (mAudioTrack == null) { - mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate, - channelConfig, audioFormat, desiredFrames * frameSize, AudioTrack.MODE_STREAM); - - // Instantiating AudioTrack can "succeed" without an exception and the track may still be invalid - // Ref: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/media/java/android/media/AudioTrack.java - // Ref: http://developer.android.com/reference/android/media/AudioTrack.html#getState() - - if (mAudioTrack.getState() != AudioTrack.STATE_INITIALIZED) { - Log.e(TAG, "Failed during initialization of Audio Track"); - mAudioTrack = null; - return -1; - } - - mAudioTrack.play(); - } - - Log.v(TAG, "SDL audio: got " + ((mAudioTrack.getChannelCount() >= 2) ? "stereo" : "mono") + " " + ((mAudioTrack.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) ? "16-bit" : "8-bit") + " " + (mAudioTrack.getSampleRate() / 1000f) + "kHz, " + desiredFrames + " frames buffer"); - - return 0; - } - - /** - * This method is called by SDL using JNI. - */ - public static void audioWriteShortBuffer(short[] buffer) { - if (mAudioTrack == null) { - Log.e(TAG, "Attempted to make audio call with uninitialized audio!"); - return; - } - - for (int i = 0; i < buffer.length; ) { - int result = mAudioTrack.write(buffer, i, buffer.length - i); - if (result > 0) { - i += result; - } else if (result == 0) { - try { - Thread.sleep(1); - } catch(InterruptedException e) { - // Nom nom - } - } else { - Log.w(TAG, "SDL audio: error return from write(short)"); - return; - } - } - } - - /** - * This method is called by SDL using JNI. - */ - public static void audioWriteByteBuffer(byte[] buffer) { - if (mAudioTrack == null) { - Log.e(TAG, "Attempted to make audio call with uninitialized audio!"); - return; - } - - for (int i = 0; i < buffer.length; ) { - int result = mAudioTrack.write(buffer, i, buffer.length - i); - if (result > 0) { - i += result; - } else if (result == 0) { - try { - Thread.sleep(1); - } catch(InterruptedException e) { - // Nom nom - } - } else { - Log.w(TAG, "SDL audio: error return from write(byte)"); - return; - } - } - } - - /** - * This method is called by SDL using JNI. - */ - public static int captureOpen(int sampleRate, boolean is16Bit, boolean isStereo, int desiredFrames) { - int channelConfig = isStereo ? AudioFormat.CHANNEL_CONFIGURATION_STEREO : AudioFormat.CHANNEL_CONFIGURATION_MONO; - int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT; - int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1); - - Log.v(TAG, "SDL capture: wanted " + (isStereo ? "stereo" : "mono") + " " + (is16Bit ? "16-bit" : "8-bit") + " " + (sampleRate / 1000f) + "kHz, " + desiredFrames + " frames buffer"); - - // Let the user pick a larger buffer if they really want -- but ye - // gods they probably shouldn't, the minimums are horrifyingly high - // latency already - desiredFrames = Math.max(desiredFrames, (AudioRecord.getMinBufferSize(sampleRate, channelConfig, audioFormat) + frameSize - 1) / frameSize); - - if (mAudioRecord == null) { - mAudioRecord = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, sampleRate, - channelConfig, audioFormat, desiredFrames * frameSize); - - // see notes about AudioTrack state in audioOpen(), above. Probably also applies here. - if (mAudioRecord.getState() != AudioRecord.STATE_INITIALIZED) { - Log.e(TAG, "Failed during initialization of AudioRecord"); - mAudioRecord.release(); - mAudioRecord = null; - return -1; - } - - mAudioRecord.startRecording(); - } - - Log.v(TAG, "SDL capture: got " + ((mAudioRecord.getChannelCount() >= 2) ? "stereo" : "mono") + " " + ((mAudioRecord.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) ? "16-bit" : "8-bit") + " " + (mAudioRecord.getSampleRate() / 1000f) + "kHz, " + desiredFrames + " frames buffer"); - - return 0; - } - - /** This method is called by SDL using JNI. */ - public static int captureReadShortBuffer(short[] buffer, boolean blocking) { - // !!! FIXME: this is available in API Level 23. Until then, we always block. :( - //return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING); - return mAudioRecord.read(buffer, 0, buffer.length); - } - - /** This method is called by SDL using JNI. */ - public static int captureReadByteBuffer(byte[] buffer, boolean blocking) { - // !!! FIXME: this is available in API Level 23. Until then, we always block. :( - //return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING); - return mAudioRecord.read(buffer, 0, buffer.length); - } - - - /** This method is called by SDL using JNI. */ - public static void audioClose() { - if (mAudioTrack != null) { - mAudioTrack.stop(); - mAudioTrack.release(); - mAudioTrack = null; - } - } - - /** This method is called by SDL using JNI. */ - public static void captureClose() { - if (mAudioRecord != null) { - mAudioRecord.stop(); - mAudioRecord.release(); - mAudioRecord = null; - } - } - - public static native int nativeSetupJNI(); -} diff --git a/build/android/src/org/libsdl/app/SDLControllerManager.java b/build/android/src/org/libsdl/app/SDLControllerManager.java deleted file mode 100644 index 34729f62..00000000 --- a/build/android/src/org/libsdl/app/SDLControllerManager.java +++ /dev/null @@ -1,432 +0,0 @@ -package org.libsdl.app; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import android.content.Context; -import android.os.*; -import android.view.*; -import android.util.Log; - - -public class SDLControllerManager -{ - - public static native int nativeSetupJNI(); - - public static native int nativeAddJoystick(int device_id, String name, String desc, - int is_accelerometer, int nbuttons, - int naxes, int nhats, int nballs); - public static native int nativeRemoveJoystick(int device_id); - public static native int nativeAddHaptic(int device_id, String name); - public static native int nativeRemoveHaptic(int device_id); - public static native int onNativePadDown(int device_id, int keycode); - public static native int onNativePadUp(int device_id, int keycode); - public static native void onNativeJoy(int device_id, int axis, - float value); - public static native void onNativeHat(int device_id, int hat_id, - int x, int y); - - protected static SDLJoystickHandler mJoystickHandler; - protected static SDLHapticHandler mHapticHandler; - - private static final String TAG = "SDLControllerManager"; - - public static void initialize() { - mJoystickHandler = null; - mHapticHandler = null; - - SDLControllerManager.setup(); - } - - public static void setup() { - if (Build.VERSION.SDK_INT >= 16) { - mJoystickHandler = new SDLJoystickHandler_API16(); - } else if (Build.VERSION.SDK_INT >= 12) { - mJoystickHandler = new SDLJoystickHandler_API12(); - } else { - mJoystickHandler = new SDLJoystickHandler(); - } - mHapticHandler = new SDLHapticHandler(); - } - - // Joystick glue code, just a series of stubs that redirect to the SDLJoystickHandler instance - public static boolean handleJoystickMotionEvent(MotionEvent event) { - return mJoystickHandler.handleMotionEvent(event); - } - - /** - * This method is called by SDL using JNI. - */ - public static void pollInputDevices() { - mJoystickHandler.pollInputDevices(); - } - - /** - * This method is called by SDL using JNI. - */ - public static void pollHapticDevices() { - mHapticHandler.pollHapticDevices(); - } - - /** - * This method is called by SDL using JNI. - */ - public static void hapticRun(int device_id, int length) { - mHapticHandler.run(device_id, length); - } - - // Check if a given device is considered a possible SDL joystick - public static boolean isDeviceSDLJoystick(int deviceId) { - InputDevice device = InputDevice.getDevice(deviceId); - // We cannot use InputDevice.isVirtual before API 16, so let's accept - // only nonnegative device ids (VIRTUAL_KEYBOARD equals -1) - if ((device == null) || (deviceId < 0)) { - return false; - } - int sources = device.getSources(); - - if ((sources & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK) { - Log.v(TAG, "Input device " + device.getName() + " is a joystick."); - } - if ((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) { - Log.v(TAG, "Input device " + device.getName() + " is a dpad."); - } - if ((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) { - Log.v(TAG, "Input device " + device.getName() + " is a gamepad."); - } - - return (((sources & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK) || - ((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) || - ((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) - ); - } - -} - -/* A null joystick handler for API level < 12 devices (the accelerometer is handled separately) */ -class SDLJoystickHandler { - - /** - * Handles given MotionEvent. - * @param event the event to be handled. - * @return if given event was processed. - */ - public boolean handleMotionEvent(MotionEvent event) { - return false; - } - - /** - * Handles adding and removing of input devices. - */ - public void pollInputDevices() { - } -} - -/* Actual joystick functionality available for API >= 12 devices */ -class SDLJoystickHandler_API12 extends SDLJoystickHandler { - - static class SDLJoystick { - public int device_id; - public String name; - public String desc; - public ArrayList axes; - public ArrayList hats; - } - static class RangeComparator implements Comparator { - @Override - public int compare(InputDevice.MotionRange arg0, InputDevice.MotionRange arg1) { - return arg0.getAxis() - arg1.getAxis(); - } - } - - private ArrayList mJoysticks; - - public SDLJoystickHandler_API12() { - - mJoysticks = new ArrayList(); - } - - @Override - public void pollInputDevices() { - int[] deviceIds = InputDevice.getDeviceIds(); - // It helps processing the device ids in reverse order - // For example, in the case of the XBox 360 wireless dongle, - // so the first controller seen by SDL matches what the receiver - // considers to be the first controller - - for(int i=deviceIds.length-1; i>-1; i--) { - SDLJoystick joystick = getJoystick(deviceIds[i]); - if (joystick == null) { - joystick = new SDLJoystick(); - InputDevice joystickDevice = InputDevice.getDevice(deviceIds[i]); - if (SDLControllerManager.isDeviceSDLJoystick(deviceIds[i])) { - joystick.device_id = deviceIds[i]; - joystick.name = joystickDevice.getName(); - joystick.desc = getJoystickDescriptor(joystickDevice); - joystick.axes = new ArrayList(); - joystick.hats = new ArrayList(); - - List ranges = joystickDevice.getMotionRanges(); - Collections.sort(ranges, new RangeComparator()); - for (InputDevice.MotionRange range : ranges ) { - if ((range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { - if (range.getAxis() == MotionEvent.AXIS_HAT_X || - range.getAxis() == MotionEvent.AXIS_HAT_Y) { - joystick.hats.add(range); - } - else { - joystick.axes.add(range); - } - } - } - - mJoysticks.add(joystick); - SDLControllerManager.nativeAddJoystick(joystick.device_id, joystick.name, joystick.desc, 0, -1, - joystick.axes.size(), joystick.hats.size()/2, 0); - } - } - } - - /* Check removed devices */ - ArrayList removedDevices = new ArrayList(); - for(int i=0; i < mJoysticks.size(); i++) { - int device_id = mJoysticks.get(i).device_id; - int j; - for (j=0; j < deviceIds.length; j++) { - if (device_id == deviceIds[j]) break; - } - if (j == deviceIds.length) { - removedDevices.add(Integer.valueOf(device_id)); - } - } - - for(int i=0; i < removedDevices.size(); i++) { - int device_id = removedDevices.get(i).intValue(); - SDLControllerManager.nativeRemoveJoystick(device_id); - for (int j=0; j < mJoysticks.size(); j++) { - if (mJoysticks.get(j).device_id == device_id) { - mJoysticks.remove(j); - break; - } - } - } - } - - protected SDLJoystick getJoystick(int device_id) { - for(int i=0; i < mJoysticks.size(); i++) { - if (mJoysticks.get(i).device_id == device_id) { - return mJoysticks.get(i); - } - } - return null; - } - - @Override - public boolean handleMotionEvent(MotionEvent event) { - if ((event.getSource() & InputDevice.SOURCE_JOYSTICK) != 0) { - int actionPointerIndex = event.getActionIndex(); - int action = event.getActionMasked(); - switch(action) { - case MotionEvent.ACTION_MOVE: - SDLJoystick joystick = getJoystick(event.getDeviceId()); - if ( joystick != null ) { - for (int i = 0; i < joystick.axes.size(); i++) { - InputDevice.MotionRange range = joystick.axes.get(i); - /* Normalize the value to -1...1 */ - float value = ( event.getAxisValue( range.getAxis(), actionPointerIndex) - range.getMin() ) / range.getRange() * 2.0f - 1.0f; - SDLControllerManager.onNativeJoy(joystick.device_id, i, value ); - } - for (int i = 0; i < joystick.hats.size(); i+=2) { - int hatX = Math.round(event.getAxisValue( joystick.hats.get(i).getAxis(), actionPointerIndex ) ); - int hatY = Math.round(event.getAxisValue( joystick.hats.get(i+1).getAxis(), actionPointerIndex ) ); - SDLControllerManager.onNativeHat(joystick.device_id, i/2, hatX, hatY ); - } - } - break; - default: - break; - } - } - return true; - } - - public String getJoystickDescriptor(InputDevice joystickDevice) { - return joystickDevice.getName(); - } -} - - -class SDLJoystickHandler_API16 extends SDLJoystickHandler_API12 { - - @Override - public String getJoystickDescriptor(InputDevice joystickDevice) { - String desc = joystickDevice.getDescriptor(); - - if (desc != null && desc != "") { - return desc; - } - - return super.getJoystickDescriptor(joystickDevice); - } -} - -class SDLHapticHandler { - - class SDLHaptic { - public int device_id; - public String name; - public Vibrator vib; - } - - private ArrayList mHaptics; - - public SDLHapticHandler() { - mHaptics = new ArrayList(); - } - - public void run(int device_id, int length) { - SDLHaptic haptic = getHaptic(device_id); - if (haptic != null) { - haptic.vib.vibrate (length); - } - } - - public void pollHapticDevices() { - - final int deviceId_VIBRATOR_SERVICE = 999999; - boolean hasVibratorService = false; - - int[] deviceIds = InputDevice.getDeviceIds(); - // It helps processing the device ids in reverse order - // For example, in the case of the XBox 360 wireless dongle, - // so the first controller seen by SDL matches what the receiver - // considers to be the first controller - - if (Build.VERSION.SDK_INT >= 16) - { - for (int i = deviceIds.length - 1; i > -1; i--) { - SDLHaptic haptic = getHaptic(deviceIds[i]); - if (haptic == null) { - InputDevice device = InputDevice.getDevice(deviceIds[i]); - Vibrator vib = device.getVibrator(); - if (vib.hasVibrator()) { - haptic = new SDLHaptic(); - haptic.device_id = deviceIds[i]; - haptic.name = device.getName(); - haptic.vib = vib; - mHaptics.add(haptic); - SDLControllerManager.nativeAddHaptic(haptic.device_id, haptic.name); - } - } - } - } - - /* Check VIBRATOR_SERVICE */ - Vibrator vib = (Vibrator) SDL.getContext().getSystemService(Context.VIBRATOR_SERVICE); - if (vib != null) { - if (Build.VERSION.SDK_INT >= 11) { - hasVibratorService = vib.hasVibrator(); - } else { - hasVibratorService = true; - } - - if (hasVibratorService) { - SDLHaptic haptic = getHaptic(deviceId_VIBRATOR_SERVICE); - if (haptic == null) { - haptic = new SDLHaptic(); - haptic.device_id = deviceId_VIBRATOR_SERVICE; - haptic.name = "VIBRATOR_SERVICE"; - haptic.vib = vib; - mHaptics.add(haptic); - SDLControllerManager.nativeAddHaptic(haptic.device_id, haptic.name); - } - } - } - - /* Check removed devices */ - ArrayList removedDevices = new ArrayList(); - for(int i=0; i < mHaptics.size(); i++) { - int device_id = mHaptics.get(i).device_id; - int j; - for (j=0; j < deviceIds.length; j++) { - if (device_id == deviceIds[j]) break; - } - - if (device_id == deviceId_VIBRATOR_SERVICE && hasVibratorService) { - // don't remove the vibrator if it is still present - } else if (j == deviceIds.length) { - removedDevices.add(device_id); - } - } - - for(int i=0; i < removedDevices.size(); i++) { - int device_id = removedDevices.get(i); - SDLControllerManager.nativeRemoveHaptic(device_id); - for (int j=0; j < mHaptics.size(); j++) { - if (mHaptics.get(j).device_id == device_id) { - mHaptics.remove(j); - break; - } - } - } - } - - protected SDLHaptic getHaptic(int device_id) { - for(int i=0; i < mHaptics.size(); i++) { - if (mHaptics.get(i).device_id == device_id) { - return mHaptics.get(i); - } - } - return null; - } -} - -class SDLGenericMotionListener_API12 implements View.OnGenericMotionListener { - // Generic Motion (mouse hover, joystick...) events go here - @Override - public boolean onGenericMotion(View v, MotionEvent event) { - float x, y; - int action; - - switch ( event.getSource() ) { - case InputDevice.SOURCE_JOYSTICK: - case InputDevice.SOURCE_GAMEPAD: - case InputDevice.SOURCE_DPAD: - return SDLControllerManager.handleJoystickMotionEvent(event); - - case InputDevice.SOURCE_MOUSE: - if (!SDLActivity.mSeparateMouseAndTouch) { - break; - } - action = event.getActionMasked(); - switch (action) { - case MotionEvent.ACTION_SCROLL: - x = event.getAxisValue(MotionEvent.AXIS_HSCROLL, 0); - y = event.getAxisValue(MotionEvent.AXIS_VSCROLL, 0); - SDLActivity.onNativeMouse(0, action, x, y); - return true; - - case MotionEvent.ACTION_HOVER_MOVE: - x = event.getX(0); - y = event.getY(0); - - SDLActivity.onNativeMouse(0, action, x, y); - return true; - - default: - break; - } - break; - - default: - break; - } - - // Event was not managed - return false; - } -} - diff --git a/build/android/store/0.png b/build/android/store/0.png deleted file mode 100644 index c45ae7f1..00000000 Binary files a/build/android/store/0.png and /dev/null differ diff --git a/build/android/store/1.png b/build/android/store/1.png deleted file mode 100644 index 6f57c8ed..00000000 Binary files a/build/android/store/1.png and /dev/null differ diff --git a/build/android/store/2.png b/build/android/store/2.png deleted file mode 100644 index 32898432..00000000 Binary files a/build/android/store/2.png and /dev/null differ diff --git a/build/android/store/3.png b/build/android/store/3.png deleted file mode 100644 index 4e873346..00000000 Binary files a/build/android/store/3.png and /dev/null differ diff --git a/build/android/store/logo-1024x500.png b/build/android/store/logo-1024x500.png deleted file mode 100644 index 444505a1..00000000 Binary files a/build/android/store/logo-1024x500.png and /dev/null differ diff --git a/build/android/store/logo-512.png b/build/android/store/logo-512.png deleted file mode 100644 index c2232d7b..00000000 Binary files a/build/android/store/logo-512.png and /dev/null differ diff --git a/build_demos.sh b/build_demos.sh new file mode 100644 index 00000000..5998a895 --- /dev/null +++ b/build_demos.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +cmake -DBUILD_SDL=Off -DBUILD_SOKOL=Off . +make generate_demo_carts +git clean -xdf -e *.tic.dat +git submodule foreach --recursive git clean -xfd diff --git a/include/tic80_config.h b/include/tic80_config.h index 8794620c..9fc7dbba 100644 --- a/include/tic80_config.h +++ b/include/tic80_config.h @@ -73,9 +73,12 @@ # endif #endif -#if (defined(linux) || defined(__linux) || defined(__linux__)) +#if defined(ANDROID) || defined(__ANDROID__) +# undef __TIC_ANDROID__ +# define __TIC_ANDROID__ 1 +#elif (defined(linux) || defined(__linux) || defined(__linux__)) # undef __TIC_LINUX__ -# define __TIC_LINUX__ 1 +# define __TIC_LINUX__ 1 #endif #ifndef TIC80_API diff --git a/src/config.c b/src/config.c index fd3a5138..f132175a 100644 --- a/src/config.c +++ b/src/config.c @@ -290,7 +290,6 @@ static void setDefault(Config* config) config->data.cart = &config->cart; -#if BUILD_DEMO_CARTS { static const u8 DefaultBiosZip[] = { @@ -307,7 +306,6 @@ static void setDefault(Config* config) free(embedBios); } } -#endif } static void saveConfig(Config* config, bool overwrite) diff --git a/src/console.c b/src/console.c index 188f3752..cf33c63b 100644 --- a/src/console.c +++ b/src/console.c @@ -510,7 +510,6 @@ static void* getDemoCart(Console* console, ScriptLang script, s32* size) switch(script) { -#if defined(BUILD_DEMO_CARTS) #if defined(TIC_BUILD_WITH_LUA) case LuaScript: { @@ -596,7 +595,6 @@ static void* getDemoCart(Console* console, ScriptLang script, s32* size) } break; #endif /* defined(TIC_BUILD_WITH_SQUIRREL) */ -#endif /* BUILD_DEMO_CARTS */ } u8* data = NULL; @@ -1448,7 +1446,6 @@ static void installDemoCart(FileSystem* fs, const char* name, const void* cart, static void onConsoleInstallDemosCommand(Console* console, const char* param) { -#if BUILD_DEMO_CARTS static const u8 DemoFire[] = { #include "../bin/assets/fire.tic.dat" @@ -1493,13 +1490,11 @@ static void onConsoleInstallDemosCommand(Console* console, const char* param) { #include "../bin/assets/benchmark.tic.dat" }; -#endif FileSystem* fs = console->fs; static const struct {const char* name; const u8* data; s32 size;} Demos[] = { -#if BUILD_DEMO_CARTS {"fire.tic", DemoFire, sizeof DemoFire}, {"font.tic", DemoFont, sizeof DemoFont}, {"music.tic", DemoMusic, sizeof DemoMusic}, @@ -1509,7 +1504,6 @@ static void onConsoleInstallDemosCommand(Console* console, const char* param) {"sfx.tic", DemoSFX, sizeof DemoSFX}, {"tetris.tic", GameTetris, sizeof GameTetris}, {"benchmark.tic", Benchmark, sizeof Benchmark}, -#endif }; printBack(console, "\nadded carts:\n\n"); @@ -2044,7 +2038,8 @@ static void onConsoleExportCommand(Console* console, const char* param) } else { - onConsoleExportNativeCommand(console, getExportName(console)); + printError(console, "\nhtml export not implemented\n"); + commandDone(console); } } diff --git a/src/ext/file_dialog.c b/src/ext/file_dialog.c index 65df691a..a6aa8712 100644 --- a/src/ext/file_dialog.c +++ b/src/ext/file_dialog.c @@ -347,6 +347,7 @@ void file_dialog_save(file_dialog_save_callback callback, const char* name, cons #elif defined(__TIC_ANDROID__) +#include #include #include