The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: prissi on August 04, 2008, 09:36:01 pm

Title: Compiling for MAC
Post by: prissi 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.
Title: Re: Compiling for MAC
Post by: topchrisher 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.
Title: Re: Compiling for MAC
Post by: leopard on August 05, 2008, 05:22:19 pm
on the ****umption 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

:-)
Title: Re: Compiling for MAC
Post by: leopard 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

:-)

Title: Re: Compiling for MAC
Post by: topchrisher 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!
Title: Re: Compiling for MAC
Post by: leopard 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)
Title: Re: Compiling for MAC
Post by: leopard 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 (http://www.aleopardstail.com/res/sim-100.01-1930.zip) 150k Zip file
Title: Re: Compiling for MAC
Post by: prissi 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?
Title: Re: Compiling for MAC
Post by: leopard 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
Title: Re: Compiling for MAC
Post by: Ashley on August 07, 2008, 08:57:18 am
Do svn diff > somefile.diff from within the repository root on your local machine.
Title: Re: Compiling for MAC
Post by: leopard 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.
Title: Re: Compiling for MAC
Post by: leopard 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.
Title: Re: Compiling for MAC
Post by: prissi 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.