Skip to main content
? Atomic Flash

GFA BASIC TIPS & TRICKS by Richard Karsmakers

In a special article,  elsewhere in this issue of ST NEWS, you'll 
find  an  article that covers a topic that is  very  often  asked 
concerning  its functioning in GfA  Basic:  Windows.  Written  by 
master-programmer Stefan Posthuma,  it is quite readable and even 
accompanied by a documented source program.

Another answer that I have received several times already was the 
question  how  it is possible to play digitized  sound  from  GfA 
Basic. Lucky enough, I had use of some of G-Data's "Sound Sampler 
II" software to explain it (the code, since it may be included in 
your own programs as well,  is supplied on this disk). The source 
file (called "SEQUENCE.BAS",  and written in GfA Basic) is  self-
explanatory.  The  "SAMPLER.IMG" file belongs to it;  both  files 
should be in the same folder.
If you are interested in Sound Sampling,  please contact  G-Data, 
who  offer  some  good  sampling hardware  as  well  as  splendid 
software.  Their address is Siemensstr. 16, D-4630 Bochum 1, West 
Germany.

A  lot  of people also seem to have problems with the  GfA  basic 
Exec  command,  according to some of the questions that came  in. 
Exec  can be used as a command or as a function.  The  respective 
syntaxes are:

       EXEC flag,name string,command string,environment string
       EXEC(flag,name string,command string,environment string)

The  'flag'  is a numeric variable,  and can have  the  following 
values:

       0 = Load and run
       3 = Load only

The  other  variables are string variables,  and  they  have  the 
following meanings:

       Name string: The name of the program to load
       Command string: This is the string that you specify when
                       a file would be a .TTP or .APP. An empty
                       string ("") is enough most of the times
       Environment string: An empty string ("") is mostly enough.
Before  using  the Exec command,  you should  reserve  a  certain 
amount of memory that Basic wants to use.  RESERVE 50000 will  be 
enough  for most applications.  The following program  loads  and 
executes  a program to one's choice (might be an idea for a  menu 
program?):

       Reserve 10000
       Fileselect "\*.*","",Lo$
       Exec 0,Lo$,"",""

That's  all there is to it.  Remarkable  simple,  isn't  it?  The 
'function'  version of the Exec command can be used to  determine 
the base page address of the program that you load. The following 
should  do  the  same as the above  program,  but  a  little  bit 
different:

       Reserve 10000
       Fileselect "\*.*","",Lo$
       A%=Exec(3,Lo$,"","")        !A%=Basepage address
       Add A%,256                  !Skip basepage
       Call A%

Another  question had to do with the GEM counterpart of the  Exec 
command: GEM function &h4B.
Mr.  Chris  Whitelock  of Bristol,  England,  had  typed  in  the 
following program, and all he got was a '2 bomb error'. Why?

       A$="Filename.prg"
       B$=""
       Void Gemdos(&H4B,0,Varptr(A$),Varptr(B$),varptr(B$)

In  GEMDOS-,   XBIOS-and  BIOS  functions,   GfA  Basic  requires 
specification  of  longwords or words.  When none  is  given,  it 
assumes that a word (2 bytes) is meant.  However,  the  addresses 
(Varptr)  are  longwords (4 bytes).  So the last line  should  be 
replaced by

       Void Gemdos(&H4B,0,L:Varptr(A$),L:Varptr(B$),L:Varptr(B$))

and everything works smoothly. Do take care of memory management!

The last question is no real question,  but a hint given by  Hans 
van  der  Linden for people that have problems reading  the  FAT. 
This is indispensable for a good file monitor.  Once you know the 
first  cluster  position,  you should read in the  FAT  and  keep 
yourself to the following rules.

  Cl%=??           !First cluster of the file
  Ncl%=Int(1.5*Cl%)!This is the place of the Low byte
  '                 High byte=Ncl%+1
  If Cl% Mod 2=0 Then Ncl%=Ncl% And $FFF
                 Else Ncl%=(Ncl% Shiftright 4) and $FFF

  Repeat this until $FF8<=Ncl%<=$FFF ($FF0-$FF7 = Bad Cluster)

Do note:  This is no GfA Basic,  but a kind of 'flowchart'.  It's 
only there to give you some guidelines.

Disclaimer
The text of the articles is identical to the originals like they appeared in old ST NEWS issues. Please take into consideration that the author(s) was (were) a lot younger and less responsible back then. So bad jokes, bad English, youthful arrogance, insults, bravura, over-crediting and tastelessness should be taken with at least a grain of salt. Any contact and/or payment information, as well as deadlines/release dates of any kind should be regarded as outdated. Due to the fact that these pages are not actually contained in an Atari executable here, references to scroll texts, featured demo screens and hidden articles may also be irrelevant.