RetroBASIC

Basicprogramming(.org) => Community news and announcements => Topic started by: Cybermonkey on January 17, 2016, 06:22:26 pm

Title: AllegroBASIC
Post by: Cybermonkey on January 17, 2016, 06:22:26 pm
(http://pulsar2d.org/images/allegrobasiclogo.png)

(http://pulsar2d.org/images/retrobasiclogo.png)

This little project of mine is evolving constantly. It is a simple BASIC not necessarily meant for game programming. There are, however, built-in functions for graphics primitives and loading and displaying bitmaps, loading and playing sound files and mouse and keyboard input.
AllegroBASIC uses the extremely powerful MY-BASIC interpreter provided by Wang Renxin. The source code can be found here: https://github.com/paladin-t/my_basic
An introduction PDF is also available there: https://github.com/paladin-t/my_basic/blob/master/MY-BASIC%20Quick%20Reference.pdf
Unfortunately Allegro 4 isn't developed any further and Allegro 5 doesn't fit in my programming scheme. At the moment I am porting AllegroBASIC to SDL2 which will be then named RETROBASIC. There will be the same limitations, to avoid numerous dependencies:

Now what looks like a typical AllegroBASIC program:
Code: [Select]
' mousetest
KEY_ESC          = 59
screen (640,480,"Mousetest")
hidemouse
sound = loadsound ("scores.wav")
do
cls

drawtext (100,100,"MouseX: "+str(mouseX))
drawtext (100,112,"MouseY: "+str(mouseY))
drawtext (100,124,"MouseButton: "+str(mousebutton))
drawtext (100,136,"MouseWheel: "+str(mousewheel))
if mousebutton = 1 then
showmouse
playsound (sound, 128, 128, false)
endif
if mousebutton = 2 then
hidemouse
stopsound (sound)
endif
sync
until keystate (KEY_ESC) = true
end
Title: Re: AllegroBASIC
Post by: wang renxin on January 18, 2016, 08:04:13 am
 ;)
Title: Re: AllegroBASIC
Post by: Aurel on January 18, 2016, 10:08:32 am
well i am wondering how much work is needed if i decide to translate source code
5000 lines for example into Oxygenbasic code ?
Title: Re: AllegroBASIC
Post by: ScriptBasic on January 18, 2016, 10:52:58 am
well i am wondering how much work is needed if i decide to translate source code
5000 lines for example into Oxygenbasic code ?

I can't think of one sane reason anyone would want to port a well written C program that runs on multiple platforms and translate it to O2. (Which Charles hasn't updated since July of 2015)
Title: Re: AllegroBASIC
Post by: Aurel on January 18, 2016, 11:05:15 am
think how many Basic programmers know C or better to say how many
understand what is what in C.
however this is just a idea and i dont have time because i am busy with DLib virtual machine
Title: Re: AllegroBASIC
Post by: Aurel on January 18, 2016, 11:08:26 am
this part is interesting:

Code: [Select]
/** Dictionary */
typedef unsigned int (* _ht_hash)(void*, void*);
typedef _common_compare _ht_compare;
typedef _common_operation _ht_operation;
typedef struct _ht_node_t {
_ls_operation free_extra;
_ht_compare compare;
_ht_hash hash;
unsigned int array_size;
unsigned int count;
_ls_node_t** array;
} _ht_node_t;
Title: Re: AllegroBASIC
Post by: Aurel on January 18, 2016, 11:14:53 am
WOW 14596 lines ...
hmm this looks that is not the same thing right?
i mean like tonytoys 5000 lines
Title: Re: AllegroBASIC
Post by: wang renxin on January 18, 2016, 11:23:41 am
hmm this looks that is not the same thing right?
i mean like tonytoys 5000 lines

Trust me, it is the same thing. I've updated the copyright signature from an old nickname to my real name; and I added many new features since the 5000 lines days. Also moved it from GoogleCode to GitHub.

Translating thousands of code written in a language with pointer to a non-pointer one is hell. I'd rather rewrite from scratch than killing myself into such a hell.
Title: Re: AllegroBASIC
Post by: ScriptBasic on January 18, 2016, 11:28:41 am
Quote
think how many Basic programmers know C or better to say how many understand what is what in C.

