Author Topic: AGS engine Android port  (Read 189203 times)

Crimson Wizard

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: AGS engine Android port
« Reply #800 on: 01 May 2018, 12:08 »
Can you put

[misc]
log=1

to the acsetup.cfg in your game folder, run the game, and then paste contents of "ags.log" that should appear in the parent "ags" folder?

Re: AGS engine Android port
« Reply #801 on: 01 May 2018, 13:37 »
Just thought I'd chime in to say that Guard Duty is up and running in the latest .apk you posted CW. So far I've only noticed an issue with font colour (as mentioned by custard), other than that everything else seems to be working perfectly. I haven't had any crashes after about 20 minutes of playing and I've yet to find anything behaving unexpectedly.

I'm running on a Galaxy S7 Edge and had to move the game folder over to internal storage (was previously on SD) to get it to run, when it was on the SD card I was getting the error 'Unable to write in the savegame directory.'.

Really impressive stuff, thank you again for your work CW. It's such a nice feeling playing through the game on mobile. The screen is ever so slightly soft, but it actually feels closer to playing on an old CRT so I'm not complaining!

Does this mean we might be able to build to apk sometime in the future? 8-0

*edit: One 'bug' I did notice: AGS lowers background audio when speech is playing (as intended) but when running on android the background audio does not return to it's normal volume after speech has finished.

Crimson Wizard

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: AGS engine Android port
« Reply #802 on: 01 May 2018, 13:48 »
Does this mean we might be able to build to apk sometime in the future? 8-0
There was this plugin made by monkey0506: http://www.adventuregamestudio.co.uk/forums/index.php?topic=53910.0
You can also do this manually with the instructions eri0o wrote: http://www.adventuregamestudio.co.uk/forums/index.php?topic=55681.0
After glancing quickly, it looks like all you need is to replace native engine libraries to version 3.4.1. Which means that we probably need to deploy both APK, for quick-testing, and these libraries for building your own APK.
Also, afaik you could extract these libraries from existing APK.


*edit: One 'bug' I did notice: AGS lowers background audio when speech is playing (as intended) but when running on android the background audio does not return to it's normal volume after speech has finished.

Well... I guess we will need to open an actual bug tracker for these reports. And start a new Android thread, because this one becomes too long and unmanageable.
Maybe after I fix most outstanding bugs known atm.

Re: AGS engine Android port
« Reply #803 on: 01 May 2018, 17:10 »
Hey CW!

I tested my game on your latest apk! Here is the video!

It's working great! :-D (except for the part that I have to rethink the touch areas for fingers instead of... pen input...)

Crimson Wizard

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: AGS engine Android port
« Reply #804 on: 06 May 2018, 22:23 »
I noticed this speech colour being different on Android:
So far I've only noticed an issue with font colour (as mentioned by custard)

Question: could you double check what renderer you were running? Below I post results of my own tests, and for me it looks like the issue is only with Software renderer.


I made additional testing to clarify the differences between 3.4.0, previous 3.4.1 and latest 3.4.1 with color fix, and the latest APK build by JJS himself (very old one).


The old APK by JJS:
Software renderer: all color games are okay.
Hardware renderer: 32 and 16 bit games are okay, 8-bit games cause engine to close or crash without a message.

3.4.0:
Software renderer: sadly, it looks like in 3.4.0 Android port was broken and could not apply chosen options, so software renderer was always disabled, and only hardware one active.
Hardware renderer: 32 and 16 bit games are okay, 8-bit games cause engine to close or crash without a message.

3.4.1 (before color fix):
Software renderer: all color games are okay.
There is one issue in 8-bit games with black text color treated as transparent. I do not know if old JJS's port had same problem, because only game where this bug was noticed is made with higher version of AGS.

Hardware renderer: 32-bit games have Red and Blue components swapped, except for the text. My test was limited, but it seems at least speech text and text on GUI buttons worked alright, contrary to the rest of the game.
16-bit: ok.
8-bit: crashes without message.

3.4.1 (after color fix):
Software renderer: 32-bit games are okay, except for the text, which has Red and Blue components swapped.
16-bit games have Red and Blue components swapped, including the text.
8-bit games: looks okay.

Hardware renderer: 32 and 16-bit games are okay.
8-bit games: crashes without message.


Summing up:
Something has changed between 3.4.0 and 3.4.1, that causes R<->B color component swap when running 32-bit games with hardware renderer.
But if that gets fixed (or "fixed"), then same error occurs for 16-bit games run with software renderer.



