Initial AGS Engine Source Code release

Started by Pumaman, Wed 27/04/2011 01:55:57

Previous topic - Next topic

GrogGames

#100
i tried to compile ags port from http://gitorious.org/ags  in ubuntu 11.04 i386 live cd.
I installed all the libraries with synaptic, except allegro libalfont and libcda. For libcda and libalfont i used this
for libalfont
Code: ags

gcc -fPIC -DPIC -O2 -m32 -Iinclude `freetype-config --cflags` -o src/alfont.o -c src/alfont.c
gcc -O2 -m32 -shared -Wl,-soname,libalfont.so.2 -o libalfont.so.2.0.9 src/alfont.o `freetype-config --libs` `allegro-config --libs |sed 's/-lalleg_unsharable//'`
install -m 755 libalfont.so.2.0.9 /usr/lib/
install -m 644 include/alfont*.h /usr/include/
ln -s libalfont.so.2.0.9 /usr/lib/libalfont.so.2
ln -s libalfont.so.2.0.9 /usr/lib/libalfont.so.2
ln -s libalfont.so.2.0.9 /usr/lib/libalfont.so


For libcda
Code: ags

gcc -O2 -m32 -fPIC -DPIC -o linux.o -c linux.c
gcc -O2 -m32 -g -shared -Wl,-soname=libcda.so.0 -o libcda.so.0 linux.o
install -m 755 libcda.so.0 /usr/lib/
mkdir /usr/include/libcda
install -m 644 libcda.h /usr/include/libcda/
ln -s libcda.so.0 /usr/lib/libcda.so

for allegro, i downloaded the 4.4 source and compiled.
that works fine, but when i try to compile ags, i received this message
Code: ags

