Skip to main content

IMPROVING GFA BASIC PROGRAMS
by Rober Heessels (STIKE-a-LIGHT Software)

In  this  article  I will tell you some  of  my  experience  about 
improving  the programs you write in GfA basic.  But  speaking  of 
improving I would first like to congratulate the makers of ST NEWS 
who keep improving their magazine every time.

In  my  article you could read in ST NEWS 2.5 (RCS  FILES  IN  GfA 
BASIC) I told you how you could use resource files.  Using them is 
a good way to make your programs look professional.  All the space 
that is needed by buttons,  inputs,  etc. can be well shaped using 
resource files.

But  what  about the space on the screen that is not  occupied  by 
buttons  and  inputs?  What  about the information  shown  on  the 
screen, the output to the user? What about the name of the program
and the programmer when they are shown on the screen?  What  about 
help pages?

Using functions like TEXT,  LINE,  CIRCLE,  RBOX, etc. can improve 
your program, but there is another way.
You  can use a drawing program like DEGAS ELITE to  make  pictures 
which  can  cheer  up your program.  These pictures  can  be  full 
screens  as  well as parts of the screen (blocks).  You  can  draw 
whatever  you  like  using all the nice  functions  of  a  drawing 
program, and then use the picture files from within your program.

All drawing programs save their pictures in different formats.  In 
this  article I will assume you use DEGAS or DEGAS ELITE.  If  you 
have  another drawing program you can use programs  like  PICWORKS 
2.0 (made by us) to convert your pictures to DEGAS files.

First you'll have to know how a DEGAS picture file is constructed. 
You must use the uncompressed files: *.PI1 *.PI2 *.PI3.
Such a file is 32034 bytes long. A screen (in the computer) is, no 
matter  what resolution,  32000 bytes of information.  This  means 
that the file contains 34 bytes of information, that is: 17 words.
The   first  word  (2  bytes)  of  the  file  is  the   resolution 
information.
Then follow 16 words which are the colour information.
Then follow 32000 bytes which are the screen information.
You won't need the first word,  so all there is left is the colour 
information, and the screen information. Quite simple, isn't it?

As  I  told you a screen in the memory of the ST  is  32000  bytes 
long. Such a screen can be laid on every memory location you like.
In  fact  there  are always 2 screens.  One screen  on  which  the 
computer does things like printing,  drawing lines,  etc.,  and on 
the other screen does nothing change.  That is the screen the user 
is looking at.
The  first  screen is called the logical  screen,  the  second  is 
called the physical screen.  In most cases the two screens are  on 
the same memory location, so you will see all changes happen.

If you want to put something on the screen, but you don't want the 
user  to  see  it (yet),  then you must lay  the  two  screens  on 
different  memory  locations.  You can,  for example  make  smooth 
animation by building your picture on the logical screen, and then 
change the two screens, etc.
You  can  change  the  two screen  locations  using  the  XBIOS  5 
function:

  Void Xbios(5,L:logic%,l:physic%,-1)
Before  you  change the screen locations you'll have to  free  the 
memory, otherwise basic will screw up the screen contents. You can 
do this by:

  Reserve 100000

The  number indicates how much memory there will be left  for  the 
program and his variables.  If you want more or less memory  free, 
that's OK, but 100000 bytes will be quite right for most purposes.

Now  you've  done this you can ask the computer  at  which  memory 
location the memory is free for you to use. You do this by:

  Memorytop%=Himem

In  most  ST  computers the Memorytop%  variable  will  be  around 
&H47000.  It  is wise to lay your screens only at  locations  like 
&H48000, &H50000, &H58000, &H60000, &H68000, etc.
By the way, the memory of your computers ends at &H80000 (1/2 meg) 
or &H100000 (1 meg).

The start of your program should now look like this:

  Reserve 100000                        ! free memory
  Void Xbios(5,L:&H78000,l:&H78000,-1)  ! set screens at &H78000
  Cls                                   ! clear screen

Now  we  can  load a DEGAS ELITE picture  file  into  the  memory. 
Because the screen location is at &H78000 we will load the picture 
at &H70000.  The steps of &H8000 are in fact 32768 bytes long,  so 
there is enough memory between the locations to leave the extra 34 
bytes of the picture file. We will load the picture at &H70000-34, 
so  the screen information will immediately be at the location  of 
&H70000.

  Bload "A:\PICTURE.PI1",&H70000-34

Now  we  can't see the picture,  because it is not on  the  screen 
memory.  We will now move to picture information to the screen. Do 
this by:

  Bmove &H70000,&H78000,32000 ! move 32000 bytes &H70000 > &H78000 

Now  the  picture is on the screen.  Tada!!!  But  wait  ...  What 
happened  to  the colours?  We didn't tell the  computer  anything 
about the colours,  so he didn't change them.  Quite logical.  But 
how do we the the computer to show the right colours:

  Void Xbios(6,L:&H70000-32)  ! get colours at &H70000-32

Remember the colours were right before the screen information,  so 
at  &H70000-32.  Xbios 6 is used to get the colours at  a  certain 
location.
By experimenting with this stuff you must be able to use  pictures 
from within your program.

If  you have any questions you're welcome to write to me.  I  will 
answer them if I can.

I  wish you a successful and joyful journey through the  hazardous 
bits of your kompjoeter.

Oh yes, my address:

STRIKE-a-LIGHT software
T.a.v. Robert Heessels
Grote Berg 85
5611 KJ  Eindhoven
The Netherlands 

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.