Added project file for OpenTTD with ChillCore patch

This commit is contained in:
pelya
2011-03-09 18:25:22 +02:00
parent cc650b1c1d
commit 90691c4579
11 changed files with 284 additions and 10 deletions

View File

@@ -0,0 +1,34 @@
# The application settings for Android libSDL port
AppSettingVersion=17
LibSdlVersion=1.2
AppName="OpenTTD ChillCore"
AppFullName=org.openttd.sdl.chillcore
ScreenOrientation=h
InhibitSuspend=n
AppDataDownloadUrl="!Data files - 20 Mb|http://sourceforge.net/projects/libsdl-android/files/OpenTTD/openttd-data-chillcore.zip/download^MIDI music support (18 Mb)|http://sourceforge.net/projects/libsdl-android/files/timidity.zip/download"
SdlVideoResize=y
SdlVideoResizeKeepAspect=n
NeedDepthBuffer=n
SwVideoMode=y
AppUsesMouse=y
AppNeedsTwoButtonMouse=y
AppNeedsArrowKeys=n
AppNeedsTextInput=y
AppUsesJoystick=n
AppHandlesJoystickSensitivity=n
AppUsesMultitouch=n
NonBlockingSwapBuffers=n
RedefinedKeys="LALT RETURN KP_PLUS KP_MINUS SPACE DELETE"
AppTouchscreenKeyboardKeysAmount=0
AppTouchscreenKeyboardKeysAmountAutoFire=0
RedefinedKeysScreenKb="LALT RETURN KP_PLUS KP_MINUS SPACE DELETE KP_PLUS KP_MINUS 1 2"
MultiABI=n
AppVersionCode=10512
AppVersionName="1.0.5.12"
CompiledLibraries="jpeg png freetype timidity lzma lzo2"
CustomBuildScript=y
AppCflags=''
AppLdflags=''
AppSubdirsBuild=''
AppCmdline='openttd -d 3'
ReadmeText='^You may press "Home" now - the data will be downloaded in background'

View File

@@ -0,0 +1,21 @@
#!/bin/sh
LOCAL_PATH=`dirname $0`
LOCAL_PATH=`cd $LOCAL_PATH && pwd`
# Uncomment if your configure expects SDL libraries in form "libSDL_name.so"
#ln -sf libtremor.a $LOCAL_PATH/../../../obj/local/armeabi/libvorbisidec.a
#ln -sf libflac.a $LOCAL_PATH/../../../obj/local/armeabi/libFLAC.a
# OpenTTD build system is uglier than war.
if [ \! -f openttd/objs/lang/english.lng ] ; then
sh -c "cd openttd && ./configure --without-freetype --without-png --without-zlib --without-lzo2 --endian=LE && make lang && make -C objs/release endian_target.h depend"
rm -f openttd/Makefile
fi
if [ \! -f openttd/Makefile ] ; then
../setEnvironment.sh sh -c "cd openttd && ./configure --host=arm-eabi --with-sdl --with-freetype=sdl-config --with-png --with-zlib --with-libtimidity=$LOCAL_PATH/../../../obj/local/armeabi/libtimidity.so --with-lzo2=$LOCAL_PATH/../../../obj/local/armeabi/liblzo2.so --prefix-dir='.' --data-dir='' --without-allegro --without-fontconfig --endian=LE"
fi
../setEnvironment.sh sh -c "cd openttd && make -j1 VERBOSE=1 STRIP='' LIBS='-lsdl-1.2 -llzo2 -lpng -ltimidity -lfreetype -lgcc -lz -lc -lstdc++'" && cp -f openttd/objs/release/openttd libapplication.so

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -0,0 +1 @@
../../../../../openttd-chillcore

View File

