Porting to Android via Java

NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
Forum rules
NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
Gianni Leuani

Porting to Android via Java

Post by Gianni Leuani »

[EDIT by Dominus:
When you read on in this thread, Dr. Code is in progress of porting Exult to Android via Java]

I'm interested in trying to make a working version of Exult to run on Android devices. But I found that in order to do this, a working model of the code has to be developed in Java, which could then be adapted to run on Android by switching out the platform specific graphics-handling.

The "working-model" should only be the game logic that parses the U7 game files, and handles running the game itself while making calls to the graphics and sound code.

Is there any additional code or anyone with notes out there that could help me with parsing the game-data files? If I had something that worked like a JUnit test that can verify if a game data file is valid or not, that'd be really helpful.
Dominus
Site Admin
Posts: 5656
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by Dominus »

I'm not sure you really need a javabased code for Android anymore. At least according to http://arstechnica.com/open-source/news ... ev-kit.ars

This port to of Scummvm to Android could maybe shed more light on this:
http://forums.scummvm.org/viewtopic.php ... ht=android
--
Read the documentation and the FAQ! There is no excuse for not reading them! RTFM
Read the Rules!
We do not support Piracy/Abandonware/Warez!
Gianni Leuani

Re: Porting to Android via Java

Post by Gianni Leuani »

The arstechnica article is mentioning that the C++ toolkit is using JNI to hook into the java code. And if you've ever delt with JNI, you'd eventually realize it gets harder to maintain in the long run, especially when newer processors come out.

So, its best to not depend entirely upon the C++ toolkit just because Exult was developed in C. I'm just trying to plan ahead here instead of just banging out code for codes sake.

And the SCUMMVM, that's an entirely different animal altogether.
Dominus
Site Admin
Posts: 5656
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by Dominus »

I mentioned Scummvm because we share at least the audio code.

Happy codeing...
--
Read the documentation and the FAQ! There is no excuse for not reading them! RTFM
Read the Rules!
We do not support Piracy/Abandonware/Warez!
Ed

Re: Porting to Android via Java

Post by Ed »

this book seems to cover the gist of the idea, but i have no idea how applicable it is to this project:

http://books.google.com/books?id=-1eQ71 ... CBcQ6AEwAQ

(just mentioning it because it would be terrific if it did happen)
486DX2/66 Dragon

Re: Porting to Android via Java

Post by 486DX2/66 Dragon »

No need to have a Java port.

You can use JNI wrappers for C++ code.
Also, there is libSDL for android.

It will be a messy thing, but theoretically it should be doable.
WtF Dragon

Re: Porting to Android via Java

Post by WtF Dragon »

If someone manages to get started on this and/or get it working, please let me know at Ultima Aiera (http://www.ultimaaiera.com). I've been corresponding with Bioware Mythic, and they're getting pretty serious about seeing the Ultima games ported to mobile platforms...a working, reasonably non-buggy port of U7 to Android would probably be of interest to them, possibly even to the level of them giving it official sanction.

And no, I am not (to the best of my knowledge) kidding or being a jackarse.
Dominus
Site Admin
Posts: 5656
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by Dominus »

:)
AsI wrote on your site, they should get someone to port Exult to Android and iOS. An experienced programmer should be able to do it. Basically Exult need sto be ported to SDL 1.3 and then you can go off :) (as has been done for ScummVM or Dosbox...)
--
Read the documentation and the FAQ! There is no excuse for not reading them! RTFM
Read the Rules!
We do not support Piracy/Abandonware/Warez!
TDI

Re: Porting to Android via Java

Post by TDI »

If BioWare is hiring to create Java ports of Ultima games, COUNT ME IN!!!

Seriously, I'll send my resume right away. :)
WtF Dragon

Re: Porting to Android via Java

Post by WtF Dragon »

@TDI

A couple of quick points.

1) It's Bioware Mythic (a.k.a. Bioware Fairfax), not Bioware (a.k.a. Bioware Edmonton) that's pushing this. That's a small distinction, as there is a lot of cross-communication between studios. But at least as far as technical distinctions go, Mythic is a separate studio from the one that pumped out Mass Effect, Dragon Age, and all the rest.

2) I don't know if they are hiring at this exact point in time, but their mid-to-long-term goal is to see the Ultima games ported to other platforms, especially mobile platforms. Paul Barnett, their Creative Director, is really stoked about iOS (iPhone/iPod Touch/iPad) ports, especially, though I'd imagine an Android port would also catch his attention.

