From Atari Wiki
Revision as of 13:12, 13 October 2011 by Admin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


So you have decided to read this tutorial? Ok, so I either assume you already know about GFABASIC or not. Read on if not.


"What is this GFABASIC this guy is talking about?" you may ask yourself? The programming language BASIC has been around since the 1960s. BASIC is an acronym and it stands for Beginners All Purpose Symbolic Instruction Code. A programming language that is easy to use for a wide range of projects by anyone to bring it to the point. GFABASIC is a dialect of this but it is not a BASIC in its original form. It is more a mix of classic BASIC with structured languages like PASCAL and Modula-2. But wait a minute - before GFABASIC there was more. Let me go back into 1985. The then famous computer company Atari launched its best coup ever in 1985, the Atari 520ST. A miraculous computer in its time, offering a wealth of graphic abilities, floppy disks, harddrives and a price that was unbeatable. Called the Jackintosh because the ST clearly was intended to be an answer to Apple's Macintosh, the ST had it all. Its sound seemed poor in the view back but the computer was intended as an office machine like the Macintosh or the then poor PCs. Coming with a graphical environment in ROM, it surely was a dream machine in 1985. Entering BASIC, the ST came from the start with a very poor implementation of the original BASIC language called ST-BASIC. This implementation used the graphic environment GEM of the ST but it suffered from a poor editor, old fashioned code with linenumbers, very slow execution of its BASIC programs and buggy implementation. In 1985 there was nothing else so the few ST users had to use it. Frank Ostrowski from Germany had already written a better BASIC implementation for the 8-bit range of computers by Atari. He moved on to the ST and decided to do a better ST-BASIC. This started the GFABASIC project. GFABASIC saw the day of light in 1986, roughly a year since the ST hit the market. The ST was already highly popular in Europe, especially in Germany, mainly because of its price and wealth of features. So the better ST-BASIC had a good start. It sold well and people would use it. But not only the fact it was the second and better BASIC, a main factor for the ongoing popularity of GFABASIC is its qualtity. From the start GFABASIC came with a rather bugfree interpreter, a wealth of commands, options and very good execution speed of its programs. Especially the ability to fully use and hook into the Atari ST's OS, TOS with its graphical components GEM and VDI, hit the street and quickly lots of decent software titles appeared in the public domain and as typeins that showed what GFABASIC could do. Time would show that even fast action games and demos are entirely possible in this dialect of a language that was already considered slow and clumsy in its time. Try the game Roger or the GFA demos by The Overlanders to see what I mean.

In short, it is still worth the effort to learn and use GFABASIC if you are into Atari ST computers, either via emulation or with a real machine.

GFABASIC features

GFABASIC has a lot of interesting features which help in developing a program.

  • one command or declaration per line for better readability
  • variables and identifiers in general can have 16 or more characters to distinguish them from each other
  • data typing and arrays
  • use of subroutines and functions
  • powerful loop and program flow constructs
  • file operations
  • commands to directly access the TOS, the OS of the Atari ST
  • commands for using VDI and AES, allowing for easy use of graphics in your program
  • commands for direct memory manipulation, allowing you to access the machine almost as with machine language
  • possibility to merge source code for libraries and reuse
  • builtin sourcecode editor that will do syntax checking while you type
  • automated source formatting in the editor - very handy and it forces you to use a specific style to format your sources
  • compiler available

Interpreter vs Compiler

GFABASIC is interpreted by default. This means the socalled interpreter takes each line of your code and looks what to do with it. The other way is the compiler which will take your code once, translate into directly executable machine code (for the Motorola 68000 microprocessor in the GFABASIC case) resulting in a more speedy program execution as the step for command lookup does not appear anymore. The compiled program just can be executed outofthe box. The advantage of an interpreter is that you can directly test and run your program without running a compiler first. In GFABASIC you just type your code into the builtin editor and then click RUN to execute your program. This is extremely helpful while developing but ofcourse a compiler is available as well allowing you to produce rather fast machine code from your GFABASIC program. Versioning

Either you are convinced by now or not. If so, you should take care of the different versions of GFABASIC. Although compatible in general, a few things should be mentioned. First of all avoid GFABASIC v1.x as that one has no compiler available and lots of useful commands are missing. V2.x can be considered but still commands are missing in particular to access the OS and a few faster graphic routines. If at all possible, use a v3.0 minimum. I personally use v3.6TT and this tutorial is based upon that version of GFABASIC. If a particular command does not work, it is a safe bet to upgrade your version of GFABASIC first. GFABASIC saves its programs in a special tokenized form that cannot be read with a normal texteditor. It is not compatible with other versions of GFABASIC as well. There are GFABASIC files with .BAS and .GFA extender. The .BAS variant is used by v1.x and v2.x, .GFA by v3.x. But a GFABASIC file with .GFA extender cannot be necessarily read by say v3.5 if it has been saved with v3.03. Therefor to exchange GFABASIC code, save your GFABASIC programs with .LST extender with the SAVE,A option as plain ASCII text. For local use on your floppies or harddisc saving as .GFA is ofcourse valid. Just don't mail or attach a .GFA file but go for a .LST instead. .LST files saved from GFABASIC v1.x can be fully run from v3.6 as GFABASIC is downward compatible to itself. However a .LST saved from v3.5 will not necessarily work in v1.0.

GFA BAsic today

Gfa-Basic is not supported by GFA anymore today. But there is an open source clone of GFA-Basic called X11-basic for linux. It uses the same syntax and has most of the GFA-commands and also a nice manual. So its worth having a look here.

back to GFA Tutorial