Qbasicnews.com

Qbasic "like" compilers/interpreters => FB Projects => Topic started by: DrV on November 30, 2004, 09:12:10 PM



Title: Allegro port
Post by: DrV on November 30, 2004, 09:12:10 PM
Is anyone up for a freeBASIC port of Allegro?  I'm willing to help with this, and na_th_an's put forth the idea a couple of times; I'm willing to wait for the initial release of the compiler before starting, though... unless v1c sends me a pre-release ver, which would be okay too... I'm kinda low on free time this week anyway.  I think this would be a worthy cause for anyone with Allegro or C experience to contribute to this awesome project.  I'm up for it. :)


Title: Allegro port
Post by: VonGodric on November 30, 2004, 09:35:04 PM
I'm willing, though I dunno how much time I have.


Title: Allegro port
Post by: Nexinarus on December 01, 2004, 08:02:58 AM
I think that all you have to do is port the headers (all .h to .bi), and compile the lib in MinGW.


Title: Allegro port
Post by: Blitz on December 01, 2004, 08:14:26 AM
Allegros headers are 20% macros. Trying to port it would be painfull since FB doesn't have macros, yet atleast. Besides that lib sucks imo.


Title: Allegro port
Post by: na_th_an on December 01, 2004, 09:26:10 AM
I will try to do my best as soon as FB is released. I'll try to convert the macros to functions. I'll count you both in the project, Vongodric and DRV :)


Title: Allegro port
Post by: DrV on December 02, 2004, 09:44:32 PM
I'm gearing up to get down... I'll try to do the core gfx stuff and then put it up somewhere so other people can work on the other stuff.  Thanks for the support so fast. :)


Title: Allegro port
Post by: ShadowWolf on December 02, 2004, 09:50:13 PM
somone here should contacted Angelo Mottola he did some work on the Mac Os port of allegro he be the closest to a expert that the QB community has for allegro.

http://www.ecplusplus.com/


Title: Allegro port
Post by: DrV on December 02, 2004, 11:26:47 PM
here's a working example (you need to have liballeg.a in the fb lib/ dir):

Code:
Declare Function install_allegro CDecl Lib "alleg" (ByVal system_id As Integer, ByRef errno_ptr As Integer, ByVal atexit_ptr As Function()) As Integer
Declare Sub allegro_message CDecl Lib "alleg" (ByVal s As String)
Declare Sub allegro_exit CDecl Lib "alleg" ()

Declare Sub atexit CDecl Lib "crtdll" ()

Const SYSTEM_AUTODETECT = 0

Option Explicit

Dim Shared errno As Integer

Function allegro_init() As Integer
allegro_init = install_allegro(SYSTEM_AUTODETECT, errno, ProcPtr(atexit))
End Function