It is worth noting, that before 3.4.1 both Software and hardware OpenGL renderer had run 16-bit games in 16-bit native mode (although for hardware renderer bitmaps were converted to 32-bit ones before being applied to textures). For 3.4.1 I made both Direct3D and OpenGL run only in 32-bit mode, because otherwise they were loosing some color precision in 16-bit games. Later I also made Software renderer choosing 32-bit display mode for 16-bit games too, for couple of reasons.
That could maybe explain why software renderer has 16-bit games screwed after the fix, but still idk if has anything to do with 32-bit games screwed earlier.

Another thing that should be noted again, on Android "Software" renderer actually works as a mixed renderer. After it builds all game image using software drawing functions, the Allegro library patched by JJS takes that final image and draws it using OpenGL again.
And the important thing is, that unlike OpenGL built in AGS, the OpenGL renderer in Allegro does not convert 16-bit game bitmaps to 32-bit - then draws them on 32-bit texture, but instead copies them to 16-bit textures (GL_UNSIGNED_SHORT_5_6_5).



Anyway, I did another test, and made 16-bit games run in 16-bit mode with Software renderer.
That fixed biggest problem (16-bit games had all colors swapped), but the issue with 32-bit games having text color swapped remained (obviously).


Right now I am bit confused, not sure how to proceed.
The whole thing is just screwed up, there are two OpenGL renderers, one in Allegro and another in AGS, and they do not work exactly same way, and I do not even know what was the need to create 2 of them. If JJS even explained it, I've never seen that explanation.
Maybe it would be possible to change color shift setup depending on whether it is software or hardware renderer running. If only I could understand how these color shifts work. It is perfectly possible that they are simply not used correctly in some case.
« Last Edit: 06 May 2018, 22:30 by Crimson Wizard »

Crimson Wizard

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: AGS engine Android port
« Reply #805 on: 07 May 2018, 00:16 »
In addition to above, if you look into the liballegro-4.4.2.patch for Android, you would see that when it updates opengl texture contents from native bitmap, it does so without any conversion:

Code: C
  1. glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, android_screen_width, android_screen_height, GL_RGBA, GL_UNSIGNED_BYTE, displayed_video_bitmap->line[0]);
  2.  
meaning that native bitmap is expected to have pixel format corresponding to GL_RGBA (R at shift 0, G at shift 8 and so on).

However, in AGS, it does explicit conversion from native bitmap, using the supplied shifts, e.g.:
Code: C++
  1. memPtrLong[x] = D3DCOLOR_RGBA(algetr32(*srcData), algetg32(*srcData), algetb32(*srcData), algeta32(*srcData));
  2.  

D3DCOLOR_RGBA is always the same for all versions:
Code: C++
  1. #define D3DCOLOR_RGBA(r,g,b,a) \
  2.   (((((a)&0xff)<<24)|(((b)&0xff)<<16)|(((g)&0xff)<<8)|((r)&0xff)))
  3.  
Which seem to correspond to GL_RGBA.
algetr32 and similar functions are declared as:
Code: C++
  1. #define algetr32(xx) ((xx >> _rgb_r_shift_32) & 0xFF)
  2.  
And for Android _rgb_r_shift_32 is set as (this was before my "fix"):
Code: C++
  1. _rgb_r_shift_32 = 0;
  2. _rgb_g_shift_32 = 8;
  3. _rgb_b_shift_32 = 16;
  4.  

Which means that native bitmap is supposed to have same pixel format as final OpenGL texture. In other words, result of bitmap->texture conversion in both Allegro renderer and AGS renderer must be the same! But for some reason it's not!
What I am missing here?!......

Crimson Wizard

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: AGS engine Android port
« Reply #806 on: 07 May 2018, 00:53 »
Oh shoot! I may have found what is the difference between 3.4.0 and 3.4.1.

Android has a compilation flag AGS_INVERTED_COLOR_ORDER, which does this at some point, when the sprite gets loaded from game resources:
Code: C++
  1.     if ((bmp_col_depth == 32) && (sys_col_depth == 32))
  2.     {
  3. #if defined (AGS_INVERTED_COLOR_ORDER)
  4.         // PSP: Convert to BGR color order.
  5.         if (software_driver)
  6.             new_bitmap = convert_32_to_32bgr(bitmap);
  7. #endif
  8.     }
  9.  
This perhaps explains how bitmaps end up with OpenGL-compatibe format for the Software renderer.

The thing is that the "if (software_driver)" condition appeared only in 3.4.1. Before that this conversion was performed regardless.


This... may explain everything. At least I hope it will, because my mind is close to get boggling.
Going to try and restore this old behavior.


