Android porting thread.

General chat related to ScummVM, adventure gaming, and so on.

Moderator: ScummVM Team

Post Reply
Botje
Posts: 207
Joined: Thu Feb 28, 2013 5:48 pm

Re: Android porting thread.

Post by Botje »

You can simply apply at the first link there; me or klusark will approve your membership.
I try to approve people when I see the emails come in, but I don't always remember..
enigmaxtreme
Posts: 2
Joined: Sat Apr 26, 2014 11:36 pm

Re: Android porting thread.

Post by enigmaxtreme »

Don't know if it has already been asked, but what's the easiest way to get Residual on the Ouya besides rooting it and installing play store
Botje
Posts: 207
Joined: Thu Feb 28, 2013 5:48 pm

Re: Android porting thread.

Post by Botje »

grab the latest .apk from the buildbot and install it with ADB over the usb cable.
hooby3dfx
Posts: 16
Joined: Tue Dec 31, 2013 6:01 am

Re: Android porting thread.

Post by hooby3dfx »

no need for usb.

ouya added an awesome feature to upload and install apks remotely via a web interface.

from the main screen just go to 'make' and then 'upload' and follow instructions.
hooby3dfx
Posts: 16
Joined: Tue Dec 31, 2013 6:01 am

Re:

Post by hooby3dfx »

Botje wrote:hello meisterfuu, I noticed you cloned my repo :)

Assuming you have checked out the source code and are currently in that directory:
$ mkdir build
$ cd build
$ export ANDROID_SDK=(path to the android SDK)
$ export ANDROID_NDK=(path to the android NDK)
$ ../configure --host=android-v7a --backend=android --enable-opengl-shaders --disable-engine=myst3
$ make

This will give you an .apk you can install on your device.

However, if you're going to be actively developing it's faster to work in the dists/android directory and invoke ndk-build/ant. I can write that up, but it will take me a while.
...btw are there full/updated instructions for building android anywhere?
Botje
Posts: 207
Joined: Thu Feb 28, 2013 5:48 pm

Re: Android porting thread.

Post by Botje »

Those are the full instructions.

For development I typically do "make libresidualvm.so", symlink that into "build/build.tmp/libs/armeabi", then "ndk-build && ant debug && adb install -R *apk".
biomecanoid
Posts: 5
Joined: Sun May 03, 2015 9:48 pm

Re: Android porting thread.

Post by biomecanoid »

Hello Guys,

Love your work with ScummVM and ResidualVM, can someone please invite me so i can download the APK for android ?

Thanks
Steel01
Posts: 5
Joined: Thu May 21, 2015 4:32 pm

Re: Android porting thread.

Post by Steel01 »

I'm interested in running Myst 3 on android, so I pulled the latest git and tried to compile. Ran into a few problems. First, GLES2 doesn't support GL_UNSIGNED_INT_8_8_8_8_REV, so I had to revert 7a3e61a. GLES2 also doesn't support GL_UNPACK_ROW_LENGTH. I had to do a bit of research there and based off some code from Retroarch, I came up with:

Code: Select all

diff --git a/engines/myst3/gfx_opengl_texture.cpp b/engines/myst3/gfx_opengl_texture.cpp
index 6f79f64..956a4a7 100644
--- a/engines/myst3/gfx_opengl_texture.cpp
+++ b/engines/myst3/gfx_opengl_texture.cpp
@@ -89,8 +89,31 @@ void OpenGLTexture::updatePartial(const Graphics::Surface *surface, const Common
 	const Graphics::Surface subArea = surface->getSubArea(rect);
 
 	glBindTexture(GL_TEXTURE_2D, id);
+
+#ifdef GL_UNPACK_ROW_LENGTH
 	glPixelStorei(GL_UNPACK_ROW_LENGTH, surface->pitch / surface->format.bytesPerPixel);
 	glTexSubImage2D(GL_TEXTURE_2D, 0, rect.left, rect.top, subArea.w, subArea.h, internalFormat, sourceFormat, subArea.getPixels());
+#else
+	// Code path for devices with GL_UNPACK_ROW_LENGTH, based on code from Retroarch.
+	const GLvoid *data_buf = subArea.getPixels();
+	unsigned pitch_width   = surface->pitch / surface->format.bytesPerPixel;
+
+	if (width != pitch_width)
+	{
+		GLvoid *conv_buffer       = calloc(sizeof(uint32_t), surface->w * surface->h);
+
+		unsigned h;
+		const unsigned line_bytes = width * surface->format.bytesPerPixel;
+		uint8_t *dst              = (uint8_t*)conv_buffer;
+		const uint8_t *src        = (const uint8_t*)subArea.getPixels();
+
+		for (h = 0; h < height; h++, src += surface->pitch, dst += line_bytes)
+			memcpy(dst, src, line_bytes);
+
+		data_buf                  = conv_buffer;
+	}
+	glTexSubImage2D(GL_TEXTURE_2D, 0, rect.left, rect.top, subArea.w, subArea.h, internalFormat, sourceFormat, data_buf);
+#endif
 }
 
 } // End of namespace Myst3
