The International Simutrans Forum

 

Author Topic: Port of Simutrans to the iPhone & iPod Touch (AppStore)  (Read 27739 times)

0 Members and 1 Guest are viewing this topic.

Offline zodttd

  • *
  • Posts: 23
Port of Simutrans to the iPhone & iPod Touch (AppStore)
« 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

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #1 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


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 ...

Offline zodttd

  • *
  • Posts: 23
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #2 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.


Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18752
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #3 on: February 27, 2009, 11:50:17 PM »
Fascinating project - and, at last, a use for Pak32.Comic!

Offline zodttd

  • *
  • Posts: 23
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #4 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!

Offline vilvoh

  • One of the good guys
  • Administrator (Inactive)
  • *
  • Posts: 4504
  • I'm the constructor, the architect
    • Escala real
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #5 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?

Offline zodttd

  • *
  • Posts: 23
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #6 on: February 28, 2009, 05:48:53 PM »
Screenshots coming soon! Want to fix up some things in SDL first. :)

Offline Silver

  • *
  • Posts: 596
  • ***Strategy and Success***
    • Simutrans-Hispano
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #7 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
« Last Edit: February 28, 2009, 08:44:11 PM by Silver »

Offline zodttd

  • *
  • Posts: 23
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #8 on: February 28, 2009, 11:10:37 PM »


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

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18752
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #9 on: February 28, 2009, 11:15:29 PM »
This is rather impressive!

Offline vilvoh

  • One of the good guys
  • Administrator (Inactive)
  • *
  • Posts: 4504
  • I'm the constructor, the architect
    • Escala real
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #10 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

Offline zodttd

  • *
  • Posts: 23
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #11 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.

Offline zodttd

  • *
  • Posts: 23
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #12 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?

Offline zodttd

  • *
  • Posts: 23
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #13 on: March 01, 2009, 03:52:43 AM »
Pak64 on iPhone:

Pak96.comic also works. I tried Pak128 but it consumes too much memory for the iPhone.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18752
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #14 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.

Offline VS

  • Senior Plumber (Devotee)
  • Devotee
  • *
  • Posts: 4855
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #15 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.

Offline vilvoh

  • One of the good guys
  • Administrator (Inactive)
  • *
  • Posts: 4504
  • I'm the constructor, the architect
    • Escala real
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #16 on: March 01, 2009, 12:43:44 PM »
Looks better than I thought... :)

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #17 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)

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9583
  • Languages: De,EN,JP
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #18 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.

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #19 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???

Offline zodttd

  • *
  • Posts: 23
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #20 on: March 01, 2009, 08:34:47 PM »
Thanks for the input! I'm working on the suggestions as we speak!

Offline zodttd

  • *
  • Posts: 23
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #21 on: March 01, 2009, 08:35:37 PM »
Which menu icons are missing though?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9583
  • Languages: De,EN,JP
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #22 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 assist to adapt a pakset to the resolution.

Offline zodttd

  • *
  • Posts: 23
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #23 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.

Offline Frank

  • Inactive/Retired
  • *
  • Posts: 1431
  • Languages: DE
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #24 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 assist 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 pakHAJO_24x24_0-101.zip

a older screenshot
« Last Edit: March 01, 2009, 09:54:41 PM by Frank »

Offline zodttd

  • *
  • Posts: 23
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #25 on: March 01, 2009, 09:54:44 PM »
Thanks, installing it now to try it out!

Offline zodttd

  • *
  • Posts: 23
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #26 on: March 01, 2009, 10:08:55 PM »


Seems HAJO with 24x24 (until other paks get 24x24 icons) might work out the best for iPhone so far!

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9583
  • Languages: De,EN,JP
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #27 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 ... )

Offline mobo

  • Devotees (Inactive)
  • *
  • Posts: 199
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #28 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  ;) ).
« Last Edit: March 02, 2009, 12:08:41 PM by mobo »

Offline zodttd

  • *
  • Posts: 23
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #29 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.

Offline zodttd

  • *
  • Posts: 23
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #30 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!

Offline zodttd

  • *
  • Posts: 23
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #31 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
« Last Edit: March 03, 2009, 10:26:33 PM by zodttd »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9583
  • Languages: De,EN,JP
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #32 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.

Offline zodttd

  • *
  • Posts: 23
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #33 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?

Offline zodttd

  • *
  • Posts: 23
Re: Port of Simutrans to the iPhone & iPod Touch (AppStore)
« Reply #34 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...