Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2001-02

Allegro

8 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Matt Emson

Did the Allegro thread progress anywhere a while back??

I lost all my email recently (my pop3 mailbox apparently became corrupted and got deleted.. bah!!)

The original post prompted me to look at the Delphi version (got it running nicely..) I'd be interested to see it running in FPC however because Allegro is now fairly 'cross platform'.

My next task will probably be getting it to run with Kylix (when it's available
- of course 8), so I'll let you all know how that goes.. (or not as the case may be ;)

If I do get the time, I'll give a port a go.. the main thing I could see that was causing a problem with an initial compilation was the following style of declaration:

type
  XXX = procedure cdecl;
  YYY = function (whatever: integer): boolean cdecl;

As far as I can see, you could declare theis as:

  XXX = procedure; cdecl;

Is that valid syntax in FPC?? Is there any difference?? Seems to work in Delphi 5.0+ anyway.

Matt

Reply by email

Sebastian Günther
to Matt Emson
Matt Emson wrote 5 lines
XXX = procedure; cdecl; Is that valid syntax in FPC?? Is there any difference?? Seems to work in Delphi 5.0+ anyway.

This works in FPC as well. For example, the OpenGL unit uses such constructs successfully:

var
  glClearIndex: procedure(c: Single); cdecl;

- Sebastian

Reply by email

Marco van de Voort
to Sebastian Günther
Show quoted text 8 lines
> Is that valid syntax in FPC?? Is there any difference?? Seems to work in Delphi > 5.0+ anyway. This works in FPC as well. For example, the OpenGL unit uses such constructs successfully: var glClearIndex: procedure(c: Single); cdecl;

So does the *nix sighandling.

Reply by email

Matt Emson

Sebastian,

Show quoted text 5 lines
This works in FPC as well. For example, the OpenGL unit uses such constructs successfully: var glClearIndex: procedure(c: Single); cdecl;

The problem then is that Delphi will accept either:

glClearIndex: procedure(c: Single); cdecl;
^^
or

glClearIndex: procedure(c: Single) cdecl;
^^
but FPC insists on the first version. I'll have another go tonight (I've loads of other stuff to look at, so don't hold your collective breaths ;)

Matt

Reply by email

Ray & Debbie Smith
to Matt Emson: Did the Allegro thread progress anywhere a while back?? I lost all my email recently (my…

Hi Matt,

I asked a question a week or so back about Allegro. Is this the thread you are referring to?

I modified allegro.pas (the delphi version) a little and have a couple of small
demos working.
As far as I'm aware everything should be "doable". My modifications allowed programs to compile with standard Free Pascal ... ie. without Delphi compatability or any other switches.

The Delphi wrapper doesn't handle external variables correctly becuase of a limition with Delphi. The modifcations I made overcame this limitation.

I have only wrapped a dozen or so functions and converted the exmem.c and exmidi.c demos that come with Allegro and they both seem to work fine.

I know very little about Object Pascal, Delphi and Free Pascal so I have no idea
what is the best way to get it working ... I'm just happy that it works the way I have
done it.

I contacted the author of allegro.pas and he created it by writing a parser to convert
the Allegro header file to output an Object Pascal Unit. He is busy for a few months
but sounded interested in supporting Free Pascal in the future.

I estimate it would take about 1 full day to convert the Delphi wrapper to work with
Free Pascal (by manually modification). I was hoping to do a similar thing as the
allegro.pas author and write a "htopas" type program to do it automatically.

If anyone wants a copy of my test programs let me know.

Ray Smith

Earlier message 48 lines
----- Original Message ----- From: Matt Emson To: Sent: Tuesday, February 13, 2001 1:17 AM Subject: [fpc-pascal]Allegro > Did the Allegro thread progress anywhere a while back?? > > I lost all my email recently (my pop3 mailbox apparently became corrupted and > got deleted.. bah!!) > > The original post prompted me to look at the Delphi version (got it running > nicely..) I'd be interested to see it running in FPC however because Allegro > is now fairly 'cross platform'. > > My next task will probably be getting it to run with Kylix (when it's available > - of course 8), so I'll let you all know how that goes.. (or not as the case > may be ;) > > If I do get the time, I'll give a port a go.. the main thing I could see that > was causing a problem with an initial compilation was the following style of > declaration: > > type > XXX = procedure cdecl; > YYY = function (whatever: integer): boolean cdecl; > > As far as I can see, you could declare theis as: > > XXX = procedure; cdecl; > > Is that valid syntax in FPC?? Is there any difference?? Seems to work in Delphi > 5.0+ anyway. > > Matt > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Peter Vreman
Show quoted text 8 lines
I estimate it would take about 1 full day to convert the Delphi wrapper to work with Free Pascal (by manually modification). I was hoping to do a similar thing as the allegro.pas author and write a "htopas" type program to do it automatically. If anyone wants a copy of my test programs let me know.

