Omnimaga

Calculator Community => Other Calculators => Topic started by: coolsnake on September 02, 2010, 03:45:02 pm

Title: Why FreeBASIC rocks your socks.
Post by: coolsnake on September 02, 2010, 03:45:02 pm
I've had a craving today for a programming language on the pc which is quite similar to TI-Basic.
This craving was mostly fueled by the BasiC++ project here on omnimaga.  :P

/Insert rant about how most programming languages are hard, either in use or in syntax.

This is something I created today in TI-Basic. It's a primitive fighting engine with you being the X and the enemy being the Z. If either of you punches your respective character changes to the theta symbol.
(http://a.imageshack.us/img341/6496/tibasic.gif)

This is a direct port in FreeBASIC, a language which I understood in less than one day with the help of one tutorial and the command list.  ;D
(http://a.imageshack.us/img713/6058/freebasic.gif) 
Moral of the story, you know more of programming than you think + FreeBASIC is awesome. :P

also, port to axe^^
(http://a.imageshack.us/img37/6789/axer.gif)
Title: Re: Why FreeBASIC rocks your socks.
Post by: Builderboy on September 02, 2010, 04:38:28 pm
Sweet!  So it has many of the similar syntax and commands? Looks really nice :)
Title: Re: Why FreeBASIC rocks your socks.
Post by: Deep Toaster on September 02, 2010, 05:22:45 pm
That looks great! Really want to try it, but it's taking so long to install... :P
Title: Re: Why FreeBASIC rocks your socks.
Post by: meishe91 on September 02, 2010, 05:31:26 pm
That looks really cool :) Where can you learn and such? I'll add it to my tutorial thread :D
Title: Re: Why FreeBASIC rocks your socks.
Post by: Deep Toaster on September 02, 2010, 05:32:24 pm
It seems to run faster than TI-BASIC ;)
Title: Re: Why FreeBASIC rocks your socks.
Post by: meishe91 on September 02, 2010, 05:46:05 pm
I'm going to guess that's because it's a computer language ;)
Title: Re: Why FreeBASIC rocks your socks.
Post by: Deep Toaster on September 02, 2010, 06:12:37 pm
I wonder if it'll possible to add a language like BASIC to KOS (not exactly like TI-BASIC; something simple and fast).
Title: Re: Why FreeBASIC rocks your socks.
Post by: meishe91 on September 02, 2010, 06:17:17 pm
Well I think one of the big reasons TI-BASIC is so slow is because it parses as it runs. So if there was a good way to parse it first then execute or something it would not be as big of an issue.
Title: Re: Why FreeBASIC rocks your socks.
Post by: Deep Toaster on September 02, 2010, 06:19:21 pm
Well I think one of the big reasons TI-BASIC is so slow is because it parses as it runs. So if there was a good way to parse it first then execute or something it would not be as big of an issue.

Wow, the TI community has yet to come up with a working BASIC to ASM converter.
Title: Re: Why FreeBASIC rocks your socks.
Post by: meishe91 on September 02, 2010, 06:20:51 pm
People have tried but it's incredibly hard to do. I mean it's sorta like what Quigibo is doing with Axe except you have to take each command and match it up in assembly and ya. Well I think anyways. In short...its hard :P
Title: Re: Why FreeBASIC rocks your socks.
Post by: Deep Toaster on September 02, 2010, 06:27:34 pm
...and an hour and a half later, FreeBASIC is 75% done installing :P
Title: Re: Why FreeBASIC rocks your socks.
Post by: miotatsu on September 02, 2010, 07:00:12 pm
now I have an urge to work on BasiC++ :P
Title: Re: Why FreeBASIC rocks your socks.
Post by: Raylin on September 02, 2010, 07:00:16 pm
@DThought: I started installing this compile a few seconds ago. It's done now. :P
Title: Re: Why FreeBASIC rocks your socks.
Post by: meishe91 on September 02, 2010, 07:02:44 pm
now I have an urge to work on BasiC++ :P