Dah. Why do you think I wrote the C BASIC helper library/include?
Title: Re: AllegroBASIC
Post by: Aurel on January 18, 2016, 12:15:16 pm
Quote
Translating thousands of code written in a language with pointer to a non-pointer one is hell
hi wang
yeah you have a right but oxygen have almost same pointers like C with casting and typedefs.
so if i understand old 5000 lines code still exists..right?
so what is AllegroBasic ..wrapper for MyBasic?
Title: Re: AllegroBASIC
Post by: Aurel on January 18, 2016, 12:26:11 pm
I download mybasic.exe form github and when i run app i get
this ,,so we need this VCruntime(++) to run myBasic programs?
i think that old 5000 line version don't need that ..right?
Title: Re: AllegroBASIC
Post by: wang renxin on January 18, 2016, 02:57:10 pm
Hi Aurel,

The exe in the repository was compiled with VC++ 2015, which I think is too new that a 2015 version vc++ runtime lib is required.

The 1.0 is 5000 lines, now it's 1.2. I've expended MB to more than 14000 lines till now by implementing new platform independent features, such as list & dictionary, sub routing, prototype-based OOP, lambda, GC, new C APIs, etc. It doesn't depend on third party libs at all to compile with a standard C compiler. And it's easy to compile with an older VS to make your own executable.

Cybermonkey did all this cool retro game basic on his own, I'm looking forward to his distribution.
Title: Re: AllegroBASIC
Post by: Aurel on January 18, 2016, 04:59:59 pm
Hi wang
so if want to compile any version of mybasic i must use VisualC++ or i can use
something like DEvC++ ?
Well i cannot say that i am not interested BUT this is just a console interpreter
and i really dont have big interest for linux or something else.
Title: Re: AllegroBASIC
Post by: ScriptBasic on January 18, 2016, 07:22:20 pm
Aurel,

You may want to consider embedding MyBASIC in O2 rather than converting it. I have MyBASIC embedded in Script BASIC and it was very easy to do. if you get frisky, you could use your OxyEdit project and create an IDE and interactive BASIC.

John
Title: Re: AllegroBASIC
Post by: wang renxin on January 19, 2016, 02:17:30 am
Hi Aurel, It works with TCC, PellesC, GCC as well if you don't like VS. Or it won't be difficult to download an MSVCRT (https://www.microsoft.com/en-us/download/details.aspx?id=48145).

Yes, John have been making notable progress to ScriptBASIC.
Title: Re: AllegroBASIC
Post by: Aurel on January 19, 2016, 08:19:16 am
Hi Wang
and thanks for reply BUT first as i said before i have in plan to rebuild already created
DLib virtual machine.
You probably don't know but DLib have already built in all winApi with userdefined
functions as part of language itself and many other things
It is created in PureBasic
Title: Re: AllegroBASIC
Post by: wang renxin on January 19, 2016, 08:48:01 am
Aurel, thanks for your advice. It's able to make MB more portable by including MSVCRT DLLs to the repository with current exe, but that's not what I'd like to do; instead, I might going to find an earlier version of VS to rebuild an exe that won't requires new coming runtimes.

I believe you've been making lots of efforts dedicating to DLib. Just for curious, how did you expose ALL Win API in DLib, one by one wrapper, or any generic solution? Excuse my ignorance, but I have no experience with PureBASIC.
Title: Re: AllegroBASIC
Post by: Aurel on January 19, 2016, 09:01:45 am
Quote
Just for curious, how did you expose ALL Win API in DLib
yes that is good question but i am not original author of DLIb and original author abandoned
project ,he also refuse any contact or explanation ..so i am on my own...
i hope you understand answer and DLib is not open source.
Title: Re: AllegroBASIC
Post by: wang renxin on January 19, 2016, 09:13:53 am
i hope you understand answer and DLib is not open source.

Sure.

And I can imagine it's possible to make generic solution if the host language supports strict memory layout alignment definition for fields of a struct, also the ability to load a DLL then invoke a C function. Or use something like how the libffi  (https://github.com/atgreen/libffi)does.
Title: Re: AllegroBASIC
Post by: Aurel on January 19, 2016, 10:04:58 am
well DLib work with DLL s witout a problem and 14000 api call supported...
by the way VM is cca 4000 lines of PureBasic code..not bad right?
Title: Re: AllegroBASIC
Post by: wang renxin on January 19, 2016, 10:10:37 am
well DLib work with DLL s witout a problem and 14000 api call supported...
by the way VM is cca 4000 lines of PureBasic code..not bad right?

Absolutely nice.
Title: Re: AllegroBASIC
Post by: Cybermonkey on January 23, 2016, 03:51:58 pm
Some more news... I decided to port my old project TinyIDE for Bacon to AllegroBASIC. The result can be seen in the screenshot.
This is really a simple editor but at least we got a syntax highlighting for AllegroBASIC and later for RETROBASIC. (And I know many Windows users don't want to mess around with the command line ...)  ;)
Oh and by the way, as you can see in the screenshot, I already included Wang's file module.
Title: Re: AllegroBASIC
Post by: Tomaaz on January 23, 2016, 04:03:22 pm
Where's the download link?
Title: Re: AllegroBASIC
Post by: Cybermonkey on January 23, 2016, 04:50:59 pm
Where's the download link?
Not available, yet ... probably tomorrow (CET  ;))
Title: Re: AllegroBASIC
Post by: Tomaaz on January 23, 2016, 05:23:30 pm
Where's the download link?
Not available, yet ... probably tomorrow (CET  ;))

