Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Allegro.pas: a wrapper to use Allegro and Pascal

This thread is locked; no one can reply to it. rss feed Print
Allegro.pas: a wrapper to use Allegro and Pascal
Niunio
Member #1,975
March 2002
avatar

I'm not sure if this is the best place to the thread, so move it if it shouldn't be there.

After TINS'06 I discovered that the evolution of my Mingro library was wrong, so I decided to restart it from 0. When I was thinking the new API I discovered that it should be easier if the wrapper to use Allegro in Pascal was as an independent package. After that I find a new job, I move myself to other city and I couldn't code nothing for a long time :(. But few weeks ago I back, and started to code it.

Yesterday I finished the "Hello, world!" example, so I decided to show it to you because I know there are some allegroids that can code in Pascal and they would be interested in this project... and they would help me to finish it (specially in that parts of Allegro that I'm not familiarized as packed files, audio streams, joystic... and documentation ;D ).

So try it and tell me what do you think. Note that the API is slightly different because I need to do some magic to make it work in Delphi (it can't access to the public variables :P ) and because some Allegro functions are equal than some Pascal procedures, as the readkey function. You'll need a C compiler to build a DLL (the magic) and a Pascal compiler for everything else. Current version worked in Wind32 only (a voluntary to port it to other platforms and/or write a better build script?).

Constructive criticism and help will be welcomed :)

[edit] Wrappers for grabber data files and bitmap blitting and the exdata example written. I've changed the attached file.

Nobody wants see it?

-----------------
Current projects: Allegro.pas | MinGRo

kazzmir
Member #1,786
December 2001
avatar

I don't think Id use such a libary but I knew pascal once upon a time so I looked at it. You are just wrapping Allegro right? Why do you have alvtable.pas? And what need is there to define the entire albitmap.pas? Cant you just do
BITMAP = POINTER;
or something? Then you can provide functions to get width and height instead of just accessing the BITMAP directly. This is what I do in my scheme wrapper for Allegro.

Also I noticed in alsystem.c you wrapped install_allegro() because its a macro, but did you notice the macro actually just calls the _install_allegro function?

gnolam
Member #2,030
March 2002
avatar

People still use Pascal? :o

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Archon
Member #4,195
January 2004
avatar

Quote:

People still use Pascal? :o

I think that Pascal has interesting syntax...

Niunio
Member #1,975
March 2002
avatar

gnolam said:

People still use Pascal?

Didn't you hear about Delphi or the new Turbos?

I can code in C, but I find Pascal is less cryptic [edit] and IMHO Object Pascal manages classes and objects better than C++, but it's only my opinion[/edit]. In TINS'06 I coded my entry in Object Pascal and I spent less time fixing stupid bugs. That's why I'm working on this wrapper.

kazzmir said:

Why do you have alvtable.pas? And what need is there to define the entire albitmap.pas? Cant you just do BITMAP = POINTER; or something?

Yes, I can if I write more C-magic functions for drawing. But this way the Pascal compiler would try to optimize in the same way that the C compiler does. Also, some Pascal compilers (as Delphi, if I remember correctly) can use inline procedures. If I define "AL_BITMAP = POINTER" then the compiler can't use inline procedures.

[edit]

kazzmir said:

Also I noticed in alsystem.c you wrapped install_allegro() because its a macro, but did you notice the macro actually just calls the _install_allegro function?

Yes I did:

AL_INLINE(int, install_allegro, (int system_id, int *errno_ptr,
   AL_METHOD(int, atexit_ptr, (AL_METHOD(void, func, (void))))),
{
   return _install_allegro_version_check(system_id, errno_ptr, atexit_ptr, \
      MAKE_VERSION(ALLEGRO_VERSION, ALLEGRO_SUB_VERSION, ALLEGRO_WIP_VERSION));
})

I started the wrapper before the latest release (4.2.0) with a different install_allegro implementation, more complex, so I decided to "expand" it instead of recode it. Now I don't need to change it. I'm smart 8-) or just a lucky boy ;D. Anyway it will be called only once each project.

[EDIT]

I've released Allegro.pas 8-). See it here

-----------------
Current projects: Allegro.pas | MinGRo

Go to: