Task: Try Programming in FastBasic on an Atari 8-Bit Computer
Needed: Altirra emulator
Time: 15-30 mins
I have previously posted about the diversity of different BASIC programming languages for the Atari 8-bit computers. Among these is FastBasic which is a modern BASIC for the Atari. I decided to give FastBasic a try given it has a number of advantages over the older BASICs.
FastBasic was developed by Daniel Serpell or ‘dmsc’ and first released as open-source software in 2017. As its name implies, it was designed to be a fast version of BASIC. It is approximately twice as fast as compiled TurboBasicXL. Some features include a modern syntax with no line numbers, more modern control structures such DO and WHILE loops, integrated editor and compiler, cross-compiler for development on a PC, and high-level commands which make procedures such as display list interrupts and player-missile graphics much easier.
I have prepared a simple example in both BASIC and FastBasic to make it easy to see some of the differences (see figure below). The program I wrote in both languages creates a 10 element array of integers and then calculates and prints the sum of the 10 values. There are a few key differences. First, there are no line numbers in the FastBasic code. Second, the BASIC program reads in the 10 values from a data statement and put them in a one-dimensional array. A FOR loop is needed to do this. Note that FastBasic provides a nice syntax for creating arrays without a loop (line 4). Third, the BASIC program calls the summation subroutine at line 200. FastBasic introduces syntax for creating procedures (see PROC CALCSUM) which can be called using the command EXEC. FastBasic definitely gives the programmer the feel of a modern programming language. I will try to post some additional examples.
First, download and boot the FastBasic ATR (version 4.4) I have provided in a zip file (newer versions can be found here). This will take you to the intro screen shown below. Hit enter. This will take you to a SpartaDos X prompt (D1:). From here you can select the floating-point version by typing FB and hitting enter. You can also select the integer version by typing FBI and hitting enter. Either are fine for this demo.
Second, you will now see the help screen shown below. This summarizes the different commands you can use to edit and interact with your code. Later, we will use Ctrl-L for loading the file and Ctrl-R to execute the code. For now, hit Ctrl-N to move on to the editor.
Third, you are ready to either type in code or load a program. Type Ctrl-L to load the program SUM.FBA from the ATR file. Once loaded, the program will display in the editor. The top row shows the filename and what screen line the cursor is on.
Fourth, run the program by typing Ctrl-R. The code is parsed, interpreted, and then executed. You should see the number 10 which is the result of summing the ten 1s in the array. End the program by pressing the break key (pause on PC).
Fifth, for comparison you can boot into Altirra or Atari BASIC and load the program SUM.BAS and RUN.
I have enjoyed this exercise and am motivated to write more code in FastBasic. It takes a little getting used to, but I can definitely see the potential. I found the editor to be a little difficult to use and kept wanting to fix code by writing a new line number. I think I just need some time to get used to using the editing commands for making code edits. Let me know what you think!
Note that the integer version fits within 8k so you could easily make a FastBasic cartridge for use on original hardware as I have previously demonstrated.
Note that I could not save a FastBasic file to a floppy disk with Atari DOS on it. This is because the DOS is uses is BW-DOS, and old Sparta compatible DOS. To write files to disks using Atari DOS you need to copy all the FastBasic files to the Atari DOS disk. I didn’t try this but dmsc indicated it will work.
Note that FastBasic indexes arrays from 0 whereas BASIC starts at 1. You will see that in my code above.
Note there are several syntax differences. For example, there is a ; after PRINT #6 in Atari BASIC. FastBasic uses a , instead.
Note that as of July 25, 2021 there is a new version (4.5.2) of FastBasic available which adds the ability to pass parameters to procedures. I have written a separate post about this new feature.