Do you mean 24/01 at 00:00 CET. Good.  ;D
Title: Re: AllegroBASIC
Post by: Cybermonkey on January 23, 2016, 10:29:09 pm
Where's the download link?
Not available, yet ... probably tomorrow (CET  ;))

Do you mean 24/01 at 00:00 CET. Good.  ;D
LOL ...  ;D
Title: Re: AllegroBASIC
Post by: Cybermonkey on January 24, 2016, 04:22:10 pm
Okay it's time to test AllegroBASIC. Grab it from the homepage: http://allegrobasic.pulsar2d.org/
Please be sure to read the notes for Windows 10 users if you are using Windows 10.  ;)
Title: Re: AllegroBASIC
Post by: Tomaaz on January 24, 2016, 05:17:15 pm
Please be sure to read the notes for Windows 10 users if you are using Windows 10.  ;)

I've changed compatibility, but it still doesn't work properly. Terminal and the graphics window are getting mixed, Mandelbrot example hangs forever without any output, the one with a knight has problems with keyboard input. Esc doesn't work and you can move the knight only once. After he starts moving, he's moving forever and you cannot stop it or change its direction. Also, the link to MY-BASIC documentation crashes both Firefox and Chromium. Once, I even had to restart the whole system. Well... I think I'm gonna pass. :(
Title: Re: AllegroBASIC
Post by: Cybermonkey on January 24, 2016, 05:52:57 pm
Hm, very strange. You can be sure that I tested everything on Windows 10 and all works on my rather slow Netbook.
Even stranger you can't open the Github page with the documentation... No problems with Firefox here.
Title: Re: AllegroBASIC
Post by: ScriptBasic on January 24, 2016, 07:53:48 pm
Don't be discouraged, you're just getting the traditional BP.org Bitter BASIC response. (bottom feeders)
Title: Re: AllegroBASIC
Post by: Tomaaz on January 24, 2016, 10:44:34 pm
Hm, very strange. You can be sure that I tested everything on Windows 10 and all works on my rather slow Netbook.

I'm pretty sure Win 10 is to blame. It wasn't pre-installed. I did an upgrade on this machine and you know - I heard a lot of stories about upgrading to Win 10.

Even stranger you can't open the Github page with the documentation...

Yeah. This is really strange. It was probably a problem with the website itself (on Linux I got a message that something went wrong etc.), but still - it shouldn't have crashed the browsers. Anyway. Linux version of AllegroBASIC seems to work fine.
Title: Re: AllegroBASIC
Post by: wang renxin on January 25, 2016, 04:33:28 am
Hi Markus,

I do feel excited to see your distribution. Works fine on my Win7 64bit, didn't get a Win10 and it seems it doesn't deserve to upgrade to it for the moment.

