Author Topic: AllegroBASIC  (Read 6658 times)

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 573
    • View Profile
    • Home of EGSL
AllegroBASIC
« on: 17. January 2016, 19:22:26 »




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: 17. January 2016, 23:16:25 by Cybermonkey »
Best regards,
Cybermonkey

wang renxin

  • Newcomer
  • *
  • Posts: 36
    • View Profile
Re: AllegroBASIC
« Reply #1 on: 18. January 2016, 09:04:13 »
 ;)

Aurel

  • Regular Member
  • Sr. Member
  • *
  • Posts: 272
    • View Profile
Re: AllegroBASIC
« Reply #2 on: 18. January 2016, 11:08:32 »
well i am wondering how much work is needed if i decide to translate source code
5000 lines for example into Oxygenbasic code ?
new basic pro forum on;
http://basicpro.spacefor.site/smf/
GUEST posting enabled

John

  • Sr. Member
  • ****
  • Posts: 362
    • View Profile
Re: AllegroBASIC
« Reply #3 on: 18. January 2016, 11:52:58 »
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

  • Regular Member
  • Sr. Member
  • *
  • Posts: 272
    • View Profile
Re: AllegroBASIC
« Reply #4 on: 18. January 2016, 12:05:15 »
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
new basic pro forum on;
http://basicpro.spacefor.site/smf/
GUEST posting enabled

Aurel

  • Regular Member
  • Sr. Member
  • *
  • Posts: 272
    • View Profile
Re: AllegroBASIC
« Reply #5 on: 18. January 2016, 12:08:26 »
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;
new basic pro forum on;
http://basicpro.spacefor.site/smf/
GUEST posting enabled

Aurel

  • Regular Member
  • Sr. Member
  • *
  • Posts: 272
    • View Profile
Re: AllegroBASIC
« Reply #6 on: 18. January 2016, 12:14:53 »
WOW 14596 lines ...
hmm this looks that is not the same thing right?
i mean like tonytoys 5000 lines
new basic pro forum on;
http://basicpro.spacefor.site/smf/
GUEST posting enabled

wang renxin

  • Newcomer
  • *
  • Posts: 36
    • View Profile
Re: AllegroBASIC
« Reply #7 on: 18. January 2016, 12:23:41 »
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: 18. January 2016, 12:28:05 by wang renxin »

John

  • Sr. Member
  • ****
  • Posts: 362
    • View Profile
Re: AllegroBASIC
« Reply #8 on: 18. January 2016, 12:28:41 »
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

  • Regular Member
  • Sr. Member
  • *
  • Posts: 272
    • View Profile
Re: AllegroBASIC
« Reply #9 on: 18. January 2016, 13:15:16 »
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?
new basic pro forum on;
http://basicpro.spacefor.site/smf/
GUEST posting enabled

Aurel

  • Regular Member
  • Sr. Member
  • *
  • Posts: 272
    • View Profile
Re: AllegroBASIC
« Reply #10 on: 18. January 2016, 13:26:11 »
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?
new basic pro forum on;
http://basicpro.spacefor.site/smf/
GUEST posting enabled

wang renxin

  • Newcomer
  • *
  • Posts: 36
    • View Profile
Re: AllegroBASIC
« Reply #11 on: 18. January 2016, 15:57:10 »
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: 18. January 2016, 16:02:04 by wang renxin »

Aurel

  • Regular Member
  • Sr. Member
  • *
  • Posts: 272
    • View Profile
Re: AllegroBASIC
« Reply #12 on: 18. January 2016, 17:59:59 »
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.
new basic pro forum on;
http://basicpro.spacefor.site/smf/
GUEST posting enabled

John

  • Sr. Member
  • ****
  • Posts: 362
    • View Profile
Re: AllegroBASIC
« Reply #13 on: 18. January 2016, 20:22:20 »
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: 18. January 2016, 20:28:28 by John »

wang renxin

  • Newcomer
  • *
  • Posts: 36
    • View Profile
Re: AllegroBASIC
« Reply #14 on: 19. January 2016, 03:17:30 »
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: 19. January 2016, 03:20:41 by wang renxin »