3.0.0 beta (ZGE on Android)

Information and change log about the latest ZGameEditor release.

Moderator: Moderators

Post Reply
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

I tried to use the BASS library on Android - see the attached testing ZGE project. I copied libs/armeabi/libbass.so to /sdcard/libbass.so. On each first library call (I used either BASS_GetVersion or BASS_Init) the application crashes. What am I doing wrong? Please help.
Attachments
bass_test.zip
testing project
(2.36 KiB) Downloaded 383 times
User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

I see in the log that libbass.so cannot be loaded. I then found this article that explains loading so-files from sdcard is not working because of security concerns:

https://groups.google.com/forum/?fromgr ... oKW1aPcK5s

So we will have to wait testing this until we can bundle so-files in the apk.

edit: Just tried manual bundling and then the so can be loaded from "/data/data/org.zgameeditor/lib/libbass.so" path and your test works. But I don't think you can write to this folder unless the files are included in the apk.
User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Rado1, here is your test project with path set and a special ZGE built with BASS.so included.

Also the 4 parameters max limit should have been raised to 8 now (but I cannot test BASS anyway because it requires Android 2.3).

Let me know if it is working.
Attachments
ZGEAndroid-debug_with_BASS.zip
(402.81 KiB) Downloaded 373 times
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Some functions of BASS are working, eg., BASS_GetVersion. However I'm not able to load music files. I tried .it, .mp3, .xm and .midi files.

If the function is defined as:

Code: Select all

int BASS_MusicLoad(string file, int offset, int length, int flags, int freq) {}
its calling returns BASS_ERROR_FORMAT - unsupported sample format. If the function is defined as:

Code: Select all

int BASS_MusicLoad(string file, int offset1, int offset2, int length, int flags, int freq) {}
its calling (offset1 == offset2 == 0) returns BASS_ERROR_FILEOPEN - can't open the file.

Note, these two variants are different in interpretation of parameter "offset" which is originally long (64-bit signed two's complement integer).

Any help?
User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

It looks like those are Java-overridden methods of BASS.

I haven't tried this myself, but I suggest you try the original method definition:

int BASS_MusicLoad(int mem, string filename, int of1, int of2, int length, int flags, int freq) { }

And pass zero in all other parameters just like in the ZGE\Projects\ModPlay\ModPlay.zgeproj sample.
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Ville, you are right. I used original signatures and it works!!! :-) :-) :-) It is, therefore, possible to use the same ZExternalLibrary for Windows and Android (just ModuleName changes), great. BASS for Android can play just MOD/XM/IT/... files, not MP3 or MIDI (BASS_ERROR_FILEFORM error is thrown in their case). To play also these formats some plugins should be added too. But this is not practically necessary, I would never use other formats than XM, IT, etc. for small ZGE applications.

This reminds me the necessity to add file attachments to Android building settings. They should be installed together with application somewhere to /data/data/<appl_id>/... folder and could be read by the application in runtime.
User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Rado1: I'm glad it works! Implementing external lib is tricky and requires some assembly code so it takes a bit of investigation and guesswork.

Another addition to simplify Android development:

If you have your Android device connected in debug mode you should be able to run your project from ZGE with a single click: "Android: Run project"
You need to have downloaded Android SDK and set the path in ZGE settings.

It will automatically upload ZGE debug apk, upload your zzdc.dat file, and then start the app with logging enabled.

http://www.zgameeditor.org/files/ZGameEditor_beta.zip
Attachments
android_debug.png
android_debug.png (25.55 KiB) Viewed 10788 times
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

"Android: Build zzdc.dat file": selection of the target directory for placement of zzdc.dat file would be better than placing it to the ZGE's home directory directly.

"Android: Run project": if an error occurs, the opened window is closed immediately, so it's difficult to know what happened. No error message appears in logs. This happened to me when I accidentally removed Android API and adb crashed/terminated immediately.
User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Finally upgraded to a Android 4 device. I got the Asus PadFone. It's pretty cool because it is a phone that can be docked to a 10" touch screen. Haven't tested the docking yet so can't say how well it works in practice.

I installed the ZGE games to see how they compared to my Samsung device:

Eater:
Samsung: No issues except audio latency.
Asus: Less audio latency, however the Midi music on title screen have slight timing issues. Weird because the lower audio latency should make the midi music timing improve too. Besides this minor annoyance the game plays perfectly.

Saucer:
Samsung: Drops in frame rate.
Asus: Smooth and stable frame rate. Less audio latency. I have managed to get to wave 5 now ;)
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Ville, very cool device!

