Skip to main content

GEM VDI CALLS PART IV (FINAL PART) by Herman de Vrees

CLIPPING:

When  you use GEM-routines,  it is possible that  something  goes 
wrong by not initialized AES-commands or wrong parameters for the 
output on screen.  The next routine deals with wrong  parameters, 
when these parameters are larger then the screen-coordinates. The 
routine limits these parameters and all illegal  screen-coordina-
tes are ignored.  All GEM-routines,  following this routine,  are 
executed  within the defined limits.  The  BASIC-commands  ignore 
this  routine,  so they have no limits.  The size of the  limited 
screen are determined by XPOS1, YPOS1, XPOS2 and YPOS2.

The syntax is:

     XPOS1 = .... : YPOS1 = ....
     XPOS2 = .... : YPOS2 = ....
     gosub CLIPPING
 

The routine is:

65200 CLIPPING:
65202 ' -----> XPOS1, YPOS1, XPOS2, YPOS2
65204 poke contrl   , 129
65210 poke intin    , 1       : 'Clipping on (0 = out)
65212 poke ptsin    , xpos1   : '0
65214 poke ptsin + 2, ypos1   : '0
65216 poke ptsin + 4, xpos2   : '600
65218 poke ptsin + 6, ypos2   : '400
65220 vdisys
65222 return
65224 ' -----------------------------------------------

FILLPATTERN:

It is possible to define your own fill-pattern in a frame of 16 * 
16  bits,  which you can use with  the  BASIC-commands:  PCIRCLE, 
PELLIPSE and FILL and with the GEM-routines:  RECTANGLE,  RECTAN
GLEROUND and POLYGON.
The values of the fill-pattern are 16 words (2 Byte),  which  are 
defined in DATA-lines and called by a name.
The definition of a new fill-pattern starts with:

      restore ( name ) 
      gosub FILLPATTERN
 

The routine of fillpattern is:

63500 FILLPATTERN:
63502 ' -----> restore MONSTER
63504 poke contrl    , 112
63506 poke contrl + 6, 16
63508 for st = 0 to 30 step 2
63510 read MONSTER
63512 poke intin + st, monster
63514 next: vdisys
63516 return
63518 ' -----------------------------------------------

An example of a new fill-pattern:

5   ' merge "FILLPATTERN/RECTANGLE/RECTANGLEROUND.bas"
10  fullw 2 : clearw 2
20  WURM:
30  data      0,  8064, 16320, 26208, 30560, 32736
40  data  29132, 16318,  8054,  7782,  7372,  7384
50  data   4080,  2022,    60,    24
60  restore wurm : gosub FILLPATTERN
70  color 1, 1, 1, 1, 4
80  pellipse 130, 100, 100, 60
90  '
100 xpos1 = 270 : ypos1 =  30 : xpos2 = 350 : ypos2 = 300
110 gosub RECTANGLE
120 '
130 xpos1 = 400 : ypos1 = 200 : xpos2 = 500 : ypos2 = 300
140 FILLING = 1 : gosub RECTANGLEROUND
150 '
160 waiting = inp(2)
170 end

LETTERSIZE:

In Part I, we had a routine, called 'TEXTSIZE', to make the text-
size  larger  or smaller then usual.  This routine works  with  5 
different sizes.  The next routine,  for monochrome  only,  works 
with 24 different sizes (3 till 26). All kinds of text-forms work 
with this routine (underlined,  italics and so on).  This routine 
can not work with the normal BASIC-command PRINT,  but only  with 
the routine TEXTOUTPUT.  The default with monochrome is:  12  and 
the default with color (low resolution) is: 6. The smallest sizes 
are not available with medium or low resolution. The syntax is:

     LETTERSIZE = ( 3...26 ) : 
     gosub LETTERSIZING
 

                       The routine is:
65300 LETTERSIZING:
65302 ' -----> LETTERSIZE
65304 poke contrl    , 12
65306 poke ptsin + 2 , lettersize
65308 vdisys
65310 return
An example of LETTERSIZING is:

5   ' merge "LETTERSIZING/TEXTOUTPUT/CLIPPING.bas"
10  fullw 2 : clearw 2
20  xpos1 = 0 : ypos1 = 0 : xpos2 = 600 : ypos2 = 360
30  gosub CLIPPING
40  for LETTERSIZE = 1 to 12
50  gosub LETTERSIZING
60  xpos = 30 : ypos = 25 * LETTERSIZE
70  text$ = "Atari, the best !"
80  gosub TEXTOUTPUT : next
90  xpos = 300 : ypos = 0
100 for LETTERSIZE = 13 to 26
110 gosub LETTERSIZING
120 ypos = ypos + LETTERSIZE + 4 : gosub TEXTOUTPUT : next
130 LETTERSIZE = 13 : gosub LETTERSIZING
140 waiting = inp(2)
150 end