What is the completion percentage of BasiC++ anyways?
Title: Re: Why FreeBASIC rocks your socks.
Post by: Deep Toaster on September 02, 2010, 07:08:22 pm
@DThought: I started installing this compile a few seconds ago. It's done now. :P

:( Two hours later, it's done. I hate Windows.

And meishe91, http://tinyurl.com/cxkn9u (http://tinyurl.com/cxkn9u) is the manual.
Title: Re: Why FreeBASIC rocks your socks.
Post by: miotatsu on September 02, 2010, 07:10:30 pm
right now it is at 0% because it was lost when my hard drive was wiped and I havent worked on it since. My plan has been to start it back up again after I finish piworld, but if I get a strong enough urge to work on it before then I might

you can see what it was like before the wipe happened though: http://i534.photobucket.com/albums/ee348/Miotatsu/Untitled-50.png

also sorry for the offtopicness, FreeBASIC looks cool
Title: Re: Why FreeBASIC rocks your socks.
Post by: meishe91 on September 02, 2010, 07:21:47 pm
Ah ok, well that sucks about the hard drive wipe :( But good luck with Piworld in the meantime :)

It looked cool though.

@Deep Thought
Thanks :)
Title: Re: Why FreeBASIC rocks your socks.
Post by: calc84maniac on September 02, 2010, 08:52:25 pm
Well I think one of the big reasons TI-BASIC is so slow is because it parses as it runs. So if there was a good way to parse it first then execute or something it would not be as big of an issue.
It would still be almost as slow, because of all the floating-point arithmetic. It would also be significantly bigger.
Title: Re: Why FreeBASIC rocks your socks.
Post by: willrandship on September 02, 2010, 09:55:44 pm
@meishe
Hmm....isn't that pretty much what axe does? (well kinda) :P

I know, it converts it to asm, not preparsing per se, but it's a similar idea.

BTW, the concept of parsing before running a program is called compiling :P

Floating point arithmetic.....is there any way around it in TI-Basic?
Title: Re: Why FreeBASIC rocks your socks.
Post by: meishe91 on September 02, 2010, 10:05:23 pm
Well I think one of the big reasons TI-BASIC is so slow is because it parses as it runs. So if there was a good way to parse it first then execute or something it would not be as big of an issue.
It would still be almost as slow, because of all the floating-point arithmetic. It would also be significantly bigger.

Ah ok, gotcha. I just read that somewhere or something like that. Probably just misinterpreted or something. What does the floating point do though? Like why does that slow it down?

@meishe
Hmm....isn't that pretty much what axe does? (well kinda) :P

I know, it converts it to asm, not preparsing per se, but it's a similar idea.

BTW, the concept of parsing before running a program is called compiling :P

Floating point arithmetic.....is there any way around it in TI-Basic?

What exactly are you referencing? As for as I know Axe is a language in itself and then you run it through AxeParser which then compiles it into assembly which is just a step up from computer language (binary, correct?) so it parses it very little when it's executed. But with TI-BASIC it runs directly as it is and as it runs the calculator compiles it as it goes, at least that is what I've gotten from reading some things.

Ya, I know. Just couldn't think of the word :P
Title: Re: Why FreeBASIC rocks your socks.
Post by: willrandship on September 02, 2010, 10:11:15 pm
well, kind of. Interpreting means basically what you said.

if you've ever heard of RPG maker 2000 or Game Maker, they are both Interpreted languages, which, like you say, means basically compiling as you go, and forgetting the compiled stuff after it's run.

And yes, but I was just saying axe was a fairly viable super-fast replacement for Ti-basic, and to the first-time user it appears to be doing something similar.

