Page 1 of 3

Android port via Java - continued discussion

Posted: Tue Jan 04, 2011 9:40 am
by Dominus
The old thread about the Android port got a bit long, thus this new thread.

Old thread http://exult.info/forum/viewtopic.php?p=337315#p337315

DrCode, Jeff, is rewriting Exult for Android via Java. So it is not a "direct" port and changes in main Exult need to be backported to Android. He doesn't have a real Android device but uses an Android Emulator.
If you are on Facebook you can view screenshots at http://www.facebook.com/album.php?id=15 ... id=2093804 or non facebookers can view them at http://www.dropbox.com/gallery/7801769/ ... d?h=e27af2. The dropbox gallery is not always up to date with the screenshots shown on Facebook.

On our Download page you can download a working snapshot of DrCode's work so far.
- You need to place the static folder of BG at "/sdcard/Games/exult/blackgate" for BG to work (SI doesn't work yet).
- Music works if you put the .ogg music files in /sdcard/Games/exult/music
- SFX need the sfx flx files in /sdcard/Games/exult to work
- you need exult.flx and exult_bg.flx file in /sdcard/Games/exult - the files can be extracted from the Exult 1.4.9rc1 release (I zipped those, including the SI one up at http://exult.info/snapshots/androiddata.zip)
- If it crashes right away, try removing the contents of the 'gamedat' directory and try again (/sdcard/Games/exult/blackgate)
- It doesn't restore games from the main Exult yet, but eventually it will.
- Press 's' to bring up the save/restore screen.

You move the Avatar either by dragging him, or dragging the mouse on an empty area or object that's not draggable.

If you think this first post needs more information, let me know and I'll edit it.

Re: Android port via Java - continued discussion

Posted: Tue Jan 04, 2011 1:01 pm
by Ed
oh hey new thread

only thing else I could think to mention is that you also need the exult_bg.flx file in /sdcard/Games/exult as well

and if there's a crash on startup if all else fails delete the GAMEDAT folder that seems like it's worked for myself and a couple other people

back from vacation and ready to try out these new builds i've missed out on =)

Re: Android port via Java - continued discussion

Posted: Tue Jan 04, 2011 5:52 pm
by drcode
Thanks, Dom!

More recently:
1. I think you also need exult.flx in /sdcard/Games/exult (the dir).
2. If you put one of the sound-effects .flx files there, SFX's should work.
3. I've been skipping over SI support for now, but it won't be all that difficult to add later.
4. Yesterday's snapshot does have the opening scene enabled.
5. I'm trying to bring up an 'alert' box with error when we can't find a file; but previous versions crashed when trying to do this. I think I have this worked out now. (Kind of annoying when your 'fatal error' message causes a crash:-)).
6. Latest snapshot lets you move the Avatar either by dragging him, or dragging the mouse on an empty area or object that's not draggable.

Re: Android port via Java - continued discussion

Posted: Tue Jan 04, 2011 11:21 pm
by Dominus
ok, updated first post a bit.

Questions on
1. is the data dir /sdcard/Games/exult or /sdcard/Games/exult/data ?
6. another input idea, if the Android does recognize long touches, maybe you can move the Avatar when you hold down a finger a longer time on the display and use stuff on quick touches.
Don't know if that just mirrors one of the other suggestions, just came to my mind.

Re: Android port via Java - continued discussion

Posted: Tue Jan 04, 2011 11:48 pm
by drcode
1. Currently /sdcard/Games/exult. Currently no support for an exult.cfg file.
6. Yes, thinking about something like that.

Another thought I have is to have a cursor, probably the 'crosshairs', that sits at, say, the top right corner. If you drag it around, it could highlight the item it's over so you can select more easily.

Re: Android port via Java - continued discussion

Posted: Wed Jan 05, 2011 12:08 am
by Dominus
the crosshair idea could work. You will probably need to experiment with different options and let real world touch-Android-users decide :)

Re: Android port via Java - continued discussion

Posted: Wed Jan 05, 2011 8:04 am
by NewAndroid
Would a zoom be possible? I think it would be more comfortable for moving objects...

Re: Android port via Java - continued discussion

Posted: Wed Jan 05, 2011 10:08 am
by Sladi
Hi,

Exult for Android is very exciting!
Maybe a seperate window showing a portion of the screen under the cursor could be done to get precise control.
Ultima 7 is not wide screen, but I think many phones have a wide display with room at the side for such a display.

Regards,
Sladi

Re: Android port via Java - continued discussion

Posted: Wed Jan 05, 2011 1:25 pm
by Torgus dragon
Zoom in and out would be very helpful. I would reccomend the pinch method