At present, they don't have the means to develop such ports in-house; their time is given over to other projects of more immediate importance. However, I have spoken with Mr. Barnett personally, and he's told me flat-out that if someone comes up with a solid, reasonably stable port of e.g. U4 (or U7; I can't imagine he'd turn it down), he'd do damn near everything to make sure that it got published EA's mobile storefront(s?) (the App Store, and I'd assume the Android Store if they have one for that ecosystem).

If you've got more questions, drop 'em here and I can forward them to Mr. Barnett.
Ed

Re: Porting to Android via Java

Post by Ed »

guysguysguys (and girls sorry i get excited)

sdl has been ported over, no java required. they've already pushed ports of Ur-Quan Masters and OpenTyrian to the market.

http://www.anddev.org/sdl_port_for_andr ... t9218.html

maybe just what the doctor ordered
monotremata
Posts: 246
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by monotremata »

Damn of course its only Android 1.6 or above..
I bought a stupid AT&T Backflip back in March and we're apparently Motorola's red-headed step child and are still on 1.5..
They say we're getting 2.1 and they're testing it but funny how for all of the non-US models of the phone they've cancelled it and decided they're staying at 1.5 for the best 'experience'...
Its the OpenGL they're having trouble with lately so Im guessing my phone wouldn't be up to playing Exult nicely anyways..


Time to look out for a new Samsung on Ebay heh..
Morbius Dragon
-==(UDIC)==-
Since 1992!
monotremata
Posts: 246
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by monotremata »

Ok somebody do this now haha!
The Backflip just got a custom 2.1 ROM last night based off a Cliq upgrade..
We dont have 3d acceleration yet but I can test whenever someone gets a build done hehe!!
Morbius Dragon
-==(UDIC)==-
Since 1992!
devon8

Re: Porting to Android via Java

Post by devon8 »

It's not exult, but ultima7 works pretty well on my ipad via dospad (dosbox port). Should also work on iphone4 and I believe there's an android port of dosbox out there, although there's probably not anything as fast as the ipad running android yet.
drcode
Site Admin
Posts: 2267
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by drcode »

Has anyone used ScratchBox to port to Android? It sounds promising.
drcode
Site Admin
Posts: 2267
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by drcode »

The ArsTechnica article says they don't intend native code to be used for large applications, but for CPU-intensive operation. But it looks like ScummVM works.:-)

Still, Exult is a pretty large program that's not very efficient with memory. I wonder what it would take to do a Java version, and whether the performance would be okay.

I've just started playing around with the 'Hello Android' examples in Eclipse with the emulated phone, and maybe will work up to doing a U7 shape browser as an exercise.
drcode
Site Admin
Posts: 2267
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by drcode »

For fun (strange idea of 'fun'), I've started converting Exult code to Java to run on Android. My initial goal is just to display one image from shapes.vga, but that involves a LOT of code. I'm pretty much just translating by hand from C++ classes to Java. Eclipse makes this relatively easy in the way it does syntax-checking as you write.

So far, I've written about 1200 lines of code and all I have to show is that I can read in the Avatar's shape.:-) But to display it, I need a palette, and that leads to bringing in most of the 'U7 file' code. Maybe tonight...

One thing that worries me about all this is that it doesn't look like an Android supports 8-bit palette graphics, which means we'll be doing a lot of converting from our 8-bit frame to its RGBA canvas. I don't know if an Android has enough CPU power for this.
MB

Re: Porting to Android via Java

Post by MB »

I really hope this works out! The only portable Ultima 7 fix I have is via that old psp port (and it is simply awful).

I run scumm vm on my Samsung Galaxy with no issues, so I'm hoping that these new phones have the power to run the classic greats.

Btw, thank you all for the hard work so far. Been following this project forever and gotten a lot of fun from it.
Torgus dragon

Re: Porting to Android via Java

Post by Torgus dragon »

Can you tell us more about scumm on the galaxy s? The galaxy s should be able to run u7 easily.
Dominus
Site Admin
Posts: 5656
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by Dominus »

@jeff, can yougive us some screenshots or photos of exult running on the android so far? Do you actually have an android or are you codeing halfblind through an android emulator? Your commits sound interesting ;)