'''
Dim ret As Integer
ret = allegro_init()
Print "ret = "; ret
Print "after allegro_init()..."
Call allegro_message("Hello, world!" + chr$(13) + "Press ok to exit")
Print "before allegro_exit()..."
allegro_exit
Print "after allegro_exit()..."



doesn't do much yet... help!   v1ctor or somebody - how do I get at C externs?  If I was just writing straight gas asm, i could use 'extrn' - is there an fb keyword for that?


Title: Allegro port
Post by: marzecTM on December 02, 2004, 11:53:54 PM
ehm if you mean like

extern void bleh

nevermind that extern. it'S just some stuff for the c-compiler to not redeclare the function somewhere else, would bitch on you otherwise. ignore extern

edit: i just was reminded by someone of common shared. hm... i'm a little confused now, but when i was porting that sdl headers i didn't have to add something to the declaration, so i guess ignoring extern when porting headers is fine.


Title: Allegro port
Post by: relsoft on December 03, 2004, 12:58:41 AM
Quote from: "ShadowWolf"
somone here should contacted Angelo Mottola he did some work on the Mac Os port of allegro he be the closest to a expert that the QB community has for allegro.

http://www.ecplusplus.com/


Angelo sez: "no"

But he(Angelo) will work on the MAC OS port of FB. :*)


Title: Allegro port
Post by: Jofers on December 03, 2004, 02:22:13 AM
Cool.  It's nice to Angelo returning... to... another scene. ;)


Title: Allegro port
Post by: relsoft on December 03, 2004, 04:45:42 AM
Yeah, I wouldn't be surprised if Bobby would too. :*)


Title: Allegro port
Post by: Jofers on December 03, 2004, 06:21:49 AM
Heh... for some reason Bobby Krusty (that font guy from years ago) came to mind, just seconds before the Cosmox Bobby. :???:  But now Jorden needs to launch a freebasic site and it'll be a trifecta :D


Title: Allegro port
Post by: v3cz0r on December 03, 2004, 08:25:20 AM
Any external procs need to be declared with an ALIAS "realnamehere", coz all symbols are case-insensitive in FB.

The alias name doesn't have to include the initial _ or @, they will be added (unless the C proc already has an initial underscore on its name, course).

There's no extern, GAS will turn any non-declared symbol as extern automagically.


As Rel said, Angelo told us that it will a bitch to port, mainly 'cause the Allegro's main function - i know nothing about Allegro for Windows, i can't help on that.


Title: Allegro port
Post by: DrV on December 03, 2004, 06:02:43 PM
No, no... I mean 'extern' vars... as in 'extern BITMAP *screen;' -- which is utterly necessary... do I have to write a crappy go-between lib in C to get and set vars?  :-?

EDIT: There is a gas thing for externs - the '.extern' directive (not extrn as I said before.... that's MASM/TASM.)


Title: Allegro port
Post by: v3cz0r on December 03, 2004, 06:53:46 PM
Yeah i know, but: ".extern is accepted in the source program--for compatibility with other assemblers--but it is ignored. as treats all undefined symbols as external", that's from gas' manual.

Like in QB, there's no way to shared vars between modules, then using COMMON, but in C you would have to declare them the same way as in FB, that would be all names in uppercase - and if you declare them in QB using suffixes (%&), it's even more difficult to know the right name.

Why do you need to share that kind of var between C and basic? I don't think it would be too safe, anyone could do screen = garbage at fb and loads of craps would happen - why not doing the SDL way? The user has the control over the bitmaps/surfaces, i thought Allegro was that way too..


Title: Allegro port
Post by: DrV on December 03, 2004, 06:59:59 PM
Allegro uses an external variable called 'screen' to represent the hardware screen bitmap, and one called 'key' to represent the keyboard keys, etc... I'm not sure how it all works under the hood, but it works in C...   :)


Title: Allegro port
Post by: relsoft on December 04, 2004, 12:17:15 AM
Quote from: "Jofers"
Heh... for some reason Bobby Krusty (that font guy from years ago) came to mind, just seconds before the Cosmox Bobby. :???:  But now Jorden needs to launch a freebasic site and it'll be a trifecta :D


trifecta.  The memories.... :*)

I thought it was you, wurka and chaoticmass?


Title: Allegro port
Post by: na_th_an on December 04, 2004, 12:42:35 AM
screen is just a BITMAP structure that represents the screen. That way, you do a :

Code:
blit (myBuffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);


to blit your buffer to the screen making it visible. That's why it is shared.


Title: Allegro port
Post by: v3cz0r on December 04, 2004, 12:55:38 AM
And "screen" is a qb/fb keyword.. Allegro could have added at least dunno al_ to public procs and global variables, there are probably what, 50 different global vars with ordinary names.. backward compatibility, i guess..


Title: Allegro port
Post by: barok on December 04, 2004, 01:25:30 AM
is there a different syntax for screen?  Any program that i try to compile in fb i have to end up taking out any screen statements.


Title: Allegro port
Post by: relsoft on December 04, 2004, 01:31:03 AM
Something in the mode of:

Screen width, height, bpp, screenmode

I guess that would work.


Title: Allegro port
Post by: v3cz0r on December 04, 2004, 01:39:27 AM
Not yet, but when Sterling finishes his qb-like gfx lib.


Title: Allegro port
Post by: Jofers on December 04, 2004, 02:18:53 AM
Yeah, something like that, rel.  But I was actually using the word "trifecta", meaning "triple winner" alluding to horse racing.


Title: Allegro port
Post by: DrV on December 05, 2004, 01:11:24 PM
Okay, decided to use a little C lib for getting/setting externs since I needed it anyway for functions to convert string return values to FB strings...  here's a quick demo:
Download fballeg-prerelease-preview.zip (http://qh2.qbtk.com/10-d)
* smiles at qh2 people *
EDIT: crap... forgot to upload bitmap in the zip - fixed now