In Eater, the title screen music is not Midi. It plays sounds out of array where sound frequencies and lengths are stored. Timing is based on App.Time. In each OnUpdate sequence App.Time is compared to the supposed time of playing next note (App.Time >= MusicBeatTimer) and if true, next note is played and MusicBeatTimer is updated. So this depends on FPS, unfortunately. I was not able to run MIDI on my device at all. It will be much better with BASS.
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

Wow, that is a neat device! I had not seen that one before,. I almost got a Xoom, when I saw them on sale for $250.00 last week, but glad I did not, as the NEXUS 7 is way closer to what I have been looking for,. quad-core, 720p, and the form factor I think is best for a tablet; 7 inches. It should be available in a couple week here, so I will no longer have to develop on the borrowed sony hardware,. the nexus also comes with a usb cable so it should be much smoother to test on.

this ability to link to external libs is amazing,. I wish I was better at compiling stuff,. interested in trying pd in an attempt to get more sound options (timing issues);
http://puredata.info/docs/developer/Bui ... orAndroid/
https://github.com/libpd/pd-for-android/

also some physics would be very nice ;)

I should have a tower defense style demo soon,. testing out some interfacing. I will post some of what I have for that soon as well,. just simple stuff really.
iterationGAMES.com
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Ok, I was playing with NDK this evening and come up with an initial version of ZGEBullet for Android, see this post.

Unfortunately I have no clue whether it is working with ZGE application. Ville could you please prepare a version of ZGE application with ZGEBullet for testing? I'm also not sure about performance, but we will see it after make it running. BTW you can also update zgebullet.txt to the new version in ZGE.

I compiled it for android-9 armeabi, is it correct? Probably armeabi-v7a would be faster due to better support for hardware floating point operations. Just tell me what targets/ABIs to use.

Ville, is there any possibility for me to build the Android ZGE application by myself? E.g., could you provide some sources where to add libraries and compile? Or do you plan to enhance support for libraries to be loaded also from /sdcard/ in a short time? Or should I wait for Android-specific application settings in ZGE and building applications by ZGE automatically?

Personal remark about Android NDK: it's a pain! I do not know why is it so "old fashioned", cygwin, gcc, gmake,... (I tried also vs-android but give up to compile ZGEBullet - so many problems appeared.) It also takes years to read and understand the original documentation. Thanks to developers who share their experience on Internet - this is the only source for setting up projects, removing compilation errors, debugging, optimization, etc. The process of compiling is not complicated by itself, but complicated is to get to know what is the process and what settings to use.
User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

That's great! I have provided some files that you can test with.

Yes, I agree NDK is unnecessarily complicated. I guess this is because Android is basically Linux, and well in Linux everything is complicated or it won't be taken seriously ;-)

ZGE Android is built using android-8 (represents Android 2.2) and ARMV6 with VFPv2 floating point support. Not sure if you need to recompile your code.

Atteched is zip-file containing:
- Debug APK with libZgeBullet included. Since APK files are just zip-files you should be able to replace the .so file inside if needed, but I'm not sure it might have internal checksums to prevent this.
- Full folder that I used for building release version of Eater. See if you can get it to build using r.bat file. You need Ant and Java compiler installed. If you can get it to build then you can try replacing all occurences of the word "Eater" with something else in all java and xml files to get an unique application (otherwise it will replace Eater on your device). This is what I will try later to automating apk-building from inside ZGE.
Attachments
zgebullet_android_test.zip
(1.12 MiB) Downloaded 381 times
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Thanks Ville!

Simple replacing of files in .apk does not work - checksums are necessary in order to install application on a device. Therefore, ant is necessary, but this is no problem, I have installed the whole environment for building Android applications.

Recompilation to android-8 is not a problem, but how to enable VFPv2 for NDK compilation? There is no mention in documentation. Any idea?

Anyway, I'm going to create a simple application with ZGEBullet now. Keep your fingers crossed!
User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Tried the 10" screen, both games run fine in the higher resolution. Jph: Saucer plays even better on the larger screen and the audio is great when using earphones.

Rado1: Try armeabi it should be the most compatible. And remember to change the path to the SO on the ExternalLibrary component. When using Eater it should be "/data/data/com.rado1.Eater/lib/libXYZ.so" etc. Just saving your so-file in the "libs\armeabi" folder is enough to include it in the apk-build. If it is not working check for "failed to load" messages in the log.
Post Reply