@torgus, I'm sure the scummvm forums would be much more suited to find information on this.
--
Read the documentation and the FAQ! There is no excuse for not reading them! RTFM
Read the Rules!
We do not support Piracy/Abandonware/Warez!
drcode
Site Admin
Posts: 2267
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by drcode »

I'll get a screenshot tonight, but don't expect a lot. What I'm doing is converting our c++ code to Java, skipping some things that I'll get to later and simplifying when possible. All that code (2000+ lines), and all I've got so far is the ability to render the flat terrains or paint a shape. No objects are created yet.

I only have the emulator to test with.

What worries me is performance. It doesn't seem like there's any builtin support for 8-bit graphics. So I'm painting into our own byte-array. Then on each 'blit', that gets transformed through the palette into a Color array, which then gets stored in a Bitmap (which looks like another big copy); and finally, that gets painted and stretched to fill the canvas/screen. That last operation is in the android library, so I'm hoping that maybe it's hardware supported. Seems like a lot of code being executed in Java for each screen refresh...

Maybe tonight I'll try to get the scene to scroll one tile on each refresh to see how many frames/second it can get.

Maybe it would make more sense to port the C++ code, but it doesn't sound as educational.:-) Also, I think debugging or getting support would be a real problem.
drcode
Site Admin
Posts: 2267
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by drcode »

drcode
Site Admin
Posts: 2267
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by drcode »

I added scrolling around with the arrow keys, and it's pretty slow. If you want to try it, here's where it looks for files:

String base = "/sdcard/Games/exult/blackgate"; // FOR NOW.
addSystemPath("", base + "/PATCH");
addSystemPath("", base + "/STATIC");
addSystemPath("", base + "/GAMEDAT");
Dominus
Site Admin
Posts: 5656
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by Dominus »

Looks very nice. Can't try it since I don't have an android. I'd root more for an iOS port :)
I'm still surprised that you need to do that much hard work for porting to Android. I was really sure that this would be much easier than porting to Java...
But as long as you are enjoying it... :)
--
Read the documentation and the FAQ! There is no excuse for not reading them! RTFM
Read the Rules!
We do not support Piracy/Abandonware/Warez!
drcode
Site Admin
Posts: 2267
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by drcode »

A bit more progress: http://www.facebook.com/photo.php?fbid= ... 1523107292