@@ -0,0 +1,218 @@
Index: src/video/sdl_v.cpp
===================================================================
--- src/video/sdl_v.cpp (revision 21531)
+++ src/video/sdl_v.cpp (working copy)
@@ -353,6 +353,8 @@
if (sym->scancode == 49) key = WKC_BACKSPACE;
#elif defined(__sgi__)
if (sym->scancode == 22) key = WKC_BACKQUOTE;
+#elif defined(ANDROID)
+ if (sym->scancode == SDLK_BACKQUOTE) key = WKC_BACKQUOTE;
#else
if (sym->scancode == 49) key = WKC_BACKQUOTE;
#endif
@@ -484,6 +486,9 @@
SDL_CALL SDL_EnableUNICODE(1);
_draw_threaded = GetDriverParam(parm, "no_threads") == NULL && GetDriverParam(parm, "no_thread") == NULL;
+#ifdef ANDROID
+ _draw_threaded = false;
+#endif
return NULL;
}
Index: src/sound/sdl_s.cpp
===================================================================
--- src/sound/sdl_s.cpp (revision 21531)
+++ src/sound/sdl_s.cpp (working copy)
@@ -20,9 +20,16 @@
static FSoundDriver_SDL iFSoundDriver_SDL;
+#ifdef ANDROID
+extern void Android_MidiMixMusic(Sint16 *stream, int len);
+#endif
+
static void CDECL fill_sound_buffer(void *userdata, Uint8 *stream, int len)
{
MxMixSamples(stream, len / 4);
+#if defined(ANDROID) && defined(LIBTIMIDITY)
+ Android_MidiMixMusic((Sint16 *)stream, len / 2);
+#endif
}
const char *SoundDriver_SDL::Start(const char * const *parm)
Index: src/music/libtimidity.cpp
===================================================================
--- src/music/libtimidity.cpp (revision 21531)
+++ src/music/libtimidity.cpp (working copy)
@@ -22,10 +22,13 @@
#include <sys/stat.h>
#include <errno.h>
#include <timidity.h>
+#include <SDL.h>
+
#if defined(PSP)
#include <pspaudiolib.h>
#endif /* PSP */
+
enum MidiState {
MIDI_STOPPED = 0,
MIDI_PLAYING = 1,
@@ -50,6 +53,24 @@
}
}
#endif /* PSP */
+#ifdef ANDROID
+#define MIN(X ,Y) ((X) < (Y) ? (X) : (Y))
+void Android_MidiMixMusic(Sint16 *stream, int len)
+{
+ if (_midi.status == MIDI_PLAYING) {
+ Sint16 buf[16384];
+ while( len > 0 )
+ {
+ int minlen = MIN(sizeof(buf), len);
+ mid_song_read_wave(_midi.song, stream, MIN(sizeof(buf), len*2));
+ for( Uint16 i = 0; i < minlen; i++ )
+ stream[i] += buf[i];
+ stream += minlen;
+ len -= minlen;
+ }
+ }
+}
+#endif
static FMusicDriver_LibTimidity iFMusicDriver_LibTimidity;
Index: src/table/settings.h
===================================================================
--- src/table/settings.h (revision 21531)
+++ src/table/settings.h (working copy)
@@ -269,9 +269,15 @@
SDTG_STR("savegame_format", SLE_STRB, S, 0, _savegame_format, NULL, STR_NULL, NULL),
SDTG_BOOL("rightclick_emulate", S, 0, _rightclick_emulate, false, STR_NULL, NULL),
#ifdef WITH_FREETYPE
+#ifdef ANDROID
+ SDTG_STR("small_font", SLE_STRB, S, 0, _freetype.small_font, "fonts/FreeSans.ttf", STR_NULL, NULL),
+ SDTG_STR("medium_font", SLE_STRB, S, 0, _freetype.medium_font, "fonts/FreeSans.ttf", STR_NULL, NULL),
+ SDTG_STR("large_font", SLE_STRB, S, 0, _freetype.large_font, "fonts/FreeSerif.ttf", STR_NULL, NULL),
+#else
SDTG_STR("small_font", SLE_STRB, S, 0, _freetype.small_font, NULL, STR_NULL, NULL),
SDTG_STR("medium_font", SLE_STRB, S, 0, _freetype.medium_font, NULL, STR_NULL, NULL),
SDTG_STR("large_font", SLE_STRB, S, 0, _freetype.large_font, NULL, STR_NULL, NULL),
+#endif
SDTG_VAR("small_size", SLE_UINT, S, 0, _freetype.small_size, 8, 0, 72, 0, STR_NULL, NULL),
SDTG_VAR("medium_size", SLE_UINT, S, 0, _freetype.medium_size, 10, 0, 72, 0, STR_NULL, NULL),
SDTG_VAR("large_size", SLE_UINT, S, 0, _freetype.large_size, 16, 0, 72, 0, STR_NULL, NULL),
Index: src/os/unix/unix.cpp
===================================================================
--- src/os/unix/unix.cpp (revision 21531)
+++ src/os/unix/unix.cpp (working copy)
@@ -24,7 +24,7 @@
#ifdef __APPLE__
#include <sys/mount.h>
-#elif (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) || defined(__GLIBC__)
+#elif ((defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) || defined(__GLIBC__)) && !defined(ANDROID)
#define HAS_STATVFS
#endif
@@ -245,6 +245,11 @@
void cocoaReleaseAutoreleasePool();
#endif
+#ifdef ANDROID
+#define main SDL_main
+extern "C" int CDECL main(int, char *[]);
+#endif
+
int CDECL main(int argc, char *argv[])
{
int ret;
Index: src/os/unix/crashlog_unix.cpp
===================================================================
--- src/os/unix/crashlog_unix.cpp (revision 21531)
+++ src/os/unix/crashlog_unix.cpp (working copy)
@@ -141,7 +141,11 @@
};
/** The signals we want our crash handler to handle. */
+#ifdef ANDROID
+static const int _signals_to_handle[] = { }; // Default Android signal handler will give us stack trace
+#else
static const int _signals_to_handle[] = { SIGSEGV, SIGABRT, SIGFPE, SIGBUS, SIGILL };
+#endif
/**
* Entry point for the crash handler.
Index: src/window.cpp
===================================================================
--- src/window.cpp (revision 21531)
+++ src/window.cpp (working copy)
@@ -2171,6 +2171,10 @@
* But there is no company related window open anyway, so _current_company is not used. */
assert(IsGeneratingWorld() || IsLocalCompany());
+#ifdef ANDROID
+ _settings_client.gui.left_mouse_btn_scrolling = true;
+#endif
+
HandlePlacePresize();
UpdateTileSelection();
Index: src/network/core/os_abstraction.h
===================================================================
--- src/network/core/os_abstraction.h (revision 21531)
+++ src/network/core/os_abstraction.h (working copy)
@@ -161,7 +161,7 @@
# include <net/if.h>
/* According to glibc/NEWS, <ifaddrs.h> appeared in glibc-2.3. */
# if !defined(__sgi__) && !defined(SUNOS) && !defined(__MORPHOS__) && !defined(__BEOS__) && !defined(__HAIKU__) && !defined(__INNOTEK_LIBC__) \
- && !(defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)) && !defined(__dietlibc__) && !defined(HPUX)
+ && !(defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)) && !defined(__dietlibc__) && !defined(HPUX) && !defined(ANDROID)
/* If for any reason ifaddrs.h does not exist on your system, comment out
* the following two lines and an alternative way will be used to fetch
* the list of IPs from the system. */
Index: src/viewport.cpp
===================================================================
Index: src/debug.cpp
===================================================================
--- src/debug.cpp (revision 21531)
+++ src/debug.cpp (working copy)
@@ -16,6 +16,9 @@
#include "string_func.h"
#include "fileio_func.h"
#include "settings_type.h"
+#ifdef ANDROID
+#include <android/log.h>
+#endif
#include <time.h>
@@ -76,6 +79,9 @@
*/
static void debug_print(const char *dbg, const char *buf)
{
+#ifdef ANDROID
+ __android_log_print(ANDROID_LOG_INFO, "OpenTTD", "[%s] %s", dbg, buf);
+#endif
#if defined(ENABLE_NETWORK)
if (_debug_socket != INVALID_SOCKET) {
char buf2[1024 + 32];
Index: src/main_gui.cpp
===================================================================
--- src/main_gui.cpp (revision 21531)
+++ src/main_gui.cpp (working copy)
@@ -465,7 +465,11 @@
Hotkey<MainWindow>('C', "center", GHK_CENTER),
Hotkey<MainWindow>('Z', "center_zoom", GHK_CENTER_ZOOM),
Hotkey<MainWindow>(WKC_ESC, "reset_object_to_place", GHK_RESET_OBJECT_TO_PLACE),
+#ifdef ANDROID
+ Hotkey<MainWindow>(WKC_DELETE, "delete_windows", GHK_DELETE_NONVITAL_WINDOWS),
+#else
Hotkey<MainWindow>(WKC_DELETE, "delete_windows", GHK_DELETE_WINDOWS),
+#endif
Hotkey<MainWindow>(WKC_DELETE | WKC_SHIFT, "delete_all_windows", GHK_DELETE_NONVITAL_WINDOWS),
Hotkey<MainWindow>('R' | WKC_CTRL, "refresh_screen", GHK_REFRESH_SCREEN),
#if defined(_DEBUG)

View File

@@ -0,0 +1,10 @@
Quick compilation guide:
Download my GIT repo from https://github.com/pelya/commandergenius,
then install Android SDK 2.2, NDK r4b, and "ant" tool, then launch commands
rm project/jni/application/src
ln -s scummvm project/jni/application/src
cd project && android update project -p .
then download OpenTTD r21531 into the dir project/jni/application/openttd/openttd,
apply ChillCore patch onto it, apply my patch openttd-trunk-android.patch
and launch build.sh. That should be it.
There will be error with "sqrtl" function not defined, change it to "sqrt".

View File

@@ -1 +0,0 @@
ufoai/build/projects/AndroidAppSettings-lowmem.cfg

View File

@@ -1 +0,0 @@
ufoai/src/ports/linux/ufo.png

View File

@@ -1,7 +0,0 @@
Quick build instructions: you have to download GIT repo from https://github.com/pelya/commandergenius ,
then install Android SDK 2.2, NDK r4b from http://develoiper.android.com , and Apache Ant tool, then you should launch commands
rm project/jni/application/src
ln -s ufoai project/jni/application/src
cd project && android update project -p .
then download UFO:AI GIT into the dir project/jni/application/ufoai/ufoai
(or create a symlink to it if you already have downloaded it), and launch build.sh. That should be it.

View File

@@ -1 +0,0 @@
../../../../../ufoai/