I also pulled a libjpeg-turbo build script to compile libjpeg for Android. With all that, I was able to compile an APK. But that was just the start of the problems. OpenGL shaders don't want to play under Android. The fragment shaders fail to compile complaining about precision not being specified for float. And no matter what I tried on those shaders, it keeps giving me the exact same error. I finally gave up and tried software rendering. No go there either. Program crashes immediately after start in /system/lib/libjpeg.so. Say what? Can someone explain how a statically compiled lib is bombing out in a shared object it shouldn't even be referencing? Anyways, the relevant section of the logcat is below:

Code: Select all

I/DEBUG   (  205): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   (  205): Build fingerprint: 'nvidia/wx_un_do/shieldtablet:5.0.1/LRX22C/29979_515.3274:user/release-keys'
I/DEBUG   (  205): Revision: '0'
I/DEBUG   (  205): ABI: 'arm'
I/DEBUG   (  205): pid: 4380, tid: 4400, name: ResidualVM  >>> org.residualvm.residualvm <<<
I/DEBUG   (  205): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
I/DEBUG   (  205):     r0 b679af88  r1 b48cf010  r2 00000000  r3 00012f60
I/DEBUG   (  205):     r4 00000000  r5 ad0a9ea8  r6 00000001  r7 a0937020
I/DEBUG   (  205):     r8 b48cf010  r9 a0937010  sl 00000000  fp a093701f
I/DEBUG   (  205):     ip b6787be8  sp ad0a9d88  lr b6785b34  pc b6788054  cpsr a0000010
I/DEBUG   (  205): 
I/DEBUG   (  205): backtrace:
I/DEBUG   (  205):     #00 pc 0001e054  /system/lib/libjpeg.so
I/DEBUG   (  205):     #01 pc 0001bb30  /system/lib/libjpeg.so
I/DEBUG   (  205):     #02 pc 00013298  /system/lib/libjpeg.so (jpeg_consume_input+120)
I/DEBUG   (  205):     #03 pc 0001350c  /system/lib/libjpeg.so (jpeg_read_header+60)
I/DEBUG   (  205):     #04 pc 0030d124  /data/app/org.residualvm.residualvm-1/lib/arm/libresidualvm.so (Image::JPEGDecoder::loadStream(Common::SeekableReadStream&)+208)
I/DEBUG   (  205):     #05 pc 00174594  /data/app/org.residualvm.residualvm-1/lib/arm/libresidualvm.so (Myst3::Myst3Engine::decodeJpeg(Myst3::DirectorySubEntry const*)+36)
I/DEBUG   (  205):     #06 pc 001752b8  /data/app/org.residualvm.residualvm-1/lib/arm/libresidualvm.so (Myst3::Face::setTextureFromJPEG(Myst3::DirectorySubEntry const*)+12)
I/DEBUG   (  205):     #07 pc 00177294  /data/app/org.residualvm.residualvm-1/lib/arm/libresidualvm.so (Myst3::NodeFrame::NodeFrame(Myst3::Myst3Engine*, unsigned short)+188)
I/DEBUG   (  205):     #08 pc 001708dc  /data/app/org.residualvm.residualvm-1/lib/arm/libresidualvm.so (Myst3::Myst3Engine::loadNodeMenu(unsigned short)+68)
I/DEBUG   (  205):     #09 pc 001783d4  /data/app/org.residualvm.residualvm-1/lib/arm/libresidualvm.so (Myst3::Script::run(Common::Array<Myst3::Opcode> const*)+92)
I/DEBUG   (  205):     #10 pc 00170ff4  /data/app/org.residualvm.residualvm-1/lib/arm/libresidualvm.so (Myst3::Myst3Engine::runNodeInitScripts()+280)
I/DEBUG   (  205):     #11 pc 00171248  /data/app/org.residualvm.residualvm-1/lib/arm/libresidualvm.so (Myst3::Myst3Engine::loadNode(unsigned short, unsigned int, unsigned int)+500)
I/DEBUG   (  205):     #12 pc 001783d4  /data/app/org.residualvm.residualvm-1/lib/arm/libresidualvm.so (Myst3::Script::run(Common::Array<Myst3::Opcode> const*)+92)
I/DEBUG   (  205):     #13 pc 00170ff4  /data/app/org.residualvm.residualvm-1/lib/arm/libresidualvm.so (Myst3::Myst3Engine::runNodeInitScripts()+280)
I/DEBUG   (  205):     #14 pc 00171248  /data/app/org.residualvm.residualvm-1/lib/arm/libresidualvm.so (Myst3::Myst3Engine::loadNode(unsigned short, unsigned int, unsigned int)+500)
I/DEBUG   (  205):     #15 pc 00173414  /data/app/org.residualvm.residualvm-1/lib/arm/libresidualvm.so (Myst3::Myst3Engine::run()+828)
I/DEBUG   (  205):     #16 pc 000d8b60  /data/app/org.residualvm.residualvm-1/lib/arm/libresidualvm.so (scummvm_main+5452)
I/DEBUG   (  205):     #17 pc 000cb80c  /data/app/org.residualvm.residualvm-1/lib/arm/libresidualvm.so (JNI::main(_JNIEnv*, _jobject*, _jobjectArray*)+292)
I/DEBUG   (  205):     #18 pc 0000291b  /data/dalvik-cache/arm/data@app@org.residualvm.residualvm-1@base.apk@classes.dex
For my specific use case, I'm using a Shield Tablet. It has full OpenGL 4.5 support. If I knew how to init OGL on Android, I'd probably just hack that together for a personal builds since it seems to run fine on my Linux desktop. But that's out of my range atm, so I'm looking to get it running with GLES2 (or maybe GLES3 or 3.1 to get the missing instructions without hacks). Do you have any idea what's wrong with either or both of the runtime problems?