Re: Android port via Java - continued discussion

Posted: Thu Jan 06, 2011 3:27 pm
by TheOtherAlex
Great work!

For now, I'm still stuck with my crappy Nokia 5800, but I'll move over to Android soon (Galaxy i9000). Can't wait to get my hands on it :))

Re: Android port via Java - continued discussion

Posted: Mon Jan 10, 2011 2:19 am
by Ed
hey DrCode i threw together a launcher icon with google's quick n dirty generator thing, if you want something to stick in there for now

http://miscetc.net/ic_launcher.zip

Re: Android port via Java - continued discussion

Posted: Mon Jan 10, 2011 10:55 pm
by drcode
Thanks, Ed. I'll take a look when I'm back from my vacation.

Another question: If we have a 'zoom' function, how do you enable it on a phone without a keyboard? I'm starting to think that part of the screen should be reserved for buttons or a menu.

Re: Android port via Java - continued discussion

Posted: Mon Jan 10, 2011 11:28 pm
by Dominus
the "pinch method" for zooming on touch only. Two fingers that move away from each other (or move to each other to zoom the other direction).

Re: Android port via Java - continued discussion

Posted: Tue Jan 11, 2011 2:33 am
by Ed
a lot of hardware still doesnt support multitouch for pinch to zoom, which is a drag

even trackpads arent on every phone so thats kinda out too =/

unless you throw all of em in! =D

Re: Android port via Java - continued discussion

Posted: Tue Jan 11, 2011 8:22 am
by Dominus
Wow, a consistent interface would surely help ;)

Re: Android port via Java - continued discussion

Posted: Tue Jan 11, 2011 11:06 am
by Malignant Manor
Image

It finally happened. (a bit late to be posting this)

Re: Android port via Java - continued discussion

Posted: Tue Jan 11, 2011 11:57 pm
by Wizardry Dragon
Not having multitouch on all phones is a significant and serious technical limitation of android phones. You could have single-touch gestures for zoom though. Perhaps if you tap and hold on something it could zoom in, and if, when zoomed in, you tap again on that same thing, it would zoom out.

Kludgy I know, but the best I can think of.
----------
Peter M Dodge
aka Wizardry Dragon
www.thefeudallands.ca

Re: Android port via Java - continued discussion

Posted: Thu Jan 13, 2011 9:57 pm
by drcode
Yes, I might try that. Although the touch is getting quite a bit overloaded.

Re: Android port via Java - continued discussion

Posted: Sat Jan 15, 2011 5:59 am
by KenC
Hi All,

I started dabbling with a native Android port a while back, and didn't notice all this work on a Java version until I almost had it working. I suspect there will better integration with Android using the Java port, but FWIW, I do have a native port up and running now.

Still need to sort out some of the controls, so it's not really playable yet, but I was able to create a new game and run around a bit. Sound effects are working, but music is not - need to investigate that still. I'm getting 3-4 fps in the simulator, and 8-10 fps on my Nexus One.

After I iron out some decent controls and get the music working, I'll see about getting my source modifications integrated into the main tree and make an apk available somewhere.

Note that this port was done with the pelya SDL port (tried using the GSoC port and never managed to get anything to draw on the screen), and the crystax NDK.

We can kick off a new thread for this if anyone wants to discuss it in detail - mainly just wanted to give a heads up that a native port is in the works now that I've actually got something running

Ken

Re: Android port via Java - continued discussion

Posted: Sun Jan 16, 2011 1:09 am
by Summ
Hi there!

I tried to run the Exult Android port mentioned in this post, but it always crashes at start. :-(

I copied the contents of my BG folder to
/sdcard/Games/exult/blackgate/BG
/sdcard/Games/exult/blackgate

tried only the STATIC folders content in
/sdcard/Games/exult/blackgate/STATIC
/sdcard/Games/exult/blackgate

I also took the exult.flx and exult_bg.flx and placed them in
/sdcard/Games/exult/exult.flx
/sdcard/Games/exult/exult_bg.flx

The reported error is:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.exult.android/com.exult.android.ExultActivity}: java.lang.IndexOutOfBoundsException
at DataUtilsFunctorMultidataReader
at DataUtilsBaseReader
...
at ExultActivity.onCreate

Any idea what I might be doing wrong?

(Device: unrooted HTC-Desire running 2.1)

Re: Android port via Java - continued discussion

Posted: Sun Jan 16, 2011 10:17 am
by Dominus
@KenC: please let us know more and definitely send us a diff when you got it working.

@Summ:
The second way you tried is the correct one (just the static folder in /sdcard/Games/exult/blackgate/STATIC).
Try only with that. Get rid of a gamedat folder /sdcard/Games/exult/blackgate