Linking CXX executable ags
/usr/lib/libalfont.so: undefined reference to `_msize'
collect2: ld returned 1 exit status
make[2]: *** [Engine/ags] Error 1
make[1]: *** [Engine/CMakeFiles/ags.dir/all] Error 2
make: *** [all] Error 2



thanks for help, sorry if I express wrong, i speak spanish :P

JawCross

I have also problems with Ubuntu. I first tried under 64 bit, but now I'm trying with 32 bit.

I copied instructions from forum to the wiki:
https://gitorious.org/ags/pages/HowToBuild#Building+under+Ubuntu
I fixed one non-printing character and ln -s libalfont.so.2.0.9. (Are these correct now?)


My problem is cmake is not founding alfont and libcda. Is there still some details missing in instructions?

GrogGames

#102
Quote from: JawCross on Tue 17/05/2011 09:40:58
I have also problems with Ubuntu. I first tried under 64 bit, but now I'm trying with 32 bit.

I copied instructions from forum to the wiki:
https://gitorious.org/ags/pages/HowToBuild#Building+under+Ubuntu
I fixed one non-printing character and ln -s libalfont.so.2.0.9. (Are these correct now?)


My problem is cmake is not founding alfont and libcda. Is there still some details missing in instructions?
YES!  =)
i found that details!
check the wiki now, i added that details.

A question, when you run "cmake .". Do you not receive a message "package allegro not found"?
With allegro 4.2 i receive that message, then i has to compile allegro 4.4, and the message disappeared.


with that instructions now compile! thanks  =)

JawCross

I tested under Ubuntu 10.10 (Maverick).

cmake gives "package allegro not found"? But it doesn't brake and make will also pass.


JawCross

I tried compile Editor under Ubuntu (10.10) using mono.
There were some trivial issues* I fixed and pushed my git clone.

Compiling stops on error "Compiler crashed with code: 1"
I do not know how to proceed with it.

*Fixed:
- error CS1587: XML (error about comments)
- "value never used"-warnings are treated as error
- used small d, but filename has capital D.

-
Steps to reproduce
sudo apt-get install mono-xbuild mono-2.0-devel libmono-winforms*

git clone git://gitorious.org/~aaporantalainen/ags/aaporantalainens-ags.git ags
cd ags/Editor
xbuild AGS.Editor.NoNative.sln


Electroshokker

QuoteMost internalized libraries are fixed by now, with the notable exception of AGS overriding allegro’s pack_fopen.
This can probably not be fixed without getting a patch into Allegro

Heheheh... actually, it CAN be fixed without getting a patch into Allegro... at least for the linux build.

I'll dig through my sources and give you guys a set of pointers and examples. For now, take a look at this linker command:
Code: ags
-Wl,-wrap,pack_fopen

If you look it up you'll find the technique I used...

------

Hmm... this thread is getting cluttered with people trying to build the source for windows, linux, mac, ... I propose using a section in the AGS wiki to coördinate this stuff, rather than lots of people setting up their own project site.

I'll post a link to the wiki here as soon as I've set it up. (this evening, don't have time right now)

RedDwarf

#106
Quote from: Electroshokker on Tue 17/05/2011 14:08:13Heheheh... actually, it CAN be fixed without getting a patch into Allegro... at least for the linux build.

I'll dig through my sources and give you guys a set of pointers and examples. For now, take a look at this linker command:
Code: ags
-Wl,-wrap,pack_fopen

If you look it up you'll find the technique I used...
That doesn't seems to work. The idea seems to be that allegro functions also use ags's pack_fopen (otherwise would be no need to name that function pack_fopen). Since allegro wasn't compiled with the wrap functions this trick doesn't work.

Anyway I created two branches:
- allegro_wrap: Uses Electroshokker trick. Probably depends on GNU ld and as explained I don't think it really works... but I could not find problems when using it.
- allegro_wrap2: When available, uses a GLIBC extension for dlsym which makes the internal pack_fopen functions unneeded. In this case allegro functions also use it.


Totally unrelated, with mpg123 1.13.3 I don't get any MP3 sounds (cat in KQ3). It worked before with the internal copy. It's just me?

Calin Leafshade

Quote from: JawCross on Tue 17/05/2011 13:56:30
I tried compile Editor under Ubuntu (10.10) using mono.

Not a great deal of point. The AGS Editor is not pure .net and uses alot of P/Invoke calls for the debugger.

To make the editor work coherently you would need to completely rewrite the debugger interface on both the editor and the engine

RedDwarf

Quote from: RedDwarf on Tue 17/05/2011 16:20:34Totally unrelated, with mpg123 1.13.3 I don't get any MP3 sounds (cat in KQ3). It worked before with the internal copy. It's just me?
The code, at the very least, lacks a call to mpg123_init().
bero, the code was untested or you forgot to add a file in the commit?

Electroshokker

Quote from: RedDwarf on Tue 17/05/2011 16:20:34
Quote from: Electroshokker on Tue 17/05/2011 14:08:13Heheheh... actually, it CAN be fixed without getting a patch into Allegro... at least for the linux build.

I'll dig through my sources and give you guys a set of pointers and examples. For now, take a look at this linker command:
Code: ags
-Wl,-wrap,pack_fopen

If you look it up you'll find the technique I used...
That doesn't seems to work. The idea seems to be that allegro functions also use ags's pack_fopen (otherwise would be no need to name that function pack_fopen). Since allegro wasn't compiled with the wrap functions this trick doesn't work.

Anyway I created two branches:
- allegro_wrap: Uses Electroshokker trick. Probably depends on GNU ld and as explained I don't think it really works... but I could not find problems when using it.
- allegro_wrap2: When available, uses a GLIBC extension for dlsym which makes the internal pack_fopen functions unneeded. In this case allegro functions also use it.


Totally unrelated, with mpg123 1.13.3 I don't get any MP3 sounds (cat in KQ3). It worked before with the internal copy. It's just me?


Ahum, it's not simply a matter of adding this command, you have to change the ags code using wrapper functions which point to the real function. If you do that, you don't have to change the AGS library.

see (just dug up this link, there are other locations which explain it better) http://stackoverflow.com/questions/3662856/how-to-reimplement-or-wrap-a-syscall-function-in-linux

If you can't work this out, I'll post my entire ags code section which uses this when I'm on my home pc. (at work now)

RedDwarf

#110
Quote from: Electroshokker on Wed 18/05/2011 11:16:10Ahum, it's not simply a matter of adding this command, you have to change the ags code using wrapper functions which point to the real function. If you do that, you don't have to change the AGS library.

see (just dug up this link, there are other locations which explain it better) http://stackoverflow.com/questions/3662856/how-to-reimplement-or-wrap-a-syscall-function-in-linux

If you can't work this out, I'll post my entire ags code section which uses this when I'm on my home pc. (at work now)
I know it isn't just adding the linker command. You have the full commit at https://gitorious.org/~reddwarf/ags/reddwarfs-ags/commit/f4099e49bd0b5896091eab61086f6dad9539e16c

But what it does is modify references to pack_fopen into __wrap_pack_fopen, and references to __real_pack_fopen into pack_fopen. It does not change the definitions, so you end with an ags executable with a symbol table that includes a __wrap_pack_fopen definition, no a pack_fopen definition. So, when loading the allegro library (dynamically linked), the loader will resolve references to pack_fopen to the internal library definition... since there is no other pack_fopen definition.
The references to pack_fopen in the allegro_library are never changed to __wrap_pack_fopen since the allegro library wasn't linked with the -wrap option.

To make it clear. If you run this code
Code: ags
#include <stdio.h>
#include <allegro.h>

PACKFILE *__real_pack_fopen(const char *, const char *);

PACKFILE *__wrap_pack_fopen(const char *filnam, const char *modd) {
  printf("Wrapper_function\n");
  __real_pack_fopen(filnam, modd);
}

int main() {
    load_wav("sample.wav");
    printf("Separator\n");
    pack_fopen("sample.wav", "r");
    return 0;
}


You get
QuoteSeparator
Wrapper_function
even when load_wav internally calls pack_fopen.

JawCross

I tested AGS on Linux-ARM. I got it compiled and it can be started, but it is not really working yet.

I collected every build warnings to: https://gitorious.org/ags/pages/StateOfArmSupport

Currently I know only one game, which is working with AGS-3.21: Kings Quest III Redux. Can you suggest some more test cases?

This is what I get in terminal:
./ags Kq3Redux.exe
Code: ags

Adventure Creator v3.21 Interpreter
Copyright (c) 1999-2001 Chris Jones

ACI version 3.21.1115
Speech sample file found and initialized.
Audio vox found and initialized.
Checking sound inits.
install_sound(-1,-1)

Unable to initialize your audio hardware.
[Problem: ALSA: snd_pcm_hw_params_set_format(pcm_handle, hwparams, format) : Invalid argument]


On the screen I get Game's logo, but after half a second it will be messed (see: http://imageshack.us/f/801/screenshot2011051815332.png ). Then nothing happens until I press key or mouse and then it dies silently.

So there are issues with (at least) audio and graphics, but are some of them fatal (why it shutdowns)?

JJS

#112
I am working on a PSP port right now, which is basically done except for the onscreen keyboard and customizable controls.

The PSP has a MIPS processor and you may have the same problem on ARM. The script engine regularly casts values to int pointers which are not 4 byte aligned. That is not allowed on the PSPs processor. So I replaced these instances with memcpy functions.

Also the bitmap font rendering uses unaligned pointers.

Here is a patch (against the SVN) that works for me. It includes some PSP specific changes too. But every single change is documented, so you should be able to gain something from it if the problem is in fact the same.

http://jjs.at/temp/pointer_alignment.patch

Edit: It might also be important that I can build all source with -O2 optimization except for ac.cpp which has to be with -O2 -fno-strict-overflow -fno-strict-aliasing . Otherwise there are strange scripting errors.
Ask me about AGS on PSP, Android and iOS! Source, Daily builds

JawCross

JJS, thanks for PSP-patch. It doesn't change user experience, but now it does not silently die, but it is Segmentation Fault always.

I'm not sure about optimization flags, I'm currently trying with Debug release.

I got first backtrace, which seems almost useless to me:
Code: ags

#0  0x0018f258 in _linear_hline16 ()
#1  0x0020564c in _xwin_hline ()
#2  0x0015a508 in _normal_rectfill ()
#3  0x0020515c in _xwin_rectfill ()
#4  0x00053c88 in rectfill (bmp=0x645a40, x1=0, y_1=0, x2=319, y2=199, color=0) at /usr/include/allegro/inline/draw.inl:88
#5  0x00054280 in AllegroGFXFilter::ClearRect (this=0x644868, x1=0, y1=0, x2=319, y2=199, RGB=0)
    at ags_maemo/Engine/acgfx.cpp:439
#6  0x000de038 in ALSoftwareGraphicsDriver::ClearRectangle (this=0x6448f8, x1=0, y1=0, x2=319, y2=199, colorToUse=0x0)
    at ags_maemo/Engine/ali3dsw.cpp:340
#7  0x0005f040 in display_switch_in () at ags_maemo/Engine/ac.cpp:15574


(None of those three Engine/ files were touched by psp-patch)

Allegro is not widely used on Maemo, but at least very simple test is working: http://wiki.allegro.cc/index.php?title=ExampleExHello


RedDwarf

Quote from: RedDwarf on Tue 17/05/2011 23:18:04
Quote from: RedDwarf on Tue 17/05/2011 16:20:34Totally unrelated, with mpg123 1.13.3 I don't get any MP3 sounds (cat in KQ3). It worked before with the internal copy. It's just me?
The code, at the very least, lacks a call to mpg123_init().
bero, the code was untested or you forgot to add a file in the commit?
Nevermind. I'm rewriting the MP3 code without using ALMP3.

I have the MYSTATICMP3 part. Once I have the MYMP3 part and I clean it I will request a merge.

RedDwarf

The new mp3 playback code is commited and there is a merge request.

Now, how are we going to handle all this? This commit is not Linux specific. Pumaman, will you look into the git log to take patches for your SVN? I don't see a way to make it easier for you. I could attach a patch here, but that is not going to make it easier (in fact Gitorious has a really nice diff/patch viewer). Gitorious really makes collaboration easier.

RedDwarf

#116
Quote from: JawCross on Wed 18/05/2011 16:17:18
JJS, thanks for PSP-patch. It doesn't change user experience, but now it does not silently die, but it is Segmentation Fault always.

I'm not sure about optimization flags, I'm currently trying with Debug release.

I got first backtrace, which seems almost useless to me:
Code: ags

#0  0x0018f258 in _linear_hline16 ()
#1  0x0020564c in _xwin_hline ()
#2  0x0015a508 in _normal_rectfill ()
#3  0x0020515c in _xwin_rectfill ()
#4  0x00053c88 in rectfill (bmp=0x645a40, x1=0, y_1=0, x2=319, y2=199, color=0) at /usr/include/allegro/inline/draw.inl:88
#5  0x00054280 in AllegroGFXFilter::ClearRect (this=0x644868, x1=0, y1=0, x2=319, y2=199, RGB=0)
    at ags_maemo/Engine/acgfx.cpp:439
#6  0x000de038 in ALSoftwareGraphicsDriver::ClearRectangle (this=0x6448f8, x1=0, y1=0, x2=319, y2=199, colorToUse=0x0)
    at ags_maemo/Engine/ali3dsw.cpp:340
#7  0x0005f040 in display_switch_in () at ags_maemo/Engine/ac.cpp:15574


(None of those three Engine/ files were touched by psp-patch)

In a Linux machine a very similar crash happens when you exit. Perhaps you have another problem that triggers a normal quit (which could give a useful message) and it segfault because of the quitting.
You should be able to comment the
Code: ags

  if (gfxDriver->UsesMemoryBackBuffer())  // make sure all borders are cleared
    gfxDriver->ClearRectangle(0, 0, final_scrn_wid - 1, final_scrn_hit - 1, NULL);

part of display_switch_in. I'm not even sure it makes sense at all.

You could also look at the backtrace of all the threads (that one isn't the main one) and search for the quit call (which will contain the message explaining why it was called).

JJS

It would make sense that this is a crash on quitting because the message that gets drawn on screen (the one from the screenshot) says that speech.vox is not available. After dismissing this box with a keypress the game quits.

You asked for other test cases, what I did was compiling some games myself which are open source like ! and the Oceanspirit Dennis games. Also of course the demo game that comes with AGS. Other games for 3.2x are (in no particular order or reason for selection): Aeronuts, Beacon, Eternally Us, Hardspace, The Hamresanden Chronicles II: The Black Prism, Of the Essence, The Lurking Horror, Next to Evil, Fountain of Youth Demo/Arcade Fighter, Gemini Rue, etc. Really a lot of games, especially also newer MAGS ones.
Ask me about AGS on PSP, Android and iOS! Source, Daily builds

JawCross

Quote from: RedDwarf on Sat 21/05/2011 03:27:48
Code: ags

  if (gfxDriver->UsesMemoryBackBuffer())  // make sure all borders are cleared
    gfxDriver->ClearRectangle(0, 0, final_scrn_wid - 1, final_scrn_hit - 1, NULL);

With this modification game (Kq3Redux) is not segfaultting on ARM, but it just ends. Debugger says: Program exited with code 0133.

Quote from: RedDwarf on Sat 21/05/2011 03:27:48
You could also look at the backtrace of all the threads (that one isn't the main one) and search for the quit call (which will contain the message explaining why it was called).

Code: ags

gdb) thread apply all backtrace

Thread 9 (Thread 0x46cfb490 (LWP 1707)):
#0  0x403b0798 in poll () from /lib/libc.so.6
#1  0x424676b8 in ?? () from /usr/lib/libpulse.so.0
#2  0x424676b8 in ?? () from /usr/lib/libpulse.so.0
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 6 (Thread 0x454fb490 (LWP 1704)):
#0  0x403b0798 in poll () from /lib/libc.so.6
#1  0x424676b8 in ?? () from /usr/lib/libpulse.so.0
#2  0x424676b8 in ?? () from /usr/lib/libpulse.so.0
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 2 (Thread 0x4105a490 (LWP 1700)):
#0  0x0018f258 in _linear_hline16 ()
#1  0x0020564c in _xwin_hline ()
#2  0x0015a508 in _normal_rectfill ()
#3  0x0020515c in _xwin_rectfill ()
#4  0x00053c88 in rectfill (bmp=0x645d70, x1=0, y_1=0, x2=319, y2=199, color=0) at /usr/include/allegro/inline/draw.inl:88
#5  0x00054280 in AllegroGFXFilter::ClearRect (this=0x644888, x1=0, y1=0, x2=319, y2=199, RGB=0)
    at ags_maemo/Engine/acgfx.cpp:439
#6  0x000de038 in ALSoftwareGraphicsDriver::ClearRectangle (this=0x644918, x1=0, y1=0, x2=319, y2=199, colorToUse=0x0)
    at ags_maemo/Engine/ali3dsw.cpp:340
#7  0x0005f040 in display_switch_in () at ags_maemo/Engine/ac.cpp:15574
#8  0x0015435c in _switch_in ()
#9  0x001b7998 in _xwin_private_handle_input ()
#10 0x001b8028 in _xwin_handle_input ()
#11 0x001aea1c in _xwin_bg_handler ()
#12 0x001e1a2c in bg_man_pthreads_threadfunc ()
#13 0x40559934 in start_thread () from /lib/libpthread.so.0
#14 0x403b9be8 in clone () from /lib/libc.so.6
#15 0x403b9be8 in clone () from /lib/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 1 (Thread 0x40021c90 (LWP 1697)):
#0  0x4055d27c in pthread_mutex_lock () from /lib/libpthread.so.0
#1  0x403c5cc8 in pthread_mutex_lock () from /lib/libc.so.6
#2  0x001e1774 in _unix_lock_mutex ()
#3  0x00201c50 in x_set_leds ()
#4  0x001609d8 in set_leds ()
#5  0x00161434 in remove_keyboard ()
#6  0x0014045c in allegro_exit ()
#7  0x0007bab4 in quit (quitmsg=0x21a3c0 "|You have exited.")
    at ags_maemo/Engine/ac.cpp:9341
#8  0x000a0af8 in QuitGame (dialog=0) at ags_maemo/Engine/ac.cpp:17995
#9  0x000ecb04 in call_function (addr=658100, numparm=1, parms=0xbefeb128, offset=0)
    at ags_maemo/Common/csrun.cpp:1224
#10 0x000f0aa0 in cc_run_code (inst=0x628588, curpc=101913)
    at ags_maemo/Common/csrun.cpp:1798
#11 0x000f1704 in ccCallInstance (inst=0x656d6167, funcname=0x0, numargs=1)
    at ags_maemo/Common/csrun.cpp:2026
#12 0x000bcaf4 in run_script_function_if_exist (sci=0x628588, tsname=0x2e1a10 "game_start", numParam=0, iparam=0, iparam2=0, iparam3=0)
    at ags_maemo/Engine/ac.cpp:3273
#13 0x000bd8ec in run_text_script (sci=0x628588, tsname=0x21d578 "game_start")
    at ags_maemo/Engine/ac.cpp:3323
#14 0x000bda20 in start_game () at ags_maemo/Engine/ac.cpp:26661
#15 0x000be6ac in initialize_start_and_play_game (override_start_room=0, loadSaveGameOnStartup=0x0)
    at ags_maemo/Engine/ac.cpp:26818
#16 0x000c7d4c in initialize_engine (argc=2, argv=0xbefec2e4)
    at ags_maemo/Engine/ac.cpp:28045
#17 0x000c8ae8 in main (argc=2, argv=0xbefec2e4) at ags_maemo/Engine/ac.cpp:27243


Maybe that ARM 'port' should wait till all big know issues are solved e.g. 64bit Linux works flawlessly. Maybe some old fancy dependencies should also be thrown away (like libcda).

JawCross

Quote from: Electroshokker on Tue 17/05/2011 14:08:13
Hmm... this thread is getting cluttered with people trying to build the source for windows, linux, mac, ... I propose using a section in the AGS wiki to coördinate this stuff, rather than lots of people setting up their own project site.

This is only coordination attempt I have seen so far. But is there more project site than svn.adventuregamestudio.co.uk and https://gitorious.org/ags ? I think two is not yet fatal at all. And I hope official ('blessed') codebase will move to gitorious as well.

RedDwarf, what is your target and plans? I can see you have removed almp3 and added some gstreamer -stuff on your branches. Bero, you started cmake-clone for easy building (under Linux), and you have wrote about 64bit systems. Everybody else can also answer: "What is your goal? Short term all long term". I haven't see new commits on https://svn.adventuregamestudio.co.uk:7743/svn/ags/trunk/ nor any sings that 'community effort will be merged to it'. I think they should be merged and I think there should be some plan (or hope) that they will be merged.

SMF spam blocked by CleanTalk