Thanks,
Steel01
Botje
Posts: 207
Joined: Thu Feb 28, 2013 5:48 pm

Re: Android porting thread.

Post by Botje »

Thanks for looking at this. I was under the impression our buildbot covered myst3 with Android builds, but apparently not.

EDIT: I pushed a patch to ResidualVM master which should solve this issue.
For the shaders: can you try applying the patch at https://www.dropbox.com/s/jredfmu85z39j ... patch?dl=1 ?

For the libjpeg issue: ResidualVM links dynamically to libjpeg, and it looks like the libjpeg version being pulled in is the one from your system.
Try editing config.mk to move -ljpeg in between the -Wl,-Bstatic -Wl,-Bdynamic bits in the LIBS variable.
Alternatively, you could use something like adb pull /system/lib/libjpeg.so libjpeg.so to link against the same libjpeg as on your system.
Steel01
Posts: 5
Joined: Thu May 21, 2015 4:32 pm

Re: Android porting thread.

Post by Steel01 »

Okay, it runs now. I still need the revert and patch as above to compile. I pulled libjpeg from my CyanogenMod tree and changed config.mk to dynamic link it. My config.mk by default is putting the jpeg stuff in the static section.

I don't think my unpack row length patch is correct. The menu hover image is garbage in OGL and correct in software. I can't get the cursor to move atm and I don't have a gamepad or mouse on me right now, so I can't even get off the menu to check anything else.
bgK
ScummVM Developer
Posts: 71
Joined: Sat Feb 13, 2016 12:40 pm

Re: Android porting thread.

Post by bgK »

Steel01, can you please check if the following commit fixes your issues?
https://github.com/bgK/residualvm/commi ... 3507a0cd8a
Steel01
Posts: 5
Joined: Thu May 21, 2015 4:32 pm

Re: Android porting thread.

Post by Steel01 »

No, the aliased extension can't be found either.

Code: Select all

../engines/myst3/gfx_opengl_texture.cpp: In member function 'void Myst3::OpenGLTexture::updateTexture(const Graphics::Surface*, const Common::Rect&)':
../engines/myst3/gfx_opengl_texture.cpp:31:30: error: 'GL_UNPACK_ROW_LENGTH_EXT' was not declared in this scope
 #define GL_UNPACK_ROW_LENGTH GL_UNPACK_ROW_LENGTH_EXT
                              ^
../engines/myst3/gfx_opengl_texture.cpp:107:17: note: in expansion of macro 'GL_UNPACK_ROW_LENGTH'
   glPixelStorei(GL_UNPACK_ROW_LENGTH, surface->pitch / surface->format.bytesPerPixel);
                 ^
../Makefile.common:105: recipe for target 'engines/myst3/gfx_opengl_texture.o' failed
Which seems odd. A bit of Googling indicates that should be in GLES2... I'm using ndk r10e. If I comment out the row length stuff, I still get the jpeg linking error because that got stuck in the static section of the LIBS parameters. Moving that around allows the compile to complete.
bgK
ScummVM Developer
Posts: 71
Joined: Sat Feb 13, 2016 12:40 pm

Re: Android porting thread.

Post by bgK »

Indeed, the ndk does not define this constant for the arm platform. I changed the commit in my branch to use the literal value.
https://github.com/bgK/residualvm/tree/myst3-fix-gles2
Steel01
Posts: 5
Joined: Thu May 21, 2015 4:32 pm

Re: Android porting thread.

Post by Steel01 »

Yes, after fixing the jpeg link issue, that compiles and seems to run fine. No graphical glitches with hardware rendering on the all of two menu pages I can get to.

Still can't get the mouse cursor to move. Touchscreen input pops up arrows and letters based on where I touch and slide, but that doesn't control the menu at all. Single tap does select the menu under the cursor, though (Load Game). Plugged in a mouse and that did absolutely nothing. Tried a joystick and got the cursor in the ResidualVM menu to move, but again nothing ingame.
bgK
ScummVM Developer
Posts: 71
Joined: Sat Feb 13, 2016 12:40 pm

Re: Android porting thread.

Post by bgK »

Ok, thanks for your testing.

I don't think Android input has been developped for Myst III, the game won't be playable until it has.
Post Reply