The International Simutrans Forum

Community => Simutrans Gaming Discussion => Topic started by: zodttd on February 27, 2009, 08:56:38 pm

Title: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on February 27, 2009, 08:56:38 pm
Hello from ZodTTD of ZodTTD.com!

I've been in contact with Hajo and prissi about a port of Simutrans to the iPhone & iPod Touch. I made many similar ports before (OpenTTD for jailbroken iPhones for instance), though Simutrans is a perfect fit!
I will be in close contact with everyone here on my progress, and be sure to submit my sources back. It is planned for AppStore as a free release.

Considering I have ported SDL over to the iPhone for my quick OpenTTD port, if SDL is needed, that is not a problem. There are times replaces SDL calls with calls to Apple's API (within a wrapper) is better, but that will be determined soon enough. My main concerns are playability on the landscape 480x320 resolution screen. I have been in discussion on how to handle the size of objects with such a small screen with a high resolution.

I'm wide open to feedback and comments. I am beginning the port today, and will be needing some beta testers soon. I move fast, so it will be less than a week to get some beta (AdHoc as Apple calls them) builds to you if all is well. :)

Of note, my nickname ZodTTD is for my port of OpenTTD to the Tapwave Zodiac years ago. Perhaps it's time for a new nickname. ;)

I'm glad to be joining this community! Thanks so much,
ZodTTD
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: Fabio on February 27, 2009, 09:06:45 pm
Welcome! I think your idea is simply great!

We had a pak32.comic, probably this size would be the best to start with

http://forum.simutrans.com/index.php?topic=1471.0

(http://www.simutrans.com/images/pak32-1.png)(http://www.simutrans.com/images/pak32-2.png)(http://www.simutrans.com/images/pak32-3.png)
Quote
Born from some wierd idea to make some comic-style buildings, pak32.comic was concieved. It is there, if there will be ever done a simutrans version for PDAs ...
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on February 27, 2009, 09:12:22 pm
fabio: Hi! And thanks! prissi recommended pak32. pak32.comic looks great! Seems to fit in very well like the quote states.

Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: jamespetts on February 27, 2009, 11:50:17 pm
Fascinating project - and, at last, a use for Pak32.Comic!
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on February 28, 2009, 04:48:09 pm
Update!
I have Simutrans up and running on the iPhone! So far this has been a very clean and tidy port too!
I'm working at getting sound enabled, improving performance, and all the rest. At the moment all I can say is Simutrans loaded on the iPhone and displayed the in-game menu and playfield. I had touch controls disabled at the moment, so I need to enable them now! Exciting!

There is a chance I will need to rewrite the SDL port some, though. Beyond that looks like things will be progressing even faster than expected! Not bad for a late night. ;)

Thanks everyone!
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: vilvoh on February 28, 2009, 05:32:38 pm
woW, how fast! Do you have any image or video of the port running on the iphone?
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on February 28, 2009, 05:48:53 pm
Screenshots coming soon! Want to fix up some things in SDL first. :)
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: Silver on February 28, 2009, 06:35:41 pm
mmm very complicated right? but, not impossible!

first, an fusion of the executable and the pak, after it, launch versions for PDA or Cell (ext.: .jad or .jar)

result: many months of work

Edit.