A MINUTE OF RANT: But clearly all of this won't be neccessary if there were some proper comments left around this code, just to make us know why the colors need to be inverted. When I checked this code a while ago, I was left assured that all this refers only to PSP (as the only comment tells), and related to how its own graphics driver works.
Apparently same technique is used in mobile ports to prepare bitmaps matching OpenGL pixel conversion, which is nowhere near obvious. :(
« Last Edit: 07 May 2018, 01:02 by Crimson Wizard »

Crimson Wizard

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: AGS engine Android port
« Reply #807 on: 07 May 2018, 02:01 »
Uhhhhhhh!

I think it is finally working with both renderers and all color modes, and text also seem to have proper color.
Please, test again:
https://www.dropbox.com/s/qww9leoj643ltwr/AGS-3.4.1-debug.apk?dl=0

Privateer Puddin'

  • Mittens Knight
  • bob
Re: AGS engine Android port
« Reply #808 on: 07 May 2018, 02:03 »
Question: could you double check what renderer you were running? Below I post results of my own tests, and for me it looks like the issue is only with Software renderer.

32 bit game with the Software renderer (neither Hardware options work on my two phones; the game plays (I hear sound) but just get a black screen)

I'll test again with the new file!

Edit: New version, 32 bit game with the Software renderer: dialog colours are correct
« Last Edit: 07 May 2018, 02:30 by Privateer Puddin' »

Crimson Wizard

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: AGS engine Android port
« Reply #809 on: 07 May 2018, 02:37 »
32 bit game with the Software renderer (neither Hardware options work on my two phones; the game plays (I hear sound) but just get a black screen)

If you have some spare time, could you check the old 3.4.0 APK with any compatible game, to see if there is any difference? It may be found here: http://www.adventuregamestudio.co.uk/releases/finals/AGS-3.4.0-P4/Android.3.4.0.16.APK.zip

Privateer Puddin'

  • Mittens Knight
  • bob
Re: AGS engine Android port
« Reply #810 on: 07 May 2018, 03:32 »
Tested using Memories Fade: http://www.adventuregamestudio.co.uk/site/games/game/2127/

3.4.0.16: Works in Software, Hardware, and Hardware (Pixel Perfect)
3.4.1-debug: Works in Software only (same as my game)

Crimson Wizard

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: AGS engine Android port
« Reply #811 on: 07 May 2018, 09:13 »
Can you put

[misc]
log=1

to the acsetup.cfg in your game folder, run the game, and then paste contents of "ags.log" that should appear in the parent "ags" folder?

Privateer Puddin'

  • Mittens Knight
  • bob
Re: AGS engine Android port
« Reply #812 on: 07 May 2018, 09:33 »
Adventure Game Studio v3.4 Interpreter
Copyright (c) 1999-2011 Chris Jones and 2011-2018 others
ACI version 3.4.1.12

Initializing allegro
Initializing game data
Looking for the game data file
Located game data file: /storage/emulated/0/ags/feria/Feria d'Arles.exe
Opened game data file: game28.dta
Game data version: 49
Compiled with: 3.4.1.11
Setting up game configuration
Setting up window
Initializing TTF renderer
Initializing mouse: number of buttons reported is 3
Checking memory
Data directory: /storage/emulated/0/ags/feria
Initializing audio vox
Audio vox found and initialized.
Initializing keyboard
Install timer
Initialize sound drivers
Sound settings: digital driver ID: 'Auto' (0xffffffff), MIDI driver ID: 'Auto' (0xffffffff)
Installed digital driver ID: 'ANDS' (0x414e4453), MIDI driver ID: 'None' (0x0)
Install exit handler
Initialize path finder library
Load game data
Game GUI version: 118
Requested script API: v3.4.1 (5), compat level: v3.4.0 (4)
Game title: 'Feria d'Arles'
Checking for disk space
Initializing MOD/XM player
Initializing resolution settings
Game native resolution: 320 x 180 (32 bit)
Device display resolution: 320 x 200
Game settings: windowed = no, screen def: max, screen size: 0 x 0, match device ratio: yes, game scale: proportional
Using graphics factory: OGL
Created graphics driver: OpenGL
Attempt to switch gfx mode to 320 x 180 (32-bit) fullscreen
Running OpenGL: OpenGL ES-CM 1.1
WARNING: OpenGL 3.0 or higher is required for tinting shader.
ERROR: OpenGL: Tinting program's fragment shader failed to compile:
----------------------------------------
ERROR: Invalid #version

----------------------------------------
ERROR: OpenGL: Lighting program's fragment shader failed to compile:
----------------------------------------
ERROR: Invalid #version

----------------------------------------
Succeeded. Using gfx mode 320 x 200 (32-bit) fullscreen
Render frame set, render dest (0, 10, 319, 189 : 320 x 180)
Requested gfx filter: StdScale
Graphics filter set: 'StdScale', filter dest (0, 10, 319, 189 : 320 x 180)
Using gfx filter: StdScale
Mouse control: off, base: 1.000000, speed: 1.000000
Mouse confined: (0,10)-(319,189) (320x180)
Check for preload image
Initialize sprites
Initialize game settings
Cannot open translation: default.tra
Prepare to start game
Audio thread started
Checking replay status
Engine initialization complete
Starting game
OGL: notified of device screen updated to 1312 x 2272, resizing viewport
Render frame set, render dest (0, 767, 1311, 1504 : 1312 x 738)
Mouse confined: (0,767)-(1311,1504) (1312x738)
***** ENGINE HAS SHUTDOWN

Crimson Wizard

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: AGS engine Android port
« Reply #813 on: 09 May 2018, 20:36 »
@Privateer Puddin', this annoys me greatly, but at the moment I do not know what could be the cause there. I tried that other game you mentioned on emulator, and it worked well with hardware renderer too. There might be another small difference in versions that I did not notice yet but do not know where to start looking.
Hopefully eventually someone gets an idea.
E: except one dumb thing, are you running game in vertical mode? Render surface is 1312 x 2272. Is there a way to try horizontal mode instead?


On a side note, here is a slightly updated Android port, fixed running FLIC movies:
https://www.dropbox.com/s/qww9leoj643ltwr/AGS-3.4.1-debug.apk?dl=0


Probably will release a new patch to 3.4.1 later this week, that will include Android port.

Mehrdad

    • I can help with animation
    •  
    • I can help with characters
    •  
    • I can help with story design
    •  
    • I can help with web design
    •  
Re: AGS engine Android port
« Reply #814 on: 10 May 2018, 06:25 »
Probably will release a new patch to 3.4.1 later this week, that will include Android port.

Is Android port in AGS editor? ? ? ? ? ? ?

Privateer Puddin'

  • Mittens Knight
  • bob
Re: AGS engine Android port
« Reply #815 on: 10 May 2018, 06:47 »
@Privateer Puddin', this annoys me greatly, but at the moment I do not know what could be the cause there. I tried that other game you mentioned on emulator, and it worked well with hardware renderer too. There might be another small difference in versions that I did not notice yet but do not know where to start looking.
Hopefully eventually someone gets an idea.
E: except one dumb thing, are you running game in vertical mode? Render surface is 1312 x 2272. Is there a way to try horizontal mode instead?

Same black screen starting/staying in horizontal, same starting in vertical and rotating to horizontal etc. (which works in software), can post up the log again if that's any help.

Crimson Wizard

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: AGS engine Android port
« Reply #816 on: 10 May 2018, 10:28 »
Is Android port in AGS editor? ? ? ? ? ? ?

No. I am not integrating building for Android in the Editor, I was fixing Android port itself.

You need to use monkey's plugin for that: http://www.adventuregamestudio.co.uk/forums/index.php?topic=53910.0
Or those instructions from eri0o: http://www.adventuregamestudio.co.uk/forums/index.php?topic=55681.0

BUT, since most people cannot build necessary Android files for these methods, we would need to post download links for them, that work with 3.4.1.

« Last Edit: 10 May 2018, 10:38 by Crimson Wizard »

Mehrdad

    • I can help with animation
    •  
    • I can help with characters
    •  
    • I can help with story design
    •  
    • I can help with web design
    •  
Re: AGS engine Android port
« Reply #817 on: 10 May 2018, 12:21 »
Oh.OK. you are amazing. Nice job CW and eri0o!!!. I'll try it as soon as possible

Re: AGS engine Android port
« Reply #818 on: 11 May 2018, 05:08 »
I didn't do anything, it was all CW, my part was mainly getting him annoyed. (laugh)

Re: AGS engine Android port
« Reply #819 on: 21 Jun 2018, 09:44 »
Hi devs,

very nice port (3.4.1)! Thank you!
I tried to play Kong Quest 1 VGA from AGD Interactive on a tablet and it is really nice.
Only one problem. Not all tablets have a menu button, only the back button.
It will be possible to switch the Actions between Back an Menu buttons? In this way on a tablet without menu button it will be easy to play. Now, when the menu button is pressed it shows a menu with contains an exit point as well. The back button works only like a shortcut for exit. It is not possible to get the virtual keyboard without a menu button.
Thank you