Then try to play. if it still doesn't work, try creating a gamedat fodler in /sdcard/Games/exult/blackgate and also try out whether it works when the static folder is all lower caps (static instead of STATIC).

Re: Android port via Java - continued discussion

Posted: Sun Jan 16, 2011 12:49 pm
by Summ
@Dominus:
I tried putting the STATIC folder here:
/sdcard/Games/exult/blackgate/STATIC

did not work - same error

Also tried this
/sdcard/Games/exult/blackgate/static

did not work - same error

No gamedat folder is present, so there is nothing to delete. I also created an empty gamedat folder, but that did not work either.

Maybe I'm missing some files? Or its a problem with the HTC-Sense-GUI... Has anyone gotten it to work on a HTC Device?

Re: Android port via Java - continued discussion

Posted: Sun Jan 16, 2011 2:14 pm
by Dominus
hmm, maybe you need one of the sfx packs for BG in /sdcard/Games/exult

Re: Android port via Java - continued discussion

Posted: Sun Jan 16, 2011 3:25 pm
by Ed
yes as of a version or two ago it bombs out at the beginning if the sound files arent found

Re: Android port via Java - continued discussion

Posted: Sun Jan 16, 2011 4:23 pm
by Summ
I do have jmsfx.flx file placed
/sdcard/Games/exult/jmsfx.flx

