Author Topic: AllegroBASIC  (Read 17765 times)

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
AllegroBASIC
« on: January 17, 2016, 06:22:26 PM »




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:
  • Only bitmap (bmp) files can be used as image files, so no gifs, pngs or jpgs!
  • Only wave files can be used as sound, so not mp3 or ogg or any other format!
  • There will be no fancy game engine things like particles, bitmap font routines etc. Code it yourself in BASIC!  ;)

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
« Last Edit: January 17, 2016, 10:16:25 PM by Cybermonkey »

wang renxin

  • Guest
Re: AllegroBASIC
« Reply #1 on: January 18, 2016, 08:04:13 AM »
 ;)

Aurel

  • Guest
Re: AllegroBASIC
« Reply #2 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 ?

ScriptBasic

  • Guest
Re: AllegroBASIC
« Reply #3 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)

Aurel

  • Guest
Re: AllegroBASIC
« Reply #4 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

Aurel

  • Guest
Re: AllegroBASIC
« Reply #5 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;

Aurel

  • Guest
Re: AllegroBASIC
« Reply #6 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

wang renxin

  • Guest
Re: AllegroBASIC
« Reply #7 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.
« Last Edit: January 18, 2016, 11:28:05 AM by wang renxin »

ScriptBasic

  • Guest
Re: AllegroBASIC
« Reply #8 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?

Aurel

  • Guest
Re: AllegroBASIC
« Reply #9 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?

Aurel

  • Guest
Re: AllegroBASIC
« Reply #10 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?

wang renxin

  • Guest
Re: AllegroBASIC
« Reply #11 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.
« Last Edit: January 18, 2016, 03:02:04 PM by wang renxin »

Aurel

  • Guest
Re: AllegroBASIC
« Reply #12 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.

ScriptBasic

  • Guest
Re: AllegroBASIC
« Reply #13 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
« Last Edit: January 18, 2016, 07:28:28 PM by John »

wang renxin

  • Guest
Re: AllegroBASIC
« Reply #14 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.

Yes, John have been making notable progress to ScriptBASIC.
« Last Edit: January 19, 2016, 02:20:41 AM by wang renxin »