The Avatar is still a fake (just drawing the shape, he doesn't really exist).
drcode
Site Admin
Posts: 2267
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by drcode »

Getting better: http://www.facebook.com/photo.php?fbid= ... 1523107292

(But the Avatar is still faked.)
TDI

Re: Porting to Android via Java

Post by TDI »

> I think everyone can view this

I can only see those pictures if I login with a facebook account.
dag

Re: Porting to Android via Java

Post by dag »

>> I think everyone can view this

>I can only see those pictures if I login with a facebook account.

Me, too :-(
Dominus
Site Admin
Posts: 5656
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by Dominus »

Jeff, if you don't mind I can put these pictures either on imageshack or dropbox...
--
Read the documentation and the FAQ! There is no excuse for not reading them! RTFM
Read the Rules!
We do not support Piracy/Abandonware/Warez!
drcode
Site Admin
Posts: 2267
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by drcode »

Sure, that would be nice.
Dominus
Site Admin
Posts: 5656
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by Dominus »

http://www.dropbox.com/gallery/7801769/ ... d?h=e27af2
Dropbox Gallery of the four screenshots
--
Read the documentation and the FAQ! There is no excuse for not reading them! RTFM
Read the Rules!
We do not support Piracy/Abandonware/Warez!
i30817
Posts: 38
Joined: Mon May 25, 2020 10:24 am

Re: Porting to Android via Java

Post by i30817 »

The worse part of being a managed language are badly designed api's that even with immutable types are paranoid and copy things into new arrays.

Anyway do you have a repository? I enjoy running findbugs on java code bases and fixing trivial @!#$.
Dominus
Site Admin
Posts: 5656
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by Dominus »

--
Read the documentation and the FAQ! There is no excuse for not reading them! RTFM
Read the Rules!
We do not support Piracy/Abandonware/Warez!
i30817
Posts: 38
Joined: Mon May 25, 2020 10:24 am

Re: Porting to Android via Java

Post by i30817 »

Forgot that android doesn't use java bytecode -> findbugs won't work.
i30817
Posts: 38
Joined: Mon May 25, 2020 10:24 am

Re: Porting to Android via Java

Post by i30817 »

A quick question though: you're trying to keep class to class compatibility between the codebases? There is a ObjectList class that is rather redundant considering the (rather excellent, except for very specialized uses, or primitive collections) java collections api.
drcode
Site Admin
Posts: 2267
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by drcode »

I might look into replacing ObjectList, but it currently has the advantage of not creating new links as objects are moved in and out of it, since the objects themselves have the link pointers.
drcode
Site Admin
Posts: 2267
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by drcode »

The facebook album now shows that the actual NPC's are being created. The next step, which is probably going to take some time, is to have the Avatar be able to walk around.

What sort of interface should there be for moving the Avatar? I assume Android phones have a touch screen, but is there a common way to indicate dragging with a right-mouse button like we do in U7? Or would the arrow keys work, and then use the touch screen for dragging objects?

(Edit by Dominus: dropbox album updated with this screenshot http://www.dropbox.com/gallery/7801769/ ... d?h=e27af2)
i30817
Posts: 38
Joined: Mon May 25, 2020 10:24 am

Re: Porting to Android via Java

Post by i30817 »

There are two places where you are using iterator in the oldest way possible. You should probably use a for each there. I would give you a diff file, but netbeans is being retarded and only allowing me to diff single files, so it would take more time for you to apply that than do it manually.
drcode
Site Admin
Posts: 2267
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by drcode »

Thanks. I'll take a look tomorrow. (Anything to speed things up.)
i30817
Posts: 38
Joined: Mon May 25, 2020 10:24 am

Re: Porting to Android via Java

Post by i30817 »

This won't speed anything up though. I suppose subversion commit rights are out of the question? I wouldn't actually touch the code, just refactor it around when not completely functional (that, now it appears to be).
i30817
Posts: 38
Joined: Mon May 25, 2020 10:24 am

Re: Porting to Android via Java

Post by i30817 »

BTW what's the pathfinding algorithm? It doesn't seem to be anything heavy in code like A* how does it avoid obstacles, and moves actors?
drcode
Site Admin
Posts: 2267
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by drcode »

Exult does use A*. I haven't added that to the Java version yet, but I plan to (although maybe that and a few other algorithms should be kept in C++ and use JNI). Generally, I'm trying to convert our C++ code fairly faithfully to Java, cleaning up a few things in the process. It's been a while since I've worked on Exult and this is giving me the chance to become familiar with the code again.

In ExultAndroid, you can walk right through walls now. Maybe I'll call that a feature.:-)

I'm wondering how the emulator speed compares with real devices. Anyone have experience with this?
Cobalt

Re: Porting to Android via Java

Post by Cobalt »

If they can get this game to run on a PSP you can get it to run on anything.
TDI

Re: Porting to Android via Java

Post by TDI »

>In ExultAndroid, you can walk right through walls now. Maybe I'll call that a feature.:-)

Leave it in the game and activate it as a hidden feature when the player enters: osspispopd
That would be kinda funny.

By the way, I'm amazed at the speed of your progress on this.
drcode
Site Admin
Posts: 2267
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by drcode »

Thanks. What makes it go fast is that I'm mainly translating from C++ to Java, so most things work right away.
i30817
Posts: 38
Joined: Mon May 25, 2020 10:24 am

Re: Porting to Android via Java

Post by i30817 »

I know of a few performing A* implementations in java.

http://keithphw.freehostia.com/LineOfSi ... Sight.jnlp

the javagaming forum is in general, a good place to as performance and api questions.
i30817
Posts: 38
Joined: Mon May 25, 2020 10:24 am

Re: Porting to Android via Java

Post by i30817 »

Ah.

source (note that clicking this link may not work, you may have to paste the link text into your browser window to actually download the zip file):
http://keithphw.freehostia.com/LineOfSight/src.zip
dependency jar (Java Topology Suite):
http://keithphw.freehostia.com/LineOfSight/jts-1.8.jar
Malignant Manor
Site Admin
Posts: 985
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by Malignant Manor »

Is the Android specific coding minimal enough that this could easily be made allow for platform independence?
drcode
Site Admin
Posts: 2267
Joined: Thu May 14, 2020 1:34 pm

Re: Porting to Android via Java

Post by drcode »

There's some Android-specific code for handling events and painting the screen. The rest is pretty standard Java, I think.

Might be nice if someone implemented the Android Java libraries for use on a regular (Linux) PC. I'd imagine the performance would be a lot better, so I wouldn't have to wait 5 minutes for the debugger to get started.
Locked