[AD] Porting Allegro to the PS2

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Hi all,
I've already made posts about this on allego.cc and on AGP, but I thought I would bring my adventure on porting Allego to the PlayStation 2 up to speed and enlighten everyone on what I have found.
	First a little backgound;

I purchased a PS2-Linux kit and it arrived about a week ago. It came with some pretty low-level libs so I thought a good idea would be to port Allegro to the PS2. The system runs "Kodara" which a Japanese Distro based off of Redhat 6. (Uses RPM as package management) So one of the first things I did was grab the Allegro 4.0.1 tarball and see how far I could get trying to compile it out of the box. It would seem that ./configure runs just dandy, creates a makefile and all. That's when the fun begins though.

It seems that when the unix code was being developed the programmer(s) assumed that linux/unix == x86, which is not my case. I'm a little endian mips with an FPU, two funky coprossesers, and a very very very very very very fast Graphics Unit. I was hoping to just make a clone of the svgalib console driver and when the various allegro functions were called, I would just replace them with the approprite GS call to the GPU. This way I can keep all the nice linux timing stuff already there. The system uses OSS so sound is OK as well but the graphics functions are causing me much heartache. Also, please bear in mind that I've been using Allegro for a few years now and never really seen how it ticks before so I'm not that hot at lib programming (yet)

This is a rundown of what has happend in my quest to get it compiled and where I went from there:

Like I said, when I did a stright ./configre the makefile correctly noticed that I wasn't an x86 and set --enable-asm=no it also found my X server (I don't run Xfree86, but Sony's XGS, so it made a few incorrect assumtions about my Xlibs) So after autoconf generated the makefile I gave it a go. This was the error I got:

---
gcc -DHAVE_CONFIG_H -Iinclude -Iinclude/allegro -I./include -I./include/allegro -I. -I/usr/X11R6/include -O2 -funroll-loops -ffast-math -fomit-frame-pointer - Wall -DALLEGRO_USE_C -DALLEGRO_LIB_BUILD -fPIC -DALLEGRO_SHARED -c ./src/gsprite
.c -o obj/unix/shared/alleg/gsprite.o
./src/gsprite.c: In function `draw_gouraud_sprite':
include/allegro/platform/alunix.h:245: `asm' operand requires impossible reload include/allegro/platform/alunix.h:245: `asm' operand requires impossible reload include/allegro/platform/alunix.h:245: `asm' operand requires impossible reload
make: *** [obj/unix/shared/alleg/gsprite.o] Error 1

------
I t's barfing on alunix.h, here
---
static inline void outportw(unsigned short port, unsigned short value)
{
__asm__ volatile ("outw %0, %1" : : "a" (value), "d" (port));
}
---

The questions are 1) why is there inline asm in a unix header file?, unix != x86 and also that's just bad karma...

and

2) what is this for? can I move it or put it some something little more device depandant? It seems to be related to the joystick....

As you can tell gcc was using the correct flags -DALLEGRO_USE_C so no asm is suppsed to get in, it is also including my Xlibs "-I/usr/X11R6/include" which I don't want it to do, what's inside isn't what allegro is going to expect (more on that later)

So what I did was create a little local CVS on my PS2 and went to hacking, the first thing I did was comment out the asm in that header file, It was happy and went a lot farther when all all of the sudden it became unhappy again. It seem to go all the way through compiling allegro but when it came time to build the demo, output I got was this:

----
gcc -L/usr/X11R6/lib -s -Wl,-export-dynamic -o demo/demo obj/unix/demo.o -Llib/
unix -lalleg-4.0.1 -lalleg_unsharable -lm
lib/unix/liballeg-4.0.1.so: undefined reference to `iopl'
collect2: ld returned 1 exit status
make: *** [demo/demo] Error 1
-----

It's linking against my X libs first of all (Bad thing, first of all even if it did work, the overhead of running X will not be benifical in making real games. I need a console driver as close to the metal as possible)

and something is now amiss in my liballeg-4.0.1

This is where my adventure ends.

Now I'm not very good at lib making. (I bearly know how to make a .a file) I'm an old Allegro user who started on the DJGPP version and after I went to linux, brought it with me. I'm not terrably good with autoconf and I don't wish to make a makefile.ps2 when it's almost there. I was hoping just to make an "if switch" in the makefile and tell it to use the ps2 console driver. But the makfile isn't intelligent enough to see it's a mips computer, (just notx86 and not to incude asm, which the header does anyway) and I don't know how to change it.

In a dream world I would love a /ps2 dir with all the .c files I'm going to need to change will all the function hooks there. All I would need to do then fill in the blanks with my GS code.

like

void hline(BITMAP *bmp, int x1, int y, int x2, int color)
{}

and I put in the stuff in the curly brackets.

Well, I hope I didn't bother you all, but I would like to see Allegro on the PS2. As it stands right now all the code I've written for x86 linux is stuck there until Allegro works. I'll help when I can ^_^

-halkun







Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/