I think the 86 pre-parsed its code, because it  would take a while to run after being edited, and take a while to be edited after run. Still only about 84+ speed though (which is amazing considering how much worse of a cpu it has, and the actual parsing it has to do. TI-84 basic only has to read the tokens, while 86 basic has to read real text.)
Title: Re: Why FreeBASIC rocks your socks.
Post by: DJ Omnimaga on September 03, 2010, 12:58:31 am
Keep in mind this project is not for calcs, though, it's for the computer. I'll move the topic in the BasiC++ sub-fora to avoid confusion. It's a PC language that is pretty much the same as TI-BASIC. It does games similar to on a calc, but later I think he was planning to add some more stuff so people can do old-skool PC games with the ease of TI-BASIC (and maybe Axe?)

I am glad this is not dead, btw :)
Title: Re: Why FreeBASIC rocks your socks.
Post by: meishe91 on September 03, 2010, 01:10:28 am
Wait, why are you moving this to BasiC++? Miotatsu was just talking about it for a second, FreeBASIC is something completely different. So I think this should really be in Non-Calc-Related Computer Projects And Ideas or something similar.
Title: Re: Why FreeBASIC rocks your socks.
Post by: DJ Omnimaga on September 03, 2010, 01:16:47 am
Oh wow, sorry, my bad. When I opened this topic, for some reasons, it went straight to page 2, even thought I did not read the topic at all before. I saw Miotatsu's first post and thought it was a new topic by him about his old BasiC++ project, renamed to FreeBASIC.

I'll need to check harder next time, I didn't know about that forum glitch until now x.x

My apologies again. Gonna move this back to calc section.

Awesome btw, Coolsnake. :)
Title: Re: Why FreeBASIC rocks your socks.
Post by: meishe91 on September 03, 2010, 01:19:22 am
Ah ok, that's what I kinda thought you had done :P What forum glitch?
Title: Re: Why FreeBASIC rocks your socks.
Post by: DJ Omnimaga on September 03, 2010, 01:22:08 am
Normally, on the new posts page, when you click a topic name, it takes you to the first post made since the last time you read the topic. However, this time, it took me on page 2 instead of 1, even if I never saw page 1 before. I think that happened before, too, but I'm unsure anymore.
Title: Re: Why FreeBASIC rocks your socks.
Post by: meishe91 on September 03, 2010, 01:25:12 am
Ah ok. Gotcha.
Title: Re: Why FreeBASIC rocks your socks.
Post by: coolsnake on September 03, 2010, 10:53:17 am
I'm glad you all like FreeBASIC.  :)
The syntax is kinda the same. Just different words for the same thing  :P
The thing I like so much about it is that it handles the command prompt screen almost exactly the same way TI-basic handles the calculator screen.
E.g Output(5,1,"blablabla") becomes

Code: [Select]
LOCATE 5,1 'places the cursor at that spot
print "blablabla"
Title: Re: Why FreeBASIC rocks your socks.
Post by: DJ Omnimaga on September 03, 2010, 06:04:41 pm
Hmm, some of it reminds me Casio calculators...

If it's similar to TI-BASIC and Casio BASIC, maybe I could learn it easily :)
Title: Re: Why FreeBASIC rocks your socks.
Post by: Deep Toaster on September 03, 2010, 06:05:27 pm
Hey, it's standalone! Good, I can have it on my thumb drive :)
Title: Re: Why FreeBASIC rocks your socks.
Post by: coolsnake on September 04, 2010, 09:01:31 am
For those who want a jumpstart on how to use FreeBASIC:
http://www.freebasic.net/wiki/wikka.php?wakka=TutGettingStartedQB
http://www.freebasic.net/wiki/wikka.php?wakka=TutHowToProgGame1

I only read those two to make my port from TI-Basic to Freebasic.
The first link shows how to output text, draw lines,draw circles, rectangles.
The second one is more interesting. It shows you how to create a game loop by moving a circle.
It'll introduce you to FB's "GetKey", "ClrHome", loops and the declaration of variables.
They don't take long to read either, it's great!

Look at this page to get a quick peek at all the commands:
http://www.freebasic.net/wiki/wikka.php?wakka=CatPgFullIndex

Hmm, some of it reminds me Casio calculators...