The referenced usertype was not enough documented, until now I added some detail in the Wiki (https://github.com/paladin-t/my_basic/wiki/Use-usertype-values).

I have a few questions with AllegroBASIC. How did you implemented resources, I tried following code but it crashed the IDE:

Code: [Select]
image=loadimage ("sprite.bmp")
back=loadbmp ("grass.bmp")
print image;
print back;

It shall use a customized mb_fmt_func_t ft functor to serialize a referenced usertype; or just prints "USERTYPE" for a (non-referenced) usertype generated as following:

Code: [Select]
mb_value_t ret;
mb_make_usertype(ret, 0);
mb_check(mb_push_value(s, l, ret));

Does it need to manually release resources which were loaded with following functions to avoid leakage:

Code: [Select]
loadsound
loadimage
loadbmp

I noticed it includes a "tickcount" function, is there another time utilitity function which returns elapsed time within a "sync" cycle? That would be useful for real time games to implement CPU frequency independent motion and animation.

Furthermore, it's able to import (https://github.com/paladin-t/my_basic/wiki/Import-another-file) a common "keycodes.bas" file for key code definitions, and so on other common code. It's also probably useful to print the "char* f" parameter to tell the file name which an error occurs, eg:

Code: [Select]
static void _on_error(struct mb_interpreter_t* s, mb_error_e e, char* m, char* f, int p, unsigned short row, unsigned short col, int abort_code) {
mb_unrefvar(s);
mb_unrefvar(p);
if(SE_NO_ERR != e) {
if(f) {
_printf("Error:\n    [LINE] %d, [COL] %d, [FILE] %s,\n    [CODE] %d, [MESSAGE] %s, [ABORT CODE] %d.\n", row, col, f, e, m, abort_code);
} else {
_printf("Error:\n    [LINE] %d, [COL] %d,\n    [CODE] %d, [MESSAGE] %s, [ABORT CODE] %d.\n", row, col, e, m, abort_code);
}
}
}
Title: Re: AllegroBASIC
Post by: Aurel on January 25, 2016, 07:43:14 am
OK i download Allegro on my win7
run Tiny IDE and open examples folder then I try
Every program first open console window then open output standard system window
but you cannot close this output window then you must close
console window to exit program.
also something is wrong with parent definition because every time you run any
sample you see flash desktop window problem with HWND_DESKTOP
inside main window procedure
also when output window runing IDE content dissapear ?
(ps work little bit faster on my old XP comp  :o )
Title: Re: AllegroBASIC
Post by: jj2007 on January 25, 2016, 08:17:44 am
Runs fine on Win7-64, but as Aurel said,
- you can't close the main window
- it is unresponsive while the program is running
- and it's irritating that you get an exception when you close the console (the only way to end the program)

But the result looks very nice, compliments!
Title: Re: AllegroBASIC
Post by: ScriptBasic on January 25, 2016, 08:21:24 am
Pressing ESC when the program ends will return you back to the IDE which closes normally with the system title/tool bar exit method.
Title: Re: AllegroBASIC
Post by: Aurel on January 25, 2016, 09:09:07 am
Quote
Pressing ESC when the program ends will return you back to the IDE which closes normally with the system title/tool bar exit method
well yes but this is  a poor method ...
i think that someone need to learn better how to properly work with windows API
Title: Re: AllegroBASIC
Post by: Aurel on January 25, 2016, 09:11:54 am
Quote
I noticed it includes a "tickcount" function, is there another time utilitity function which returns elapsed time within a "sync" cycle?
yes of course this one:

Declare Function QueryPerformanceCounter   Lib "kernel32.dll" (ByRef lpPerformanceCount As LARGE_INTEGER) As Long
Declare Function QueryPerformanceFrequency Lib "kernel32.dll" (ByRef lpFrequency As LARGE_INTEGER) As Long

well how you don't know that?
experience with windows api functions wrappers helps a lot..
Title: Re: AllegroBASIC
Post by: wang renxin on January 25, 2016, 10:28:46 am
I know that, anyway, thanks Aurel for copying and pasting _ticks from my_basic/shell/main.c here.
Title: Re: AllegroBASIC
Post by: Aurel on January 25, 2016, 05:15:19 pm
Quote
I know that, anyway, thanks Aurel for copying and pasting _ticks from my_basic/shell/main

no need for thanks and this is  NOT copy/paste from your file then from mine
written in awinh.inc - Oxygen basic include file

also you can view it here:
http://www.oxygenbasic.org/forum/index.php?topic=307.45

Title: Re: AllegroBASIC
Post by: Cybermonkey on January 25, 2016, 07:22:54 pm
Hi Markus,

I do feel excited to see your distribution. Works fine on my Win7 64bit, didn't get a Win10 and it seems it doesn't deserve to upgrade to it for the moment.

The referenced usertype was not enough documented, until now I added some detail in the Wiki (https://github.com/paladin-t/my_basic/wiki/Use-usertype-values).

I have a few questions with AllegroBASIC. How did you implemented resources, I tried following code but it crashed the IDE:

Code: [Select]
image=loadimage ("sprite.bmp")
back=loadbmp ("grass.bmp")
print image;
print back;

It shall use a customized mb_fmt_func_t ft functor to serialize a referenced usertype; or just prints "USERTYPE" for a (non-referenced) usertype generated as following:

Code: [Select]
mb_value_t ret;
mb_make_usertype(ret, 0);
mb_check(mb_push_value(s, l, ret));

Does it need to manually release resources which were loaded with following functions to avoid leakage:

Code: [Select]
loadsound
loadimage
loadbmp

I noticed it includes a "tickcount" function, is there another time utilitity function which returns elapsed time within a "sync" cycle? That would be useful for real time games to implement CPU frequency independent motion and animation.

Furthermore, it's able to import (https://github.com/paladin-t/my_basic/wiki/Import-another-file) a common "keycodes.bas" file for key code definitions, and so on other common code. It's also probably useful to print the "char* f" parameter to tell the file name which an error occurs, eg:

Code: [Select]
static void _on_error(struct mb_interpreter_t* s, mb_error_e e, char* m, char* f, int p, unsigned short row, unsigned short col, int abort_code) {
mb_unrefvar(s);
mb_unrefvar(p);
if(SE_NO_ERR != e) {
if(f) {
_printf("Error:\n    [LINE] %d, [COL] %d, [FILE] %s,\n    [CODE] %d, [MESSAGE] %s, [ABORT CODE] %d.\n", row, col, f, e, m, abort_code);
} else {
_printf("Error:\n    [LINE] %d, [COL] %d,\n    [CODE] %d, [MESSAGE] %s, [ABORT CODE] %d.\n", row, col, e, m, abort_code);
}
}
}

Oh, I think I did that wrong because I didn't reference any usertype. I just "pushed" a usertype back:
Code: [Select]
static int bas_loadbmp (struct mb_interpreter_t* s, void** l) {
int result = MB_FUNC_OK;
char *filename;
BITMAP *image;

mb_assert(s && l);
mb_check(mb_attempt_open_bracket(s, l));
mb_check(mb_pop_string(s, l, &filename));
mb_check(mb_attempt_close_bracket(s, l));

image=load_bitmap (filename, NULL);

if (image) {
mb_check(mb_push_usertype(s,l,image));
}
else {
allegro_message ("Error reading image file %s", filename);
exit (1);
}

return result;
}

But if I use the ret value to assign a bitmap I got the following compile error:
Quote
allegrobasic.c:972: warning: assignment from incompatible pointer type
allegrobasic.c:989: warning: assignment from incompatible pointer type
allegrobasic.c:1008: error: cannot cast 'struct BITMAP *' to 'struct mb_value_t'
What did I wrong?

I will of course change the error message, so one can see in which module the error occured.

@jj2007: I totally forgot that people always want to click on the red "x" to close windows. I will add that soon. (But how do you close fullscreen windows?  ;))

@aurel: Of course I could compile AllegroBASIC that it does not need a console but it is intended because the PRINT and INPUT functions work with the CMD.exe.
Furthermore I do not use the WinAPI directly, the editor is done with Lazarus/Freepascal the graphics  output with Allegro. I don't use any WinAPI function directly because both programs are primarily developed on Linux. I also use TCC as the compiler for AllegroBASIC. You should wait for RETROBASIC which will use SDL2 (better window handling) and GCC as the main compiler. However, this won't change the behaviour of the editor, it just waits until the BASIC sctript execution has ended.
Title: Re: AllegroBASIC
Post by: ScriptBasic on January 25, 2016, 08:02:24 pm
Markus,

Maybe you should give it a go in Script BASIC. It's multi-threaded and really easy to use. The C extension API makes the BASIC expansion unlimited on all platforms.

Just food for thought.

Title: Re: AllegroBASIC
Post by: wang renxin on January 26, 2016, 01:45:48 am
Markus,

That would be fine. The following two usage perform the same thing:

Code: [Select]
1. Yours
image = load_bitmap(filename, NULL);
mb_check(mb_push_usertype(s, l, image));

2. Same as
image = load_bitmap(filename, NULL);
mb_value_t ret;
mb_make_usertype(ret, image);
mb_check(mb_push_value(s, l, ret));

After that, it's able to retrieve a bitmap as:

Code: [Select]
1.
BITMAP* image = NULL;
mb_check(mb_pop_usertype(s, l, (void**)&image));

2.
BITMAP* image = NULL;
mb_value_t arg;
mb_check(mb_pop_value(s, l, &arg));
image = (BITMAP*)arg.value.usertype;

You don't need to call mb_ref_value or ??_ref_?? things for usertypes created from above, only mb_make_ref_value generates a referenced usertype. So I think you need some releasing functions for non-referenced usertype.

BTW. if you use the BITMAP* or other resources directly as the usertype data, it won't carry any type information representing for if it's a BITMAP, or an IMAGE, or something else... Why not use a struct wrapper:

Code: [Select]
// Pseudo code
struct AllegroBASICObject {
enum type;
void* data;
};

Then you could do different things according to different type.

Best.
Title: Re: AllegroBASIC
Post by: jj2007 on January 26, 2016, 08:34:43 am
@jj2007: I totally forgot that people always want to click on the red "x" to close windows.

Markus,

Windows gives you three standard options to close a window: the "x", the system menu in the upper left corner, and pressing Alt F4. Part of the success story of Microsoft Windows is that the user gets a uniform interface, and therefore does not have to dig into the source code to discover the "inkey", which btw does not react to Alt F4 for some reason.

Similar for the IDE: If the source is not saved, it gives you an idiosyncratic prompt. Standard would be "Save changes?", "Yes/No/Cancel", and instead of clicking, you could press y, n or Escape without any risk to take a wrong decision.

Don't take this as a criticism, more as an observation. Quite often I noticed in the old bp.org that people (especially with Linux experience) do not follow the Windows logic. For example, there was a long thread about CPU usage going up with BASIC programs because of a bad implementation of GetMessage(). I do hate Windows, and wish Mr Gates should go to jail to pay for the damage he has done, but standardisation is one of the few positive aspects...
Title: Re: AllegroBASIC
Post by: Aurel on January 26, 2016, 05:42:17 pm
Quote
The mandelbrot sample code came along with AllegroBASIC takes ~63 seconds on my i7 PC
hi wang
i cannot believe 63 seconds on i7  :o
Title: Re: AllegroBASIC
Post by: Cybermonkey on January 26, 2016, 09:02:35 pm
Markus,

That would be fine. The following two usage perform the same thing:

Code: [Select]
1. Yours
image = load_bitmap(filename, NULL);
mb_check(mb_push_usertype(s, l, image));

2. Same as
image = load_bitmap(filename, NULL);
mb_value_t ret;
mb_make_usertype(ret, image);
mb_check(mb_push_value(s, l, ret));

After that, it's able to retrieve a bitmap as:

Code: [Select]
1.
BITMAP* image = NULL;
mb_check(mb_pop_usertype(s, l, (void**)&image));

2.
BITMAP* image = NULL;
mb_value_t arg;
mb_check(mb_pop_value(s, l, &arg));
image = (BITMAP*)arg.value.usertype;

You don't need to call mb_ref_value or ??_ref_?? things for usertypes created from above, only mb_make_ref_value generates a referenced usertype. So I think you need some releasing functions for non-referenced usertype.

BTW. if you use the BITMAP* or other resources directly as the usertype data, it won't carry any type information representing for if it's a BITMAP, or an IMAGE, or something else... Why not use a struct wrapper:

Code: [Select]
// Pseudo code
struct AllegroBASICObject {
enum type;
void* data;
};

Then you could do different things according to different type.

Best.

Hi Wang,

I changed the "retrieving" functions and added the (void**) cast. It's now possible to print the bitmap, sound or whatever. The result is USERTYPE.  This will be part of the next upload.
And a question: Is it possible to interrupt a script and exit the program? I want to implement  a check if the window close button was clicked. In Allegro it looks like that:
Code: [Select]
void close_button_handler(void)   {
 
 exit (EXIT_SUCCESS);
 }
END_OF_FUNCTION(close_button_handler)

And in the init part:
Code: [Select]
LOCK_FUNCTION(close_button_handler);
set_close_button_callback(close_button_handler);

But if I close the window I always get a  segementation fault ...

My atexit() function looks like this:
Code: [Select]
static void _on_exit(void) {

  mb_close(&bas);
  mb_dispose();
  remove_sound();
  allegro_exit();
}
Title: Re: AllegroBASIC
Post by: ScriptBasic on January 26, 2016, 09:53:07 pm
IF MyBASIC is doing the calling to your Allegro library, maybe you should release those resources before dropping MyBASIC.

Code: [Select]
static void _on_exit(void) {

  remove_sound();
  allegro_exit();
  mb_close(&bas);
  mb_dispose();
}
Title: Re: AllegroBASIC
Post by: wang renxin on January 27, 2016, 02:11:22 am
@Aurel, Yes it does.

@Markus, Need to know in which step it triggers a segementation fault.

@John, It's proper to drop MY-BASIC before releasing resource stuff, especially when using referenced usertype to hold resources. It disposes all referenced data in mb_close, thus the reference could be a wild reference if it has already released resources before closing MY-BASIC. Your way might work ok in AllegroBASIC, since it's using non-referenced usertype; but it's a hidden trouble.
Title: Re: AllegroBASIC
Post by: Cybermonkey on February 07, 2016, 09:47:15 pm
A new version will be uploaded soon with some major changes.
1. I got rid of that console window - since Windows user don't get on with that. I implemented via the nice tinyfiledialogs an inputbox (see attached screenshots). All errors are now reported by a messagebox.
2. You can now close the Window with the 'X' button - but the BASIC programmer have to take care of it. A function which returns ture or false if the window was closed was implemented. (So there are no segmentation faults anymore ...)
Sample code:
Code: [Select]
screen (800,600,"CircleTrap")
KEY_ESC          = 59   
setfps (200)
h = screenheight/2
w = screenwidth/2
paper (0,0,0)
do

cls (x)

t = tickcount/1000
for i=1 to 360
    ink (255,255-i,255-i)
    circle (w+sin(i*90+t)*200,h+cos(i*90+t)*200,20+i)
next
sync

until (keystate (KEY_ESC) = true) or (windowclosed=true)
end
Title: Re: AllegroBASIC
Post by: Cybermonkey on February 08, 2016, 06:58:55 pm
Good news ... I just compiled AllegroBASIC on Windows 10 and it works now without setting the compatiblity mode. Just a few days for upload ...
Title: Re: AllegroBASIC
Post by: Cybermonkey on February 10, 2016, 07:21:10 pm
I also added a time function, stay tuned, download will be next weekend.
Title: Re: AllegroBASIC
Post by: Cybermonkey on February 28, 2016, 11:59:46 am
Allright guys, version 0.6 of AllegroBASIC is available on the homepage: http://allegrobasic.pulsar2d.org/
What's new?
Title: Re: AllegroBASIC
Post by: Galileo on July 30, 2016, 11:30:42 am
Hello, Cybermonkey. I'm sorry you do not feel continue programming (I hope it is temporary). In any case, I tried AllegroBASIC and I find very interesting. I would better know the dialect, but for that I need documentation on it. Could you wrote if only a cursory relationship command with a description of its functionality and a small example of use?
Title: Re: AllegroBASIC
Post by: Cybermonkey on July 30, 2016, 04:14:45 pm
Well, the best documentation is what you'll find on the Github page for MY-BASIC: https://github.com/paladin-t/my_basic
Apart from that I added some input, graphics and sound functions. For any of them there's an example. (Most interesting/comprehensive example is probably keyandsprite.bas.)