Skip to main content
? Share And Enjoy

GEM VDI CALLS PART III by Herman de Vrees

Originally  published in ST NEWS Volume 1 Issue  6,  launched  on 
November 15th 1986.

COLOR-DEFINITIONS:

Those of us,  who were rich enough to buy a  color-monitor,  know 
that there is no way to set the color-definitions easy.
You  can set the colors by the 'Control'-accessory,  but you  can 
not save your setting.  In the next routine,  you can define  all 
colors.  These colors are made by mixing the three  ground-colors 
'red', 'green' and 'blue'.
Every ground-color has seven different color-densities.
The syntax is:

     COLORNUMBER = ...
     RED         = 1 .. 7 
     GREEN       = 1 .. 7 
     BLUE        = 1 .. 7 
     gosub COLORSET
 

'Colornumber'  determines,  which color gets defined and  is  the 
same as the color in the command 'COLOR',  so it can be called by 
this command.
It is possible to define a color-palette and save it as a  BASIC-
program.
You can make the color with the next program.

The subroutine is:

62700 COLORSET:
62702 ' -----> RED ; GREEN ; BLUE 
62704 '        COLORNUMBER
62706 poke contrl, 14
62708 poke intin, colornumber
62710 poke intin + 2, red  * 140
62712 poke intin + 4, green * 140
62714 poke intin + 6, blue * 140
62716 vdisys
62718 return
62720 ' --------------------------------------------------

The program is:

5   ' merge "COLORSET.bas"
6   ' merge "RECTANGLE.bas"
9   '
10  fullw 2: clearw 2
20  start:
30  for RED   = 1 to 7
40  for GREEN = 1 to 7
50  for BLUE  = 1 to 7
60  x = x + 1 : if x = 8 then x = 1
70  colornumber = x + 1
80  gosub COLORSET
90  color 1, colornumber, 1
100 xpos1 = 60 : xpos2 = 250
110 ypos1 = -20 + colornumber * 15
120 ypos2 = ypos1 + 13 : gosub rectangle
130 next : next : next
140 out 2, 7 : goto start
150 end

POLYMARKCOLORS:

The  colors  for  VDI- and AES-routines can  be  defined  by  the 
command 'COLOR'.  The 'polymark'-command is an exception on  this 
rule. This command needs an own routine. You can choose from the
defined color-palette by:

     MARKCOLOR = .. 
     gosub POLYMARKCOLOR
 

The subroutine is:

62750 POLYMARKCOLOR:
62752 ' -----> MARKCOLOR
62754 poke contrl, 20
62756 poke intin, markcolor
62758 vdisys
62760 return

The program is:

5   ' merge "POLYMARKCOLOR.bas"
6   ' merge "POLYMARK.bas"
9   '
10  clearw 2: fullw 2
20  for MARKCOLOR = 1 to 15
30  gosub POLYMARKCOLOR
40  xpos = 10 + markcolor * 15
50  ypos = 50
60  gosub POLYMARK
70  next: waiting = inp(2): end

AES-ROUTINES:

CALLING OF AN AES-ROUTINE:

The AES (Application Environment System) takes care of:
  - Calling and controlling desk-accessory
  - Control and management of memory and calculation-time
  - Producing and calling options in the desk-top-menus
  - Windows
  - Mouse-routines
  - Icons (Diskstations and wastebasket)

The  AES is a part of the computersystem and is therefore  always 
available. To us, its very large library of routines are the most 
important  part of the AES.  We can call the AES-routines on  the 
same way as the VDI-routines.  Between BASIC and the AES we  need 
an interface, called 'GEMSYS'.

We also need several special addresses:

     CONTROL     Contains the length of the next fields 
     GLOBAL      Contains several systemdata 
     GINTIN      Input-field for data 
                 (co-ordinates of a window)
 
     GINTOUT     Output of data 
                 (position of the mouse) 
     ADDRIN      Pointer on an address (input) 
     ADDROUT     Pointer on an address (output)
 

We  have  to declare these variables each time we  use  the  AES-
routines. We can do this with the next program.