If it's similar to TI-BASIC and Casio BASIC, maybe I could learn it easily :)

Well that's the beauty of it. It may not have the exactly same syntax but It certainly does "feel" like TI-Basic.
I'm really developing to become a FreeBASIC fanboy now.  :P
You could also "setup" FreeBASIC to behave alot more like TI-Basic on the calculator.
Here's a quick tutorial:
NOTE: You can get alot of this out of the previously mentioned tutorials too.

If you add the following line to the top of your FreeBASIC source, you get a 16x8 character screen like the one on your calc.
Code: [Select]
screenres 136,72
If you add these lines to the top you can use the very responsive GetKey from FB(there's also a slower one):
Code: [Select]
   #include "fbgfx.bi"
    Using FB

The very responsive GetKey works just like in Axe
Code: [Select]
MultiKey(SC_KEY)
If you want to use certain variables you have to declare them.
You're probably not used to this in TI-Basic but it's standard fare in computer languages.
Code: [Select]
DIM as integer A,B,C
DIM as string Str1,Str2
It's pretty straightforward. Here's a link to the datatypes.
http://www.freebasic.net/wiki/wikka.php?wakka=CatPgStdDataTypes

If you want to store variables:
Code: [Select]
A=10
str1="abc"

The pause command in TI-Basic becomes
Code: [Select]
Sleep
If you want to pause for 100 milliseconds
Code: [Select]
Sleep 100,1If you don't add the ",1" it'll wait for 100 milliseconds OR until a key is pressed. the ",1" disables the latter.

ClrHome becomes
Code: [Select]
Cls
If your hesistant about using FB's syntax and rather want to use TI-Basic's syntax, you can just add a subroutine to the beginning of your code.
e.g for ClrHome

Code: [Select]
Sub ClrHome
cls
End sub

And now you can use ClrHome in the same way you use it as in TI-Basic! :D
i'm going to go out on a limb here and say that you can do this for about every TI-Basic command except:
-the (unconventional) storage of variables e.g 10-> B
-Conditionals
-Loops

Here's a subroutine to use the Output command.
Note that I use output1(Y,X,"text") instead of output(Y,X,"text") because there already is a (different) function called output in FB, so I can't just replace it with mine.
Code: [Select]
sub output1(Y as integer,X as integer,text as string)
locate Y,X
print text
end sub

Also be aware that FB is certainly not limited to the stuff I'm showing you.
Check FB's projects page to see what FB is capable of.
http://www.freebasic.net/forum/viewforum.php?f=8
I kinda smirked at the gameboy emulator thing.
*imagines writing a gameboy emulator in TI-Basic ;D*
Title: Re: Why FreeBASIC rocks your socks.
Post by: DJ Omnimaga on September 04, 2010, 05:54:15 pm
Nice. I'm really glad there's a TI-BASIC like computer language. I tried VB and C before and I just don't like it. Same for TI-Nspire/89 BASIC, although not as much. I prefer syntaxes like TI-83+ BASIC or Axe. Also I'm glad it is not just limited to text games.
Title: Re: Why FreeBASIC rocks your socks.
Post by: meishe91 on September 04, 2010, 07:03:46 pm
Very cool. I'll add that to my Tutorials page.
Title: Re: Why FreeBASIC rocks your socks.
Post by: Deep Toaster on September 04, 2010, 10:23:14 pm
If your hesistant about using FB's syntax and rather want to use TI-Basic's syntax, you can just add a subroutine to the beginning of your code.
e.g for ClrHome

Code: [Select]
Sub ClrHome
cls
End sub

And now you can use ClrHome in the same way you use it as in TI-Basic! :D
i'm going to go out on a limb here and say that you can do this for about every TI-Basic command except:
-the (unconventional) storage of variables e.g 10-> B
-Conditionals
-Loops

Wow, that's a really useful feature. We should keep track of the particularly useful replacements and post it somewhere...
Title: Re: Why FreeBASIC rocks your socks.
Post by: DJ Omnimaga on September 04, 2010, 10:25:58 pm
Ok so if we call a command that is not the name of any FreeBASIC command or name used, it will interpret it as an actual sub-routine? Seems kinda nice. Someone could easily write a set of sub-routines that lets someone use pretty much all game programming TI-BASIC commands.
Title: Re: Why FreeBASIC rocks your socks.
Post by: Deep Toaster on September 04, 2010, 10:53:55 pm
Hm, I wonder if FreeBASIC could be changed a bit (meaning the source itself so that it would run TI-BASIC programs perfectly. That would be easier than using an emu!
Title: Re: Why FreeBASIC rocks your socks.
Post by: Builderboy on September 04, 2010, 10:56:26 pm
That would be hella awesome :D Or maybe a crossover language for people who know calc programing but want to move onto computer programing
Title: Re: Why FreeBASIC rocks your socks.
Post by: meishe91 on September 04, 2010, 10:57:48 pm
Well isn't that essentially what Miotatsu is doing with BasiC++?
Title: Re: Why FreeBASIC rocks your socks.
Post by: Deep Toaster on September 04, 2010, 11:53:57 pm
And I think there was a topic somewhere around here about making an online calc simulator ... what about just a simple TI-BASIC emulator? It would be really helpful to people without an emu on their computer.
Title: Re: Why FreeBASIC rocks your socks.
Post by: coolsnake on September 05, 2010, 02:09:41 pm
I've been browsing FB's site for a bit and I think I might be able to create a library for FB. Concretely it means you just need to add two files to the FreeBasic lib directory, add two lines of code to the start of your source code, and presto, pseudo TI Basic.  :P
I do consider this a "hackish" attempt though, since it's just mainly renaming known functions. But meh, I've never written a library before and it sounds fun.   :D

Hm, I wonder if FreeBASIC could be changed a bit (meaning the source itself so that it would run TI-BASIC programs perfectly. That would be easier than using an emu!

Well FreeBASIC is opensource... But I doubt it would be that easy.^^ It's mainly there so people can use new but potentially unstable versions.
Title: Re: Why FreeBASIC rocks your socks.
Post by: DJ Omnimaga on September 05, 2010, 02:14:34 pm
One other question about FreeBASIC: if you want people to be able to play your game, do they absolutely need to install FreeBASIC or can you make them standalone executables like Visual Basic and RPG Maker (in the latter, you needed to use an undocumented trick to remove dependencies, though)?
Title: Re: Why FreeBASIC rocks your socks.
Post by: coolsnake on September 05, 2010, 03:16:01 pm
Don't worry, it compiles to standalone executables. Dependencies are a turnoff in general  :P
Title: Re: Why FreeBASIC rocks your socks.
Post by: DJ Omnimaga on September 06, 2010, 04:01:01 pm
Ok good. With one of my old VB games, I discovered it requires me to download some OCX files to play them and it won't tell me where to put them (in the system folders it doesn't work in Windows 7 64 bit)
Title: Re: Why FreeBASIC rocks your socks.
Post by: Jonius7 on September 06, 2010, 07:32:25 pm
is this for the nspire?
Title: Re: Why FreeBASIC rocks your socks.
Post by: calcdude84se on September 06, 2010, 09:28:26 pm
Sadly, no. It's a computer program (definitely Windows, Idk about Linux or Mac OS)
Title: Re: Why FreeBASIC rocks your socks.
Post by: DJ Omnimaga on September 06, 2010, 09:30:46 pm
It would be cool if it was made for the Nspire. I always wished there was an easy language for it. Otherwise, Axe could work, but it can be a bit harder I guess, than 83+ style basic.
Title: Re: Why FreeBASIC rocks your socks.
Post by: Deep Toaster on September 07, 2010, 07:04:47 pm
Don't worry, it compiles to standalone executables.

Oh, so it's like Axe (as in compiling to assembly)!

And I think there is a Linux version for download. Haven't tried it yet.