and also the music in
/sdcard/Games/exult/music/*.ogg

still it bombs out with the same Exception :-(s

If it is really about the right place for the file, maybe someone with a working directory layout could paste the output of
$>ls -la /sdcard/Games/exult

here? If that still fails, maybe it is a problem with HTC-Sense or one of my files is corrupted (but I used the same files as for my local exult installation under Ubuntu...)

Re: Android port via Java - continued discussion

Posted: Sun Jan 16, 2011 4:52 pm
by Dominus
try with the mt32 sfx file.

Re: Android port via Java - continued discussion

Posted: Sun Jan 16, 2011 6:27 pm
by Summ
works.

Okay, the problem was:
exult.flx from the current ubuntu package and exult.flx from the current windows version are not identical.

So, using the data files from the Exult Win32 Version I could start it :-) (8-12fps, sound had some error messages, music was nice)

However, I was not able to return back to game after saving and also was not able to quit the game at all. But I can live with that for now.

But I would suggest to reengineer the mouse emulation, since its very hard to move small objects with the touchpad.
How about a trackpad emulation like in the qemu-version for android? The screen acts like a trackpad allowing nice cursor positioning and two of the hardware buttons are used as substiute for LMB and RMB.

Re: Android port via Java - continued discussion

Posted: Sun Jan 16, 2011 6:29 pm
by Dominus
Yes, Ubuntu package is probably based on 1.2 and that is very old...

Edit: I made a zip file of the 1.4.9rc1 data files and uploaded them to our snapshots space. See the first post

Re: Android port via Java - continued discussion

Posted: Sun Jan 16, 2011 10:39 pm
by Summ
Hi again,

I took a quick look at the current sources and I think it would be possible to add the described behaviour for the cursor without greater problems. (touch only moves cursor relative, hardware buttons to click)
Not that I have much time for this, but I'd be willing to give it a try.

But since there is no tags folder in the svn-tree and the trunk is currently very active, I would like to know which revision was used for the current apk build?

Re: Android port via Java - continued discussion

Posted: Sun Jan 16, 2011 11:18 pm
by Summ
Sorry for doublepost, but I dont know where to put this instead: the current apk build has a memory leak somewhere in the imagebuffer - I dont have the time to investigate it further, but it occurred after walking around for 3 minutes in Trinsic when the clouds showed up.

(Also: saving before the Avatar is visible directly at the beginning causes the game to load this savegame everytime the application is run, but lets the Avatar remain invisible and does not continue the opening scene. Maybe the savegame does not cover running cutscenes currently? )

Re: Android port via Java - continued discussion

Posted: Mon Jan 17, 2011 1:52 am
by Dominus
@Summ: a usefull link is http://exult.svn.sourceforge.net/viewvc ... /?view=log which should show you only the revisions concerning the android port.
The current apk is from the 4th of January, so expect the apk to approximately match revision #6687.

Re: Android port via Java - continued discussion

Posted: Mon Jan 17, 2011 5:42 pm
by drcode
Yes, there was definitely a memory problem, in that I was inadvertantly allocating 65K for every game chunk. That's fixed now, but not in the snapshot.

I'm also trying to show errors instead of crashing when files are not found; but I had a problem bringing up a dialog box, as it too would crash. That might be fixed now.

Do you know which hardware buttons are used as the 'mouse' buttons? I only have the emulator to work with. One other idea I have is to display a 'select' cursor that you can drag around, and when it's on an object, the object gets highlighted. I also don't think it will be hard to do zooming, like we've discussed above.

Assume that the source will be very unstable for quite a while. I'm currently working on pathfinding and setting NPC schedules, and this has caused either lots of slowdowns, more crashes, plus bad savefiles can be created. This is why I haven't made a new snapshot lately. It's also uncovered bugs in Exult that we don't notice in the PC version because PC's are so fast. For example, NPC's that are off-screen are continuously doing pathfinding, then throwing away the path because they're not visible. Fixing that made a big speed difference in the emulator.

Re: Android port via Java - continued discussion

Posted: Mon Jan 17, 2011 8:30 pm
by Malignant Manor
I thought the pathfinding issue was mostly with combat where they try to find a path a few times, and then they give up completely. After that, the only way for them to attack is to provoke them unless there is a schedule change.

I was under the impression that the npcs in the nearby superchunks were able to do their schedules. The Blue Boar waitresses seem to stock tables for the people eating there when I was waiting around at the Fellowship shelter near Paws. Of course, the cutoff point for when people stop doing schedules is probably too far away.

Re: Android port via Java - continued discussion

Posted: Mon Jan 17, 2011 9:30 pm
by Dominus
Let us know of the fixes for the trunk ;)

Re: Android port via Java - continued discussion

Posted: Mon Jan 17, 2011 9:39 pm
by drcode
I don't want to change the trunk until I'm sure I haven't broken anything, which is more than likely.:-)

Malignant: We've had all kinds of bugs. One was that in combat, we'd keep repeating the pathfinder for an NPC that was trapped in a room, and the game would get really slow. Then we'd fix that, and there would be the problem you noted where they wouldn't attack even after you opened the door to that room. The code that I'm trying to get working goes like this:

1. If the NPC is more than a screen-full away, set it to 'dormant'.
2. If it's dormant, don't do pathfinding or scheduling for it, but keep checking every second or so in case it's no longer dormant.
3. When an NPC is rendered, mark it as no longer dormant.

This might not be great for the main version of Exult, since it means NPC's that are off-screen will be frozen until you get close enough to see them. I'll have to play with this a bit to see whether it's a problem.

Re: Android port via Java - continued discussion

Posted: Mon Jan 17, 2011 10:42 pm
by Summ
Do you know which hardware buttons are used as the 'mouse' buttons?
Either the trackball-button, search or the volume-buttons. I think it would be best to make them configurable.
I also don't think it will be hard to do zooming, like we've discussed above
Would sure be nice for smaller displays, but if you are using your finger as a pointer the object beneath it is still covered by it. Thats why I favor the relative cursor movement and a classic cursor. But why not both?
I'm currently working on pathfinding...
Yeah, A* is a nasty algorithm. I used it many times in several projects, so if you have a specific problem, just post it here - maybe I can help. I took a brief look at the pathfinding sources yesterday too - optimization is really important here as the complexity of A* is O=|N|^2 in the worst case. Maybe a SMA* could help, but that would require further investigation.
Also letting actors "think" for a couple of frames/ticks can save great amounts of performance. (I currently cant check it with your code if you already do it, but you could e.g. limit the number of new nodes beeing created during tree generation to a maximum of n for a single frame/tick and continue in the next frame - uses more memory though, if many actors are waiting for their paths to be finished)
I don't want to change the trunk until I'm sure I haven't broken anything
You could create a trunk/tags/branches structure in the SVN, and commit your current WIP code into a branch - this way we can help you test.

Re: Android port via Java - continued discussion

Posted: Tue Jan 18, 2011 6:47 pm
by TDI
I'm guessing you already have the C version of your pathfinding algorithm from Exult code. Still, I have a ready-made A*/BestFS/Dijkstra coded in Java, if you should need it, I would gladly donate it to Exult.

It works on a square grid and comes with a little applet that lets you draw obstacles and observe the pathfinding. Something I had to do for college, but should be easily adapted to anything else.

There's probably two dozen Java A* algorithms on the net. I based mine on one of those. Unfortunately practically all of them are incomplete or contain subtle errors and you have to invest alot of time to fix them.

>Maybe a SMA* could help

This is the first time I hear of SMA*, but Wikipedia says it is "memory bounded". I'm not certain, but I think that CPU is more critical than memory for Exult on Android devices? At least in relation to what Exult will gobble up anyways, I guess that a few extra kb for a decent search won't make a huge difference.

Re: Android port via Java - continued discussion