FRAMING:

When  you  use a graphic command that uses a  fill-pattern  (like 
pcircle),  the  circle will be drawn with a thin line  round  the 
fill-pattern.  This line can be switched off.  The routine  works 
with the next BASIC-commands and GEM-routines:
  - pcircle         - pellipse      - rectangle
  - rectangleround  - polygon
The syntax is:

     FRAME = ( 0 , 1 ) :
     gosub FRAMING
  

The routine is:

65250 FRAMING:
65252 ' -----> FRAME (0,1): '1 = on   0 = no line
65254 poke contrl    , 104
65256 poke intin     , frame
65258 vdisys
65260 return
65262 ' -----------------------------------------------
An example of FRAMING is:

5   ' merge "FRAMING.bas"
10  fullw 2 : clearw 2
20  color 1, 1, 1, 3, 3
30  FRAME = 1 : gosub FRAMING
40  pcircle 150, 150, 100, 0, 2800
50  FRAME = 0 : gosub FRAMING
60  pcircle 400, 150, 100, 0, 2800
70  waiting = inp(2)
80  end

MOUSE2:

The  AES  has a similar routine as the VDI-routine  'MOUSE'  (see 
Part II) to get the mouse-position, but before we can use an AES-
routine  we have to use the 'INIT'-routine (see  part  III).  The 
next mouse-routine gives us information about the position of the 
mouse,  the  mousekeys and the keys CONTROL,  ALTERNATE and  both 
SHIFT-keys.
The syntax is:

     gosub MOUSE2 

The  information is given in the variables MOUSEX and MOUSEY  for 
the  position and in the variable KEYA for the mouse-keys and  in 
the variable KEYB for the other keys. The values can be:

  KEYA (mouse-keys): 
        Key                    Value
       -------------------------------
        Left                    1
        Right                   2
        Left and Right          3
  KEYB (others) : 
        Key                    Value
       -------------------------------
        Shift right             1
        Shift left              2
        Control                 4
        Alternate               8

The routine is:

62550 MOUSE2:
62552 ' <----- MOUSEX ; MOUSEY
62554 ' <----- KEYA  ; KEYB
62556 mousex = peek(gintout + 2)-1
62558 mousey = peek(gintout + 4)-38
62560 keya  = peek(gintout + 6)
62562 keyb  = peek(gintout + 8)
62564 gemsys 79
62566 return
62568 ' ------------------------------------------------

An example of MOUSE2 is:

5   ' merge "INIT/MOUSE2.bas"
10  gosub INIT
20  start:
30  gosub MOUSE2
40  print MOUSEX, MOUSEY, KEYA, KEYB
50  goto start

EVENTMOUSE:

The  next  routine  verifies if the mouse is present  in  a  pre-
defined  rectangle.  The  coordinates of the  left-top-corner  of 
rectangle are put in XPOS and YPOS and the size of the  rectangle 
in  WIDTHE  and HEIGHT.  The routine responds when the  mouse  is 
coming  in the rectangle or when the mouse leaves the  rectangle. 
This  is done by putting 0 in GINTIN (the routine waits till  the 
mouse  enters the rectangle) or by putting 1 in  GINTIN  (waiting 
till the mouse leaves the rectangle).
The syntax is:

     XPOS1 = .... : YPOS1 = ....
     WIDTHE = ... : HEIGHT = ...
     gosub EVENTMOUSE
 

The routine of EVENTMOUSE is:

62500 EVENTMOUSE:
62502 ' -----> XPOS1 ; YPOS1
62504 ' -----> WIDTHE ; HEIGHT
62506 poke gintin    , 0
62508 poke gintin + 2, xpos1 + 1
62510 poke gintin + 4, ypos1 + 38
62512 poke gintin + 6, widthe
62514 poke gintin + 8, height
62516 gemsys 22
62518 return
62520 ' ------------------------------------------------

For completing the routine 'SHOWMOUSE' the next routine:

63042 HIDEMOUSE:
63044 poke contrl    , 123
63046 vdisys
63048 return
63049 ' ------------------------------------------------

An example of EVENTMOUSE is:

5   ' merge "INIT/EVENTMOUSE/SHOWMOUSE/RECTANGLE.bas"
10  gosub INIT
20  fullw 2 : clearw 2 : color 1, 1, 1, 3, 3
30  xpos1 = 100 : ypos1 = 100 : xpos2 = 150 : ypos2 = 120
40  widthe = 50 : height = 20
50  start:
60  gosub RECTANGLE
70  gosub SHOWMOUSE
80  gosub EVENTMOUSE
90  gosub MOUSE2
100 if keya = 1 then 120
110 out 2,7 : goto start
120 end

RUBBERBOX:

This routine gives a rectangle,  defined by the mouse.  The left-
top-corner  of the rectangle is determined by pressing  the  left 
mousekey.  When  you  move  the mouse  (keep  the  left-mouse-key 
pressed),  you  see  a rectangle following  your  mouse-movements 
until you stop pressing the mousekey.  Then the routine gives you 
the size of the rectangle.  Before we can use this  routine,  the 
routine  MOUSE2 checks if you have pressed the left-mouse-key  to 
determine the left-top-corner.  The routine RUBBERBOX takes  over 
the  values  of  this  starting-point  from  MOUSE2  (MOUSEX  and 
MOUSEY).
The syntax is:

     gosub RUBBERBOX 

The routine of RUBBERBOX is:

62200 RUBBERBOX:
62202 ' -----> MOUSEX ; MOUSEY
62204 ' <----- WIDTHE ; HEIGHT
62206 poke gintin    , mousex + 1
62208 poke gintin + 2, mousey + 38
62210 poke gintin + 4, 1
62212 poke gintin + 6, 1
62214 AES.3: gemsys 70
62216 widthe = peek(gintout + 2)
62218 height = peek(gintout + 4)
62220 if height<3 or widthe<3 then goto AES.3
62222 return
62224 ' -------------------------------------------------

10  gosub INIT
20  openw 2 : clearw 2
30  start : gosub MOUSE2
40  if keya = 1 then gosub RUBBERBOX else goto start
50  print "The box is : " widthe " wide and " height " high."
60  end
DRAGBOX:

This  routine  is  used to move a  rectangle.  The  size  of  the 
rectangle  is  determinated by the variables WIDTHE  and  HEIGHT. 
With  the routine MOUSE2 we have to determine the starting  point 
(left-top-corner) of the rectangle.  It is possible to limit  the 
area in which the rectangle can move through the variables X.MIN, 
Y.MIN,  X.MAX  and  Y.MAX.  The routine gives back to  the  main-
program the new position of the rectangle in the variables  XPOS1 
and  YPOS1.  To  prevent wiping the rectangle we  use  first  the 
routine HIDEMOUSE and then the routine SHOWMOUSE.
The syntax is:

     X.MIN   = .... : Y.MIN   = ....
     X.MAX   = .... : Y.MAX   = ....
     WIDTHE  = .... : HEIGHT  = ....
     gosub DRAGBOX
 

The routine of DRAGBOX is:

62250 DRAGBOX:
62252 ' -----> WIDTHE ; HEIGHT
62254 '        X.MIN   ; Y.MIN
62256 '        X.MAX   ; Y.MAX
62258 ' <----- XPOS1   ; YPOS1
62260 poke contrl + 2, 8
62262 poke contrl + 4, 3
62264 poke gintin    , widthe
62266 poke gintin + 2, height
62268 poke gintin + 4, mousex + 1
62270 poke gintin + 6, mousey + 38
62272 poke gintin + 8, x.min + 1
62274 poke gintin +10, y.min + 38
62276 poke gintin +12, x.max + 1
62278 poke gintin +14, y.max + 38
62280 gemsys 71
62282 xpos1 = peek(gintout + 2)-1
62284 ypos1 = peek(gintout + 4)-38
62286 return
62288 '-------------------------------------------------
An example of DRAGBOX is:

5   ' merge "INIT/MOUSE2/DRAGBOX/SHOWMOUSE/HIDEMOUSE/RECTANGLE"
10  gosub INIT
20  fullw 2 : clearw 2 : color 1, 1, 1, 2, 3
30  widthe = 300 : height = 150 : x.min = 100 : y.min = 100
40  x.max = 500 : y.max = 250
50  gosub MOUSE2
60  start : gosub MOUSE2
70  if keya = 1 then gosub DRAGBOX else goto start
80  xpos2 = xpos1 + widthe : ypos2 = ypos1 + height
90  gosub HIDEMOUSE : gosub RECTANGLE
100 gosub SHOWMOUSE
110 gotoxy 0,0
120 print "The coordinates are : " xpos1, ypos1
130 end

On the disk,  a program is contained called "SUBE1_4.BAS",  which 
contains not only the subroutines from this issue,  but also from 
the previous issues of ST NEWS, since this is the concluding part 
of the 'course'.

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.