Installing Freebasic on (Debian) Linux.

by Computothought in Circuits > Linux

13976 Views, 3 Favorites, 0 Comments

Installing Freebasic on (Debian) Linux.

mc.png
roids.png
c-sine.png

Freebasic is like Qbasic. Most all of the instructables we do that involve programming use Freebasic. One think I like about it is the ease of programming the parallel and other ports on the computer. There are certainly lots of other programming languages you could use (i.e. http://computothought.wordpress.com/2010/04/06/freedom-of-assembly/), but there have been so many programs written for qbasic, you just hate not to be able to use them.

Freebasic is a derivative of the Beginners All Purpose Instruction Code aka Basic. BASIC (standing for Beginner's All Purpose Symbolic Instruction Code) was written (invented) in 1963, at Dartmouth College, by mathematicians John George Kemeny and Tom Kurtzas as a teaching tool for undergraduates. BASIC has been one of the most commonly used computer programming languages, a simple computer language considered an easy step for students to learn before more powerful languages such as FORTRAN. Ironically I learned Fortran before I ever new about Basic. Today, probably the web based languages such as Javascript, Python, or C might be more in line with what people are using.

You may want to install the c compiler first, if you have not already done so.
$ sudo apt-get install build-essential

Manual Install

freebasic.png

Normally I only try to use software from the Linux, but this is an exception. You could use Mono, but there are too many legal and other issues involved.

Install Freebasic: on newer system libfreebasic is not needed. now version: 1.00.0

$ sudo apt-get install libfreebasic libxext-dev libncurses5-dev libx11-dev libxpm-dev libxrandr-dev libstdc++6-4.4-dev
Go to sourceforge.net and download FreeBASIC-0.24.0-linux.tar.gz
$ tar zxvf FreeBASIC-0.24.0-linux.tar.gz
$ cd FreeBASIC-

1.00.0

-linux
$ chmod +x install.sh
$ sudo ./install.sh -i
Write a program:
$ vim helloworld.bas

[code]
print "Hello world! "
[/code]

Compile it:
$ fbc -lang qb helloworld.bas

Run it:
$ ./helloworld
Hello World!


Note According to http://www.freebasic.net/forum/viewtopic.php?f=17&p=189357 Freebasic is now available for the ARM. There are some download links on the page. Since the Freebasic website soes not include them, sue with caution.

Gui Test.

roids.png
You could try this program to see how freebasic works with your gui.

roids.bas:
[code]
' ÜÛÛÛÛÜ  ÜÛÛÛÛÛÛÜ ÛÛÛÛÛÛÛÛ ÛÛÛÛÛÛÛÛÛ ÛÛÛÛÛÛÜ   ÜÛÛÛÛÛÜ  ÛÛ ÛÛÛÛÛÛÜ  ÜÛÛÛÛÛÛÜ
'ÛÛ    ÛÛ ÛÛß  ßßß    ÛÛ    ÛÛ        ÛÛ   ßÛÛ ÛÛß   ßÛÛ ÛÛ ÛÛ   ßÛÛ ÛÛß  ßßß
'ÛÛ    ÛÛ ßÛÛÜ        ÛÛ    ÛÛ        ÛÛ   ÜÛÛ ÛÛ     ÛÛ ÛÛ ÛÛ    ÛÛ ßÛÛÜ
'ÛÛÛÛÛÛÛÛ   ßÛÛÜ      ÛÛ    ÛÛÛÛÛÛ    ÛÛÛÛÛÛß  ÛÛ     ÛÛ ÛÛ ÛÛ    ÛÛ   ßÛÛÜ
'ÛÛ    ÛÛ     ßÛÛÜ    ÛÛ    ÛÛ        ÛÛ   ÛÛ  ÛÛ     ÛÛ ÛÛ ÛÛ    ÛÛ     ßÛÛÜ
'ÛÛ    ÛÛ ÛÛÜ  ÜÛÛ    ÛÛ    ÛÛ        ÛÛ    ÛÛ ÛÛÜ   ÜÛÛ ÛÛ ÛÛ   ÜÛÛ ÛÛÜ  ÜÛÛ
'ÛÛ    ÛÛ  ßÛÛÛÛß     ÛÛ    ÛÛÛÛÛÛÛÛÛ ÛÛ    ÛÛ  ßÛÛÛÛÛß  ÛÛ ÛÛÛÛÛÛß   ßÛÛÛÛß
'
'This is a one person game.  The object is to shoot the falling asteroids and
'keep them from hitting the surface.   Use the left and right arrow keys to
'move your gun and the up key to fire.  The "P" button pauses the game, and
'the "Q" button ends it.  When a game is paused, hit space to make it run
'again.  Scoring is based on the level you're on.  The higher the level, the
'more points for hit asteroids, and the less points taken away for missed
'asteroids.  While you play, you may notice the screen flickering badly, or
'the action to fast.  To correct this, make the number after Flicker.Control
'(shown below) bigger.  If the game goes too slow, make the number smaller.
Flicker.Control = 500   ' Now press "F5" to play.
'
'
'

SCREEN 7       '320 X 200 resolution
RANDOMIZE TIMER

movement = 0

playagain:
CLS
LOCATE 12, 1
COLOR 15
INPUT ; "What level do you want to start at"; level
LOCATE 12, 1
PRINT "                                         "
gun = 165
missile.x = -5000
missile.y = 5000
totalhit = 0
misses = 0
totaldropped = 0

newasteroid:
asteroid.x = 319 * RND + 1
asteroid.y = 1
totaldropped = totaldropped + 1

a:

COLOR 0
WHILE movement = 1
LINE (gun2 - 20, 170)-(gun2 + 20, 170)
LINE (gun2, 155)-(gun2 - 20, 170)
LINE (gun2, 155)-(gun2 + 20, 170)
LINE (gun2 - 3, 147)-(gun2 + 3, 170), , BF
movement = 0
WEND

COLOR 15
LINE (gun - 20, 170)-(gun + 20, 170)
LINE (gun, 155)-(gun - 20, 170)
LINE (gun, 155)-(gun + 20, 170)
LINE (gun - 3, 147)-(gun + 3, 170), , BF
LINE (asteroid.x - 10, asteroid.y - 6)-(asteroid.x + 10, asteroid.y + 6), 6, BF
CIRCLE (missile.x, missile.y), 3, 12
LINE (1, 171)-(319, 171), 9

FOR count = 1 TO Flicker.Control
NEXT count


asteroid.x2 = asteroid.x
asteroid.y2 = asteroid.y
missile.x2 = missile.x
missile.y2 = missile.y

COLOR 0
LINE (asteroid.x2 - 10, asteroid.y2 - 6)-(asteroid.x2 + 10, asteroid.y2 + 6), 0, BF
CIRCLE (missile.x2, missile.y2), 3, 0



LOCATE 23, 1
COLOR 9
PRINT "Shot:"; totalhit
LOCATE 23, 11
PRINT "Level:"; level
LOCATE 23, 21
PRINT "Score:"; score

missile.y = missile.y - 5

IF missile.y < 1 THEN
missile.y = 5000
END IF

asteroid.y = asteroid.y + level * .75

IF asteroid.y > 170 THEN
CIRCLE (asteroid.x, asteroid.y), 30, 14
CIRCLE (asteroid.x, asteroid.y), 30, 0
misses = misses + 1
IF misses = 10 THEN
GOTO gameover
END IF
score = score - INT(10 / level)
GOTO newasteroid
END IF

IF missile.x - 3 < asteroid.x + 10 AND missile.x + 3 > asteroid.x - 10 AND missile.y + 3 < asteroid.y + 6 THEN
totalhit = totalhit + 1
IF totalhit / 10 = INT(totalhit / 10) THEN
level = level + 1
misses = 0
END IF
score = score + 10 * level
FOR ctr = 1 TO 7
  radius = 15 * RND + 5
  offset.x = 40 * RND - 20
  offset.y = 40 * RND - 20
  circlecolor = 16 * RND
  CIRCLE (asteroid.x + offset.x, asteroid.y + offset.y), radius, circlecolor
  FOR ctr2 = 1 TO 50
  NEXT ctr2
  CIRCLE (asteroid.x + offset.x, asteroid.y + offset.y), radius, 0
NEXT ctr
missile.y = 5000
GOTO newasteroid
END IF

move$ = INKEY$

SELECT CASE move$
CASE CHR$(0) + "K"
gun2 = gun
gun = gun - 5
movement = 1
CASE CHR$(0) + "M"
gun2 = gun
gun = gun + 5
movement = 1
CASE CHR$(0) + "H"
missile.x = gun
missile.y = 147
CASE "q"
GOTO quit
CASE "p"
COLOR 15
LINE (gun - 20, 170)-(gun + 20, 170)
LINE (gun, 155)-(gun - 20, 170)
LINE (gun, 155)-(gun + 20, 170)
LINE (gun - 3, 147)-(gun + 3, 170), , BF
LINE (asteroid.x - 10, asteroid.y - 6)-(asteroid.x + 10, asteroid.y + 6), 6, BF
CIRCLE (missile.x, missile.y), 3, 12
LOCATE 12, 4
PRINT "Game Paused Hit Space to continue"
startpause:
  a$ = INKEY$
  SELECT CASE a$
  CASE " "
  LOCATE 12, 4
  PRINT "                                  "
  GOTO endpause
  END SELECT
GOTO startpause
END SELECT

endpause:

GOTO a

gameover:

LINE (1, 171)-(319, 171), 9
LOCATE 23, 1
COLOR 9
PRINT "Shot:"; totalhit
LOCATE 23, 11
PRINT "Level:"; level
LOCATE 23, 21
PRINT "Score:"; score
COLOR 15

LINE (gun - 20, 170)-(gun + 20, 170)
LINE (gun, 155)-(gun - 20, 170)
LINE (gun, 155)-(gun + 20, 170)
LINE (gun - 3, 147)-(gun + 3, 170), , BF

COLOR 4
LOCATE 12, 1
PRINT "E                                      O"
LOCATE 12, 1
PRINT "ME                                    OV"
LOCATE 12, 1
PRINT "AME                                  OVE"
LOCATE 12, 1
PRINT "GAME                                OVER"
LOCATE 12, 1
PRINT " GAME                              OVER "
LOCATE 12, 1
PRINT "  GAME                            OVER "
LOCATE 12, 1
PRINT "   GAME                          OVER "
LOCATE 12, 1
PRINT "    GAME                        OVER "
LOCATE 12, 1
PRINT "     GAME                      OVER "
LOCATE 12, 1
PRINT "      GAME                    OVER "
LOCATE 12, 1
PRINT "       GAME                  OVER "
LOCATE 12, 1
PRINT "        GAME                OVER "
LOCATE 12, 1
PRINT "         GAME              OVER "
LOCATE 12, 1
PRINT "          GAME            OVER "
LOCATE 12, 1
PRINT "           GAME          OVER "
LOCATE 12, 1
PRINT "            GAME        OVER "
LOCATE 12, 1
PRINT "             GAME      OVER "
LOCATE 12, 1
PRINT "              GAME    OVER "
LOCATE 12, 1
PRINT "               GAME  OVER "

FOR ctr = 1 TO 500
NEXT ctr

LOCATE 13, 13
PRINT "Play Again? y/n"
playagain.y.n:
y.n$ = INKEY$
SELECT CASE y.n$
CASE "n"
GOTO quit
CASE "y"
GOTO playagain
END SELECT
GOTO playagain.y.n

quit:
[/code]

$ fbc -lang qb roids.bas

Downloads

Other Freebasic Instructables.

lw.png

Dosbox to Access Other Basics.

basic-1.png
basic-2.png

Gwbasic generally saves code is a special format. You can load those files in and then save them in ascii or text.

QB64

Screenshot from 2012-08-02 05:01:05.png
basic-3.png

Qb45 (www.qb64.net) is another basic compiler. It is available for the major platforms. (instructions for Ubuntu 12.04 is at: http://www.as2.com/pdf/QB64-install-manual-on-Precise-Pangolin.pdf