netbeans maybe serve as a program known this to begin developing the idea.
Push here (http://www.netbeans.org/)
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on February 28, 2009, 11:10:37 pm
(http://www.zodttd.com/images/Screenshot-2009.02.28-17.57.53.jpg)

Here's a screenshot I took right off the iPhone. I rotated it 90 degrees to the right since the iPhone is oriented landscape when playing.
Everything is working except music, which may not be implemented right away...at least until I port over something like the Timidity library for MIDI output.

You'll notice due to the 480x320 resolution, the text on the status bar tends to run over each other. Also the 'create a new game' seems to be a bit too tall.

I'd like to know if there is an option for auto scroll around the map when the cursor is on the edge of the screen...or if I could use a right click to move around the map?

The closing of windows is hard due to the X in the corner being a bit too small still.

Everything else works, including sound effects. I'll be sure to keep everyone updated. If anyone here has a suggestion, I'd like to know it! :)

Thanks,
ZodTTD
http://www.zodttd.com
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: jamespetts on February 28, 2009, 11:15:29 pm
This is rather impressive!
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: vilvoh on March 01, 2009, 12:16:21 am
Two thumbs up for this great port! althought reading the comments on your website, people would prefer an OpenTTD port... :D
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on March 01, 2009, 12:19:49 am
LOL @ the OpenTTD port. I considered it, but OpenGFX isn't far enough along, and sound/music are still copyrighted.
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on March 01, 2009, 03:48:24 am
By any chance, does anyone here have a (jailbroken?) iPhone or iPod Touch and some time to try a build/suggest some playability enhancements?
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on March 01, 2009, 03:52:43 am
Pak64 on iPhone:
(http://www.zodttd.com/images/Screenshot-2009.02.28-22.48.24.jpg)
Pak96.comic also works. I tried Pak128 but it consumes too much memory for the iPhone.
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: jamespetts on March 01, 2009, 10:26:51 am
Very impressive! I think that you'll have to change the text such that there's less of it at the bottom, though.
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: VS on March 01, 2009, 10:35:47 am
Some menu icons are hidden.

That could be solved by adapting the whole menu system to smaller icons (already possible on pak level!) - all it needs is rewriting a few numbers and making the icons smaller.
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: vilvoh on March 01, 2009, 12:43:44 pm
Looks better than I thought... :)
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: Fabio on March 01, 2009, 02:00:24 pm
that's great! bravo!

(pak64 is impressive there, but on an iphime i'd rather use ABO pak 64)
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: prissi on March 01, 2009, 07:17:47 pm
One could add another date setting, like six to display a compat date like
26.1.1935 23h and save a lot of space. Also the name of the company may be replaced by the color of the income and the obey era is not show. Then this shoudl work on small screens.
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: Fabio on March 01, 2009, 07:43:03 pm
The name of the company may be replaced by the color of the income

and what about the debts which are in red???
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on March 01, 2009, 08:34:47 pm
Thanks for the input! I'm working on the suggestions as we speak!
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on March 01, 2009, 08:35:37 pm
Which menu icons are missing though?
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: prissi on March 01, 2009, 08:46:32 pm
All the ones right outside the screen ... there is a file menuconf.tab, and it would allow you to set any menu size. Thus, if one of the grphics people would make buttons 20x20 instead 32x32 then such a menu would fit on the screen (and also such toolsbars would need way less space). This can be done today, just the images needs to be adjusted in the pak-files.

That is why I think you it would be best if some of the graphic artists would ****ist to adapt a pakset to the resolution.
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on March 01, 2009, 09:00:57 pm
Thanks prissi! That would be great! I'm moving fast!

One semi-important usability issue is that when someone moves their finger off the edge of the screen, it's (currently) considered a mouse up event. I am not sure how to handle this just yet. But what happens is someone drags their finger off the screen and whatever action is selected, such as laying down tracks, it activates due to the mouse up event.

One thing I added was the ability to "scroll the map" when the cursor is on the edge of the screen.

So I could disable mouse up events along the border/edges of the gameplay area to avoid this, but then window placement must respect that rule so they can be moved and closed properly.

To some extent this must be done already, since it's very hard to close a window on the very edge of the iphone screen. Registering touch events in about a 20 pixel area along the edge of the iphone screen is difficult, but give it 30-50 pixels and its fine. So two things can be done in this area. Either place all windows a bit inward from the edge of the screen (I do this in my test builds a bit already), or make the menu's top bar larger to allow for larger "X" icons to close, etc. If the menu size settings change this, that would be really great!

The only other issue is the height of a few windows such as "Create a New Game" are too tall to fit on the 320px high iPhone screen. I'm trying to avoid taking a larger screen and scaling down to the 480x320 screen if at all possible. Not sure how to handle this one yet either.
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: Frank on March 01, 2009, 09:45:20 pm
All the ones right outside the screen ... there is a file menuconf.tab, and it would allow you to set any menu size. Thus, if one of the grphics people would make buttons 20x20 instead 32x32 then such a menu would fit on the screen (and also such toolsbars would need way less space). This can be done today, just the images needs to be adjusted in the pak-files.

That is why I think you it would be best if some of the graphic artists would ****ist to adapt a pakset to the resolution.

there exists a version of pakHAJO with 24x24 buttons

http://sourceforge.net/project/showfiles.php?group_id=196471&package_id=251094&release_id=653583 (http://sourceforge.net/project/showfiles.php?group_id=196471&package_id=251094&release_id=653583) pakHAJO_24x24_0-101.zip

a older screenshot
(http://simutrans-germany.com/simu_install/0-99-18/pakHAJO_24er-Buttons.png) (http://simutrans-germany.com/simu_install/0-99-18/pakHAJO_24er-Buttons.png)
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on March 01, 2009, 09:54:44 pm
Thanks, installing it now to try it out!
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on March 01, 2009, 10:08:55 pm
(http://www.zodttd.com/images/Screenshot-2009.03.01-17.04.17.jpg)

Seems HAJO with 24x24 (until other paks get 24x24 icons) might work out the best for iPhone so far!
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: prissi on March 02, 2009, 09:52:48 am
SInce the iPhone has an orientation sensor and simutrans support resolution changes on the fly, one could think that the problems with dialogues could be fixed by rotation of the screen.

(BTW: THere are some Quick time based sound routines in the sound and music folder. Maybe they are useful for creating sound on the mac then. Timidity is overkill ... )
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: mobo on March 02, 2009, 11:37:27 am
Very intersting, and impressive!

I'm really considering, to change the buttons on p32 comic now. I didnt know i really could (and how) before i read this.

Which size would be good? 20x20?

The problem is: this is some effort, and will take some time (I'm really slow, especially with boring tasks), and the pakset still isn't complete after this, there are still many objects missing, so it isn't really playble yet, and i would rather not "release" it officially when it's only half finished (you know people will think "simutrans sucks" instead of "this pak set has not all the features possible").
So it'd be better to concentrate on vehicles first. They don't have buttons (so I don't work further in the wrong direction), and they're the most important objects to make it playable.

BTW: changing the buttons of a well working set is not much more effort, and maybe sometimes easier, because in some sets they're separated from the object they belong to (and now i even understand why that makes sense  ;) ).
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on March 03, 2009, 09:32:42 pm
prissi: I will try the  on the fly rotation of the screen technique, if possible within my SDL setup.

mobo: The final say on icon sizes will depend if I will rotate to portrait mode, which leaves only 320px width for the toolbar. Note that the iPhone version won't need the screenshot icon, and perhaps the two spacer icons can be removed as well? So that would be 17 icons. So plan for 19 pixel wide icons, though that number could change soon. Do the icons have to be square? Perhaps 19x30 icons would make things easier to tap on the iPhone.
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on March 03, 2009, 09:38:53 pm
I've also added multitouch scrolling to Simutrans on the iPhone via my SDL port.

One thing I really need help with is tracking down a bug:
Process to reproduce bug: build a garage, build station 1 -> build station 2 -> tap garage -> add new line -> select a valid location such as a station or road
Once that sequence is made I get a segfault.

In my attempts to debug I was using your debug mode + stderr. I will use a log file instead, since it seems stderr is delayed on the iPhone even with fflush. So far it seems the bug is within:
simworld.cc: void karte_t::interactive_event(event_t &ev)

I'll try to provide more debug info shortly. Thanks!
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on March 03, 2009, 10:00:18 pm
Update to the bug hunt:
I added logging by text file and found out the crash is within...
EDIT:
void karte_t::sync_step(long delta_t, bool sync, bool display )
within the function inside it:
intr_refresh_display( false );

So I'm stepping through intr_refresh_display now... Fun times. :P
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: prissi on March 03, 2009, 10:51:39 pm
This is the routine that draws everything (we are doing cooperative multitasking). We had some errors with ggc 4.xx which aparently produces some wrong clipping coordinates in the schedule window. Maybe it is related to this.

valgrind is probably not an option on a iPhone ...

By the way, non-rectangular buttons (19x30) are perfectly possible.
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on March 03, 2009, 10:57:56 pm
Ah this would make sense!
I traced things further and found:
The segfault is further within "display_win" and more specifically at the line:
komp->zeichnen(wins[win].pos, gr);

The disp_height was clipped to 288 from 320 in win_display_flush.

I'm forced to use GCC 4.x in this case. Any workarounds at the moment?
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on March 03, 2009, 11:01:21 pm
In the meantime I will try to fix the clipping issue in GCC 4.x. I might know why...
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: prissi on March 03, 2009, 11:02:26 pm
I am not sure, but maybe the problem is the dirty tile puffer is written into negative values?

One workaround would be to have some extra buffer around *textur [pseudocode textur=malloc(width*(height+32)*2)+width*16] Since on Windows debugging GCC ist crap, and GCC 4.0 is not yet stable (sigh) I did not yet dug deeper in it. If that helps, then maybe there is another error in the program. (Btw. you use the code from the svn?)
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on March 03, 2009, 11:10:41 pm
Ok, I will look into that. Also yes, I use the code from the SVN. :)
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on March 04, 2009, 02:58:34 am
I isolated the bug, and by removed the following code, the crash no longer occurs. Researching a fix now...

In the function: fahrplan_gui_t::fahrplan_gui_t
Commenting out this code within that function gets rid of the segfault crash:
#if 0
   ypos += BUTTON_HEIGHT;
   scrolly.set_pos( koord( 0, ypos ) );
   // scrolly.set_show_scroll_x(false);
   add_komponente(&scrolly);
#endif
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on March 04, 2009, 03:09:18 am
More specifically the crash is here:
Function: void gui_scrollpane_t::zeichnen(koord pos)
Line: if(old_komp_groesse!=komp->get_groesse()) {

Im going to look into the get_groesse() function now...So close to a fix!
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on March 04, 2009, 05:00:35 am
YAY! I fixed the bug! There was a buffer overflow occuring that threw off everything on the iPhone. It's a simple fix:
Inside: void fahrplan_gui_t::gimme_stop_name(cbuffer_t & buf, karte_t *welt, const schedule_t *fpl, int i, int max_chars)
Change: char tmp [256];
To: char tmp [512];

The reason was the max_chars p****ed to the function is 512, the size of 'buf'. But tmp was only 256 chars. Increasing it to the proper 512 fixed this bug!
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: Dwachs on March 04, 2009, 07:15:37 am
Change: char tmp [256];
To: char tmp [512];
Thank you!
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: zodttd on March 04, 2009, 07:17:08 am
No problem. :)
That was a tricky bug to find! Glad it's fixed though, things are going smoothly for this port! I'm seeking out beta testers.
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: puzzler995 on July 25, 2009, 02:45:26 pm
you really need to update it. we should develop a pak just for it! :D
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: jamespetts on July 25, 2009, 02:50:00 pm
i.Pak? ;-)
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: Michael 'Cruzer' on July 25, 2009, 03:34:09 pm

No pak.i32 ^^
We must be simutrans conform! :D
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: IgorEliezer on July 25, 2009, 04:47:04 pm
Pakset name standard:

pak<size>.<theme>

Examples:

pak96.cominc
pak128.Japan
pak128.Britain
Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: mwoodburn81 on July 25, 2009, 04:51:30 pm
The iPhone port also needs:

 - a keyboard interface
 - bigger buttons to close and move windows etc.
 - a better way to scroll around the map

Having it's own pak set would help too :-)

Title: Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
Post by: egoadsr on March 25, 2010, 06:54:00 am
Hello all

Simutrans can be one of the best app of the appstore !

There are some problem of ergonomy, id don't know what it is possible and what not.

Add some dropdown menus, maybe use multitouch to zoom screen...

But... does this project is active, or have you abandoned it ?

P.S: Sorry for my poo english, and thanks a lot cause i have discovered this "so nice" game with you :)