There is already a h2pas program available with Free Pascal. But i recommend to use the development version as it's better and can handle some more complexer .h files.

Reply by email

Matt Emson

Hi Ray,

I'd love to get a copy of your source (including your alterations to Allegro.pas.) I've converted about 5 of the demos myself, as well as writing a few of my own just messing around, so maybe we could combine efforts. I'm more interested in writing an OO wrapper to the Allegro.pas unit, so if you can send me the bit's you've converted, I'll probably be able to get it working with both Delphi *and* FPC in 'Delphi' mode ;)

I've noticed the author has made some errors too... There are a few classics:

function Load_BMP(filename: PAL_Char; pal: PAL_Rbg): PAL_Bitmap; cdecl;

should actually read (and works as):

function Load_BMP(filename: PAL_Char; pal: PAL_Palette): PAL_Bitmap; cdecl;

(I gleaned this by reading the demos.. the docs kind of contradict themselves..)

Because the resulting value in 'pal' after the call is actually the Bitmaps Palette. So if you then call (totally OTTOMH so don't quote me):

var
  abmp: PAL_Bitmap;
  apal: PAL_Palette;
begin
  abmp := Load_BMP(PChar('c:\afile.bmp'), pal);
  Set_Palette(pal^); //if you don't call this the colours are not correct!!
  blit(abmp, screen, 0, 0, 0, 0, abmp^.w, abmp^.h);
end;
The Delphi wrapper doesn't handle external variables correctly becuase of a limition with Delphi. The modifcations I made overcame this limitation.

Can you ellabourate on this more?? Which version of Delphi?

I have only wrapped a dozen or so functions and converted the exmem.c and exmidi.c demos that come with Allegro and they both seem to work fine.

To be honest, a lot of the functionality does more than you'd need on a daily basis.

I know very little about Object Pascal, Delphi and Free Pascal so I have no idea what is the best way to get it working ... I'm just happy that it works

the

way I have done it.

I'm willing to look at the code and give you some pointers if you like.

Show quoted text 7 lines
I estimate it would take about 1 full day to convert the Delphi wrapper to work with Free Pascal (by manually modification). I was hoping to do a similar thing as the allegro.pas author and write a "htopas" type program to do it automatically.

I think I'd personally like to 'snapshot' the version that works, get everything working well and *then* worry about the current version. So long as nothing changes too radically, it should just be an 'adding additional stuff' rather than a complete re-write.

If anyone wants a copy of my test programs let me know.

Me, me, me ;)

Thanks,

Matt

Reply by email

Ray & Debbie Smith
to Peter Vreman: There is already a h2pas program available with Free Pascal. But i recommend to use the…

From: Peter Vreman

There is already a h2pas program available with Free Pascal. But i

recommend to use the

development version as it's better and can handle some more complexer .h

files.

Thanks Peter,

The h2pas program with latest release failed pretty badly.

Allegro.h is quiet complex so I'll download the development version of h2pas and give it a try.

Thanks,

Ray Smith

Reply by email