62900 INIT:
62902 aes# = gb
62904 control = peek(aes#)
62906 global  = peek(aes# + 4)
62908 gintin  = peek(aes# + 8)
62910 gintout = peek(aes# + 12)
62912 addrin  = peek(aes# + 16)

62914 addrout = peek(aes# + 20)
62916 return
62918 ' --------------------------------------------------

WINDOWS:

Most  of the AES-routines are used for building  and  controlling 
windows.  Some of them are already in ST-BASIC ('OPENW', 'CLOSEW' 
and 'CLEARW').  Some of the AES-routines are very interesting  to 
use in your programs.  These routines are called directly by  way 
of the BASIC-AES-Interface, called 'GEMSYS'.
An example of this is the routine to define for yourself the size 
and  the  position  of the window.  The routine  needs  the  next 
information:  coordinates of the left-top-corner, the wanted size 
and the number of the window.
The syntax is:  (widthe = width, I could not use WIDTH)    

     XPOS   =  .....  :  YPOS = .....
     WIDTH =  .....  :  HEIGHT = .....
     WINDOWNUMBER = 1 .. 4 
     gosub SETWIND
 

The windownumbers are not the same as in ST-BASIC,  they have the 
next values:
     EDIT     1 
     LIST     2 
     OUTPUT   3 
     COMMAND  4
 

The routine is:

62000 SETWIND:
62002 ' -----> XPOS   ; YPOS ; WIDTHE
62004 ' -----> HEIGHT ; WINDOWNUMBER
62006 poke gintin    , windownumber
62008 poke gintin + 2, 5
62010 poke gintin + 4, xpos
62012 poke gintin + 6, ypos
62014 poke gintin + 8, widthe  
62016 poke gintin + 10, height
62018 gemsys 105
62020 return
62022 ' --------------------------------------------------

The program is:

5   ' merge "INTIN.bas"
6   ' merge "SETWIND.bas"
9   '
10  gosub INIT
15  for WINDOWNUMBER = 1 to 4
20  xpos = -50 + 100 * windownumber
30  ypos =  10 +  20 * windownumber
40  widthe =  30 +  50 * windownumber
50  height = 200
60  gosub SETWIND
70  next : end

USING THE FULL SCREEN :

All output-commands are executed in the output-window.  Therefore 
you  can  see always the border of  the  output-window.  In  many 
programs  it would be nice to make that  border  invisible.  With 
your Atari almost everything is possible,  even this. An easy way 
to do this,  is to define the size of the output-window a  little 
bit  greater then the screen with the previous routine.  Now  the 
borders of the window are forced from of the screen.
The syntax is:

     gosub INIT 
     gosub FULLWINDOW
 

Particularly for a 'hardcopy' of the screen this routine is  very 
useful: no more borders.
The  subroutine  gives  you the possibility to  define  your  own 
settings:  no borders or just a fine line as border when you want 
a frame on your printer.
The routine is:

62050 FULLWIND:
62052 '
62054 poke gintin    , 3        :' OUTPUT-window
62056 poke gintin + 2, 5        :' with/ without border
62058 poke gintin + 4, 0        :'  0  : (  -1) ; x1
62060 poke gintin + 6, 1        :'  1  : (   0) ; y1
62062 poke gintin + 8, 658      :' 658 : ( 660) ; x2
62064 poke gintin + 10,417      :' 417 : ( 419) ; y2

62066 gemsys 105
62068 return
62070 ' --------------------------------------------------

The BASIC-commands 'FULLW,  CLEARW,  OPENW' give no problems with 
the  full screen,  only with 'CLOSEW' it is advisable to put  the 
window back to its original size by the command 'FULLW 2'.
At  the  same time we have to realize that the  relation  between 
GEM-coordinates and BASIC-coordinates changes with a full screen. 
In  all previous routines we adjusted all  GEM-outputcommands  to 
the BASIC-outputcommands: X-direction 1 pixel and  Y-direction 38 
pixels. Using the full screen the deviation in the Y-direction is 
just  19 pixels and the X-coordinates are equal.  You  have  take 
this  in  account when you are using these routines with  a  full 
screen.

WIPE THE DESK-TOP:

After using the previous routine the desktop-line  remains.  This 
line is not accessible by normal BASIC-commands.  For those of us 
who  wants no desk-top-line on the printer,  you have to use  the 

next routine. This routine draws a white rectangle over the desk-
top-line by using the VDI-routine 'RECTANGLE'.

When you used this routine, you lost the desktop-line. You get it 
back  by  'restart' of the BASIC or by the  routine  'TEXTOUTPUT' 
(described  in  part  I).  This routine has access  to  the  full 
screen,  like all GEM-routines.  Therefore you can generate  your 
own desktop-line.

The routines are:

62080 CLEARDESK:
62082 ' merge "RECTANGLE.bas"
62084 color 1,0,1 :
62086 xpos1 = -1 : xpos2 = 638 : ypos1 = -40 : ypos2 = -20
62088 gosub rectangle: color 1,1,1
62090 return
62092 ' --------------------------------------------------

64000 RECTANGLE:
64002 ' -----> XPOS1 : YPOS1 : XPOS2 : YPOS2
64004 poke contrl    , 11
64006 poke contrl + 2, 2
64008 poke contrl + 6, 0
64010 poke contrl + 10, 1
64012 poke ptsin    , XPOS1 + 1
64014 poke ptsin + 2, YPOS1 + 38
64016 poke ptsin + 4, XPOS2 + 1
64018 poke ptsin + 6, YPOS2 + 38
64020 vdisys
64022 return
64024 ' --------------------------------------------------

MOVING BOXES :

The  AES has routines,  which can give you the impression that  a 
rectangle  moves from one point to an other or that  a  rectangle 
grows  from one point to its full size.  These routines are  used 
for building windows (for example to show a directory or to  show 
a message).

We  can  use  these routines in ST-BASIC  to  make  our  programs 
better.
There are three different routines in AES:
 - movements of a rectangle that grows (GROW_BOX) 
 - movements of a rectangle that shrinks (SHRINX_BOX) 
 - movements of a rectangle of the same size (MOVE_BOX)
 

GROWBOX :
  
This routine shows a rectangle that starts from one  point,  goes 
to an other point, growing to its full size.
The routine needs as parameters:
 - left-top-coordinates of the start-rectangle
 - the growing
 - the value of the end-rectangle
The   rectangle   starts   its  movements   from   the   position 
(XPOS1;YPOS1)  with  the starting-size  (WIDTH1;HEIGHT1)  to  its  
destination. There he grows to its end-size (WIDTH2;HEIGHT2).
The routine gives only the movement. The arising rectangle has to 
be drawn by an other routine, like 'RECTANGLE'.
The syntax of 'GROWBOX' is:

     XOLD = ....      : YOLD = ....
     XNEW = ....      : YNEW = ....
     WIDTH1 = ....    : HEIGHT1 = ....
     WIDTH2 = ....    : HEIGHT2 = ....
     gosub GROWBOX
 

With  this  routine  and the next you  can  make  very  beautiful 
graphic  effects,  like  growing boxes with information  or  with 
options.  To  prevent that the background-information gets  lost, 
you  have  to use the XOR-option of the routine  'TEXTFORM'  (see 
part I).

SHRINXBOX :

This routine is the opposite of the GROWBOX-routine.  You can use 
this routine for closing windows or options.
If the parameters don't change, the syntax is:

     gosub SHRINXBOX 

Otherwise  you  have to define the eight  parameters  again  (see 
GROWBOX).
The routines for 'GROWBOX' and 'SHRINXBOX' are:
62100 SHRINXBOX:  
62102 ' ----->  XOLD ; YOLD ; WIDTH1 ; HEIGHT1
62104 ' ----->  XNEW ; YNEW ; WIDTH2 ; HEIGHT2
62106 shrinx% = 1
62108 '
62110 GROWBOX:
62112 ' ----->  SEE SHRINXBOX  
62114 '
62116 poke contrl + 2, 8
62118 poke contrl + 4, 1
62120 poke gintin     , xold
62122 poke gintin + 2 , yold
62124 poke gintin + 4 , width1
62126 poke gintin + 6 , height1
62128 poke gintin + 8 , xnew  + 1
62130 poke gintin + 10, ynew  + 38
62132 poke gintin + 12, width2
62134 poke gintin + 14, height2
62136 gemsys 73 + shrinx%
62138 shrinx% = 0
62140 return
62142 ' --------------------------------------------------

An example is:

5   ' merge "INIT.bas"
6   ' merge "GROWBOX.bas"
7   ' merge "RECTANGLE.bas"
9   '
10  gosub INIT
20  fullw 2 : clearw 2
30  xold =   0 : yold = 300 : width1 =  40 : height1 =  40
40  xnew = 400 : ynew = 100 : width2 = 100 : height2 = 200
50  start:
60  xpos1 = xnew: ypos1 = ynew : xpos2 = xnew + width2
70  ypos2 = ynew + height2
80  color 1,1,0,0,0
90  gosub GROWBOX : gosub RECTANGLE
100 for a = 0 to 1000 : next
110 color 1,0
120 gosub RECTANGLE : gosub SHRINXBOX
130 for a = 0 to 1000 : next
140 goto start
MOVEBOX :

The last routine of this group is 'MOVEBOX'. It moves a rectangle 
from one point to another. The box keeps the same size. As in the 
previous routines the routine only takes care of the movement. 
The rectangle has to be drawn by another routine.
The syntax is:

     XOLD = ....   : YOLD = ....
     XNEW = ....   : YNEW = ....
     WIDTHE = .... : HEIGHT = ....
     gosub MOVEBOX
  

The routine is:

62150 MOVEBOX:
62152 ' -----> WIDTHE ; HEIGHT ; XOLD ; YOLD
62154 ' -----> XNEW  ; YNEW  
62156 poke contrl + 2, 6
62158 poke contrl + 4, 1
62160 poke gintin    , widthe
62162 poke gintin + 2, height
62164 poke gintin + 4, xold + 1
62166 poke gintin + 6, yold + 38
62168 poke gintin + 8, xnew + 1
62170 poke gintin + 10,ynew + 38
62172 gemsys 72
62174 return
62176 ' --------------------------------------------------

An example is:

5   ' merge "INIT.bas"
6   ' merge "MOVEBOX.bas"
7   ' merge "RECTANGLE.bas"
9   '
10  gosub INIT
20  fullw 2 : clearw 2
30  xold =  50 : yold =  50 : width = 50 : height = 100
40  xnew = 500 : ynew = 100
50  start :
60  gosub MOVEBOX
70  color 1,1,1,0,0
80  xpos1 = xnew : ypos1 = ynew : xpos2 = xnew + width
90  ypos2 = ynew + height : gosub RECTANGLE
100 swap xold , xnew : swap yold , ynew
110 for a = 0 to 1000 : next
120 color 1,0,0 : gosub RECTANGLE
130 goto start
140 end

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.