Posted: Tue Jan 18, 2011 6:58 pm
by Summ
SMA* is also a little faster since it guesses the most probable steps during tree-spanning.
Memory is limited by the DalvikVM (Androids JavaVM) to 16-25MB per process (afaik), but the CPU is mostly between 600-1000MHz, so memory might be more critical.
But if you have a good A* implementation at hand and no problem releasing it into GPL, why not?

Re: Android port via Java - continued discussion

Posted: Tue Jan 18, 2011 9:00 pm
by drcode
Thanks, but I already took the Exult AStar code and converted it to Java, except that I'm using the Java builtin priority queue instead of the custom one used in C++ Exult. Seems to work okay and fast enough, so far.

The real problems I'm seeing involve when to have an NPC go 'dormant' because he's off the screen and has no need to move. This is really important in U7 because there are so many NPC's around and it's a waste of time to have them doing their activities when you can't see them. OTOH, we can't have an NPC frozen when it's time for him to walk near the player from off-screen or attack him.

Re: Android port via Java - continued discussion

Posted: Tue Jan 18, 2011 9:29 pm
by Summ
Hmm, a few dozens of NPCs should not cause a big performance problem. How many NPCs are checked each frame?

Also some of the NPCs that might be some distance away still need to be checked, because the player could e.g. wait at the tavern for an NPC to show up. In Trinsic this is less of a problem, but in Britain the NPCs travel larger distances.
(The original U7 was able to run smoothly on 50Mhz with 4MB RAM, so maybe the original programmers used a different approach?)
Arent most of the paths always the same when the Player is not in the way? Could they be precalculated?

Re: Android port via Java - continued discussion

Posted: Thu Jan 20, 2011 10:02 pm
by drcode
I just uploaded a new snapshot. This has NPC's walk to their schedules, and several schedule types are implemented. You'll probably want to delete old savegames along with gamedat/*.

The world is looking more alive, but it also crashes more since there's much more going on. Haven't done anything else with the interface yet. That might be my next goal after implementing more schedules.

Re: Android port via Java - continued discussion

Posted: Thu Jan 20, 2011 10:09 pm
by Malignant Manor
Could you please include the flx files that are currently needed in the download page for people who don't have easy access to them?

Re: Android port via Java - continued discussion

Posted: Thu Jan 20, 2011 10:42 pm
by Dominus
While it would be best if Jeff would add them, I made a zip of those and put them in the snapshot space and updated the first post.
Jeff if you can and if it isnecessary, please update that zip (andrioddata.zip) with the correct files.

Re: Android port via Java - continued discussion

Posted: Fri Jan 21, 2011 1:40 pm
by Ed
Tried out the new build with all sounds and musics and whatnot and all seems to be working. intro works with full earthquake dance and all that now. ran around for a while without any crashing too

pressing S on hardware keyboard works to pop up save screen, but cant seem to find a button for inventory. doubleclicking avatar works however (not sure if other keyboard shortcuts havent been added but figured id mention)

theres a couple odd bright green circles sitting on the ground in the opening scene. if these arent showing on the emulator I can try to get a screenshot for you.

other than that, seems pretty great. Is there a way to exit? I couldnt figure one out other than hitting back, but that leaves the app running in the background

Re: Android port via Java - continued discussion

Posted: Fri Jan 21, 2011 5:20 pm
by drcode
Dom: Thanks. I'll take a look at it this weekend.

Ed: You're right, I haven't implemented many of the shortcuts yet, including 'I' for inventory. Those little green circles and red numbers are 'eggs', and I have them on by default now, but will change that soon. Alt-X should exit, though it doesn't prompt you first.

Re: Android port via Java - continued discussion

Posted: Fri Jan 21, 2011 6:03 pm
by Ed
oh awesome, thanks for alt-x somehow that combo didnt occur to me

Re: Android port via Java - continued discussion

Posted: Fri Jan 21, 2011 6:07 pm
by Ed
also, is there any way to start a new game? after my first play where i hit save it always starts up with that save

or i guess these sorta things will be handled by the menu wrapper situation eventually

Re: Android port via Java - continued discussion

Posted: Fri Jan 21, 2011 6:12 pm
by Malignant Manor
You can should be able to delete the gamedat directory to start a new game.

Re: Android port via Java - continued discussion

Posted: Fri Jan 21, 2011 6:59 pm
by Ed
oh dur haha

Re: Android port via Java - continued discussion

Posted: Fri Jan 21, 2011 7:55 pm
by drcode
I wonder how a user can quit if his phone doesn't have a keyboard. I'm starting to think more and more that the side of the screen should be reserved for some buttons.