The International Simutrans Forum

 

Author Topic: Compiling for MAC  (Read 6651 times)

0 Members and 1 Guest are viewing this topic.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10822
  • Languages: De,EN,JP
Compiling for MAC
« on: August 04, 2008, 09:36:01 PM »
I had on my PowerMAC emulator a try to compile allegro and simutrans for Allegro. I worked quite nice, much faster imho than with SDL. Also it should be able to use sound and midis (which crash my emulator). It could be even bundled to a simple one click install. Maybe Allegro (http://www.liballeg.org) is another good way to go for MAC.

topchrisher

  • Guest
Re: Compiling for MAC
« Reply #1 on: August 04, 2008, 11:46:25 PM »
I will investigate this as quickly as possible, which means that in six months there will be a result.  And I'm only half-kidding.

Offline leopard

  • Devotees (Inactive)
  • *
  • Posts: 97
  • Life in the Urban Jungle
    • A Leopard's Tail
Re: Compiling for MAC
« Reply #2 on: August 05, 2008, 05:22:19 PM »
on the assumption I can get it to compile as part of the game I've sort of got an apple native midi routine running, expanding this to wave audio is theoretically pretty simple. just having fun mixing objective-c and c++ currently.

not given up but will almost certainly end up back on the command line

:-)

Offline leopard

  • Devotees (Inactive)
  • *
  • Posts: 97
  • Life in the Urban Jungle
    • A Leopard's Tail
Re: Compiling for MAC
« Reply #3 on: August 05, 2008, 06:33:13 PM »
Now have managed to get my little objective-c MIDI playing routine functioning, using the quicktime library. the quality is much better than the SDL MIDI routine.

compile problem solved by changing the file name from *.m to *.mm, go figure (something about the difference between c and c++).

there are still a few compile warnings I want to eliminate, and it needs fully testing but it works.

then the wave audio engine, which will be basically the same functions.

not got a clue how to integrate this into the main source, and don't want access, since I will break something, but once its tested the *.m file and the required linker flags will get posted somewhere for general review

:-)


topchrisher

  • Guest
Re: Compiling for MAC
« Reply #4 on: August 06, 2008, 12:33:04 AM »
I'm not really sure what this is about - is it compiling without Allegro or SDL?  Or is it about moving to Allegro?  Please explain!

Offline leopard

  • Devotees (Inactive)
  • *
  • Posts: 97
  • Life in the Urban Jungle
    • A Leopard's Tail
Re: Compiling for MAC
« Reply #5 on: August 06, 2008, 06:10:42 PM »
well its still using SDL for the display, and using apple native libraries for sound, in this case QuickTime driving core audio & core audio midi (indirectly).

looking at porting SDL to work in a cocoa window, and eventually direct drawing (maybe)

Offline leopard

  • Devotees (Inactive)
  • *
  • Posts: 97
  • Life in the Urban Jungle
    • A Leopard's Tail
Re: Compiling for MAC
« Reply #6 on: August 06, 2008, 08:07:00 PM »
Ok this is a test binary, should work on a normal intel mac (this is not universal). based on 100.01.19.

this should only require the normal frameworks as opposed to anything "funny" on my own system.

been looking at how to make this 'mac native' in so far as double clickable from within finder, apparently this binary can be put into an application bundle, along with an info file and it should "just work". I just need to sort out how to write the info file to see if thats actually true.

if it is then compiling a PPC version for the same bundle is possible.

but if someone with an intel mac can see if this works, and if they get midi files to play then I know my build process is working.

http://www.aleopardstail.com/res/sim-100.01-1930.zip 150k Zip file

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10822
  • Languages: De,EN,JP
Re: Compiling for MAC
« Reply #7 on: August 06, 2008, 08:07:49 PM »
Direct Drawing may not really help you speedwise. Quicktime windows will be fast enough, looking at OpenTTD code. Simutrans is just a big bitmap, that is copied to the screen.

The most tedious part will be the event catching a distributing on MAC imho.

EDIT: wow, this was fast. Do you have the diff for this?

Offline leopard

  • Devotees (Inactive)
  • *
  • Posts: 97
  • Life in the Urban Jungle
    • A Leopard's Tail
Re: Compiling for MAC
« Reply #8 on: August 06, 2008, 08:12:58 PM »
diff?

not as yet, the source isn't fully error trapped as yet, also my makefiles etc have been butchered slightly, if this works what I plan to do is download a new 'clean' nightly, and merge my changes with that, so you don't get all the rubbish.

the binary has my midi & wave audio code included, but otherwise no changes

Offline Ashley

  • Coder/Patcher
  • Devotees (Inactive)
  • *
  • Posts: 1288
    • entropy.me.uk
Re: Compiling for MAC
« Reply #9 on: August 07, 2008, 08:57:18 AM »
Do svn diff > somefile.diff from within the repository root on your local machine.

Offline leopard

  • Devotees (Inactive)
  • *
  • Posts: 97
  • Life in the Urban Jungle
    • A Leopard's Tail
Re: Compiling for MAC
« Reply #10 on: August 07, 2008, 06:35:13 PM »
I think I may have this right, least I hope I have.

attached are the diff file which will (I think) adjust:
- common.mk (To add the support for objective-c files)
- makefile (adding a section for a cocoa backend)
- config.template (to add the cocoa backend option)

in addition there are two new files, which add the sound support
core-audio_sound.mm --> /sound
core-audio_midi.mm --> /music

the audio routines are not fully error trapped as yet, but they work here, will be very interested to see if they work for other people. these files will be updated as I get more testing done.

for people used to c++ and c these files may look a tad odd, but thats objective-c for you.

the cocoa backend current uses SDL for everything except audio, I will at some point try to change this.

Offline leopard

  • Devotees (Inactive)
  • *
  • Posts: 97
  • Life in the Urban Jungle
    • A Leopard's Tail
Re: Compiling for MAC
« Reply #11 on: August 07, 2008, 06:36:16 PM »
if this doesn't work, let me know and I'll try to upload the actual makefile etc. not used to diff but this appears to be right.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10822
  • Languages: De,EN,JP
Re: Compiling for MAC
« Reply #12 on: August 22, 2008, 08:02:07 PM »
Commited your changes (after some Makefile editing) to the trunk. Instead of cocoa it is still sdl as backend, together with mac. Please test the makefile.