home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / ST_NEWS / STN_01_C.MSA / DATA_DOC31 < prev    next >
Text File  |  1994-03-14  |  14KB  |  449 lines

  1. üGEM VDI CALLS PART IIIÇ by Herman de Vrees
  2.  
  3. Originally  published in üST NEWSÇ Volume 1 Issue  6,  launched  on 
  4. November 15th 1986.
  5.  
  6. üCOLOR-DEFINITIONSÇ:
  7.  
  8. Those of us,  who were rich enough to buy a  color-monitor,  know 
  9. that there is no way to set the color-definitions easy.
  10. You  can set the colors by the 'Control'-accessory,  but you  can 
  11. not save your setting.  In the next routine,  you can define  all 
  12. colors.  These colors are made by mixing the three  ground-colors 
  13. 'red', 'green' and 'blue'.
  14. Every ground-color has seven different color-densities.
  15. The syntax is:
  16.  
  17. ä     COLORNUMBER = ...
  18.      RED         = 1 .. 7 
  19.      GREEN       = 1 .. 7 
  20.      BLUE        = 1 .. 7 
  21.      gosub COLORSET 
  22.  
  23. Ç'Colornumber'  determines,  which color gets defined and  is  the 
  24. same as the color in the command 'COLOR',  so it can be called by 
  25. this command.
  26. It is possible to define a color-palette and save it as a  BASIC-
  27. program.
  28. You can make the color with the next program.
  29.  
  30. The subroutine is:
  31.            
  32. 62700 COLORSET:
  33. 62702 ' -----> RED ; GREEN ; BLUE 
  34. 62704 '        COLORNUMBER
  35. 62706 poke contrl, 14
  36. 62708 poke intin, colornumber
  37. 62710 poke intin + 2, red  * 140
  38. 62712 poke intin + 4, green * 140
  39. 62714 poke intin + 6, blue * 140
  40. 62716 vdisys
  41. 62718 return
  42. 62720 ' --------------------------------------------------
  43.  
  44.  
  45. The program is:
  46.  
  47. 5   ' merge "COLORSET.bas"
  48. 6   ' merge "RECTANGLE.bas"
  49. 9   '
  50. 10  fullw 2: clearw 2
  51. 20  start:
  52. 30  for RED   = 1 to 7
  53. 40  for GREEN = 1 to 7
  54. 50  for BLUE  = 1 to 7
  55. 60  x = x + 1 : if x = 8 then x = 1
  56. 70  colornumber = x + 1
  57. 80  gosub COLORSET
  58. 90  color 1, colornumber, 1
  59. 100 xpos1 = 60 : xpos2 = 250
  60. 110 ypos1 = -20 + colornumber * 15
  61. 120 ypos2 = ypos1 + 13 : gosub rectangle
  62. 130 next : next : next
  63. 140 out 2, 7 : goto start
  64. 150 end
  65.  
  66. ü
  67. POLYMARKCOLORS:Ç
  68.  
  69. The  colors  for  VDI- and AES-routines can  be  defined  by  the 
  70. command 'COLOR'.  The 'polymark'-command is an exception on  this 
  71. rule. This command needs an own routine. You can choose from the
  72. defined color-palette by:
  73.  
  74. ä     MARKCOLOR = .. 
  75.      gosub POLYMARKCOLOR Ç
  76.  
  77. The subroutine is:
  78.  
  79. 62750 POLYMARKCOLOR:
  80. 62752 ' -----> MARKCOLOR
  81. 62754 poke contrl, 20
  82. 62756 poke intin, markcolor
  83. 62758 vdisys
  84. 62760 return
  85.  
  86.  
  87.  
  88.  
  89. The program is:
  90.  
  91. 5   ' merge "POLYMARKCOLOR.bas"
  92. 6   ' merge "POLYMARK.bas"
  93. 9   '
  94. 10  clearw 2: fullw 2
  95. 20  for MARKCOLOR = 1 to 15
  96. 30  gosub POLYMARKCOLOR
  97. 40  xpos = 10 + markcolor * 15
  98. 50  ypos = 50
  99. 60  gosub POLYMARK
  100. 70  next: waiting = inp(2): end
  101.  
  102. ë
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111. AES-ROUTINESÇ:
  112.  
  113. üCALLING OF AN AES-ROUTINEÇ:
  114.  
  115. The AES (Application Environment System) takes care of:
  116.   - Calling and controlling desk-accessory
  117.   - Control and management of memory and calculation-time
  118.   - Producing and calling options in the desk-top-menus
  119.   - Windows
  120.   - Mouse-routines
  121.   - Icons (Diskstations and wastebasket)
  122.  
  123. The  AES is a part of the computersystem and is therefore  always 
  124. available. To us, its very large library of routines are the most 
  125. important  part of the AES.  We can call the AES-routines on  the 
  126. same way as the VDI-routines.  Between BASIC and the AES we  need 
  127. an interface, called 'GEMSYS'.
  128.  
  129.  
  130.  
  131.  
  132.  
  133. We also need several special addresses:
  134.  
  135.      äCONTROL     Contains the length of the next fields 
  136.      GLOBAL      Contains several systemdata 
  137.      GINTIN      Input-field for data 
  138.                  (co-ordinates of a window) Ç
  139. ä     GINTOUT     Output of data 
  140.                  (position of the mouse) 
  141.      ADDRIN      Pointer on an address (input) 
  142.      ADDROUT     Pointer on an address (output) 
  143. Ç
  144. We  have  to declare these variables each time we  use  the  AES-
  145. routines. We can do this with the next program.
  146.         
  147. 62900 INIT:
  148. 62902 aes# = gb
  149. 62904 control = peek(aes#)
  150. 62906 global  = peek(aes# + 4)
  151. 62908 gintin  = peek(aes# + 8)
  152. 62910 gintout = peek(aes# + 12)
  153. 62912 addrin  = peek(aes# + 16)
  154.  
  155. 62914 addrout = peek(aes# + 20)
  156. 62916 return
  157. 62918 ' --------------------------------------------------
  158. ü
  159. WINDOWS:Ç
  160.  
  161. Most  of the AES-routines are used for building  and  controlling 
  162. windows.  Some of them are already in ST-BASIC ('OPENW', 'CLOSEW' 
  163. and 'CLEARW').  Some of the AES-routines are very interesting  to 
  164. use in your programs.  These routines are called directly by  way 
  165. of the BASIC-AES-Interface, called 'GEMSYS'.
  166. An example of this is the routine to define for yourself the size 
  167. and  the  position  of the window.  The routine  needs  the  next 
  168. information:  coordinates of the left-top-corner, the wanted size 
  169. and the number of the window.
  170. The syntax is:  (widthe = width, I could not use WIDTH)    
  171.  
  172. ä     XPOS   =  .....  :  YPOS = .....
  173.      WIDTH =  .....  :  HEIGHT = .....
  174.      WINDOWNUMBER = 1 .. 4 
  175.      gosub SETWIND Ç
  176.  
  177. The windownumbers are not the same as in ST-BASIC,  they have the 
  178. next values:
  179.      äEDIT     1 
  180.      LIST     2 
  181.      OUTPUT   3 
  182.      COMMAND  4 Ç
  183.  
  184. The routine is:
  185.  
  186. 62000 SETWIND:
  187. 62002 ' -----> XPOS   ; YPOS ; WIDTHE
  188. 62004 ' -----> HEIGHT ; WINDOWNUMBER
  189. 62006 poke gintin    , windownumber
  190. 62008 poke gintin + 2, 5
  191. 62010 poke gintin + 4, xpos
  192. 62012 poke gintin + 6, ypos
  193. 62014 poke gintin + 8, widthe  
  194. 62016 poke gintin + 10, height
  195. 62018 gemsys 105
  196. 62020 return
  197. 62022 ' --------------------------------------------------
  198.  
  199. The program is:
  200.  
  201. 5   ' merge "INTIN.bas"
  202. 6   ' merge "SETWIND.bas"
  203. 9   '
  204. 10  gosub INIT
  205. 15  for WINDOWNUMBER = 1 to 4
  206. 20  xpos = -50 + 100 * windownumber
  207. 30  ypos =  10 +  20 * windownumber
  208. 40  widthe =  30 +  50 * windownumber
  209. 50  height = 200
  210. 60  gosub SETWIND
  211. 70  next : end
  212.  
  213. üUSING THE FULL SCREENÇ :
  214.  
  215. All output-commands are executed in the output-window.  Therefore 
  216. you  can  see always the border of  the  output-window.  In  many 
  217. programs  it would be nice to make that  border  invisible.  With 
  218. your Atari almost everything is possible,  even this. An easy way 
  219. to do this,  is to define the size of the output-window a  little 
  220. bit  greater then the screen with the previous routine.  Now  the 
  221. borders of the window are forced from of the screen.
  222. The syntax is:
  223.  
  224. ä     gosub INIT 
  225.      gosub FULLWINDOW Ç
  226.  
  227. Particularly for a 'hardcopy' of the screen this routine is  very 
  228. useful: no more borders.
  229. The  subroutine  gives  you the possibility to  define  your  own 
  230. settings:  no borders or just a fine line as border when you want 
  231. a frame on your printer.
  232. The routine is:
  233.   
  234. 62050 FULLWIND:
  235. 62052 '
  236. 62054 poke gintin    , 3        :' OUTPUT-window
  237. 62056 poke gintin + 2, 5        :' with/ without border
  238. 62058 poke gintin + 4, 0        :'  0  : (  -1) ; x1
  239. 62060 poke gintin + 6, 1        :'  1  : (   0) ; y1
  240. 62062 poke gintin + 8, 658      :' 658 : ( 660) ; x2
  241. 62064 poke gintin + 10,417      :' 417 : ( 419) ; y2
  242.  
  243. 62066 gemsys 105
  244. 62068 return
  245. 62070 ' --------------------------------------------------
  246.  
  247. The BASIC-commands 'FULLW,  CLEARW,  OPENW' give no problems with 
  248. the  full screen,  only with 'CLOSEW' it is advisable to put  the 
  249. window back to its original size by the command 'FULLW 2'.
  250. At  the  same time we have to realize that the  relation  between 
  251. GEM-coordinates and BASIC-coordinates changes with a full screen. 
  252. In  all previous routines we adjusted all  GEM-outputcommands  to 
  253. the BASIC-outputcommands: X-direction 1 pixel and  Y-direction 38 
  254. pixels. Using the full screen the deviation in the Y-direction is 
  255. just  19 pixels and the X-coordinates are equal.  You  have  take 
  256. this  in  account when you are using these routines with  a  full 
  257. screen.
  258. ü
  259. WIPE THE DESK-TOPÇ:
  260.  
  261. After using the previous routine the desktop-line  remains.  This 
  262. line is not accessible by normal BASIC-commands.  For those of us 
  263. who  wants no desk-top-line on the printer,  you have to use  the 
  264.  
  265. next routine. This routine draws a white rectangle over the desk-
  266. top-line by using the VDI-routine 'RECTANGLE'.
  267.  
  268. When you used this routine, you lost the desktop-line. You get it 
  269. back  by  'restart' of the BASIC or by the  routine  'TEXTOUTPUT' 
  270. (described  in  part  I).  This routine has access  to  the  full 
  271. screen,  like all GEM-routines.  Therefore you can generate  your 
  272. own desktop-line.
  273.  
  274. The routines are:
  275.  
  276. 62080 CLEARDESK:
  277. 62082 ' merge "RECTANGLE.bas"
  278. 62084 color 1,0,1 :
  279. 62086 xpos1 = -1 : xpos2 = 638 : ypos1 = -40 : ypos2 = -20
  280. 62088 gosub rectangle: color 1,1,1
  281. 62090 return
  282. 62092 ' --------------------------------------------------
  283.  
  284.  
  285.  
  286.  
  287. 64000 RECTANGLE:
  288. 64002 ' -----> XPOS1 : YPOS1 : XPOS2 : YPOS2
  289. 64004 poke contrl    , 11
  290. 64006 poke contrl + 2, 2
  291. 64008 poke contrl + 6, 0
  292. 64010 poke contrl + 10, 1
  293. 64012 poke ptsin    , XPOS1 + 1
  294. 64014 poke ptsin + 2, YPOS1 + 38
  295. 64016 poke ptsin + 4, XPOS2 + 1
  296. 64018 poke ptsin + 6, YPOS2 + 38
  297. 64020 vdisys
  298. 64022 return
  299. 64024 ' --------------------------------------------------
  300. ü
  301. MOVING BOXESÇ :
  302.  
  303. The  AES has routines,  which can give you the impression that  a 
  304. rectangle  moves from one point to an other or that  a  rectangle 
  305. grows  from one point to its full size.  These routines are  used 
  306. for building windows (for example to show a directory or to  show 
  307. a message).
  308.  
  309. We  can  use  these routines in ST-BASIC  to  make  our  programs 
  310. better.
  311. There are three different routines in AES:
  312. ä - movements of a rectangle that grows (GROW_BOX) 
  313.  - movements of a rectangle that shrinks (SHRINX_BOX) 
  314.  - movements of a rectangle of the same size (MOVE_BOX) Ç
  315.  
  316. üGROWBOX Ç:
  317. ä  Ç
  318. This routine shows a rectangle that starts from one  point,  goes 
  319. to an other point, growing to its full size.
  320. The routine needs as parameters:
  321.  - left-top-coordinates of the start-rectangle
  322.  - the growing
  323.  - the value of the end-rectangle
  324. The   rectangle   starts   its  movements   from   the   position 
  325. (XPOS1;YPOS1)  with  the starting-size  (WIDTH1;HEIGHT1)  to  its  
  326. destination. There he grows to its end-size (WIDTH2;HEIGHT2).
  327. The routine gives only the movement. The arising rectangle has to 
  328. be drawn by an other routine, like 'RECTANGLE'.
  329. The syntax of 'GROWBOX' is:
  330.  
  331.      äXOLD = ....      : YOLD = ....
  332.      XNEW = ....      : YNEW = ....
  333.      WIDTH1 = ....    : HEIGHT1 = ....
  334.      WIDTH2 = ....    : HEIGHT2 = ....
  335.      gosub GROWBOX Ç
  336.  
  337. With  this  routine  and the next you  can  make  very  beautiful 
  338. graphic  effects,  like  growing boxes with information  or  with 
  339. options.  To  prevent that the background-information gets  lost, 
  340. you  have  to use the XOR-option of the routine  'TEXTFORM'  (see 
  341. part I).
  342.  
  343. üSHRINXBOXÇ :
  344.  
  345. This routine is the opposite of the GROWBOX-routine.  You can use 
  346. this routine for closing windows or options.
  347. If the parameters don't change, the syntax is:
  348.  
  349.      ägosub SHRINXBOX Ç
  350.  
  351. Otherwise  you  have to define the eight  parameters  again  (see 
  352. GROWBOX).
  353. The routines for 'GROWBOX' and 'SHRINXBOX' are:
  354. 62100 SHRINXBOX:  
  355. 62102 ' ----->  XOLD ; YOLD ; WIDTH1 ; HEIGHT1
  356. 62104 ' ----->  XNEW ; YNEW ; WIDTH2 ; HEIGHT2
  357. 62106 shrinx% = 1
  358. 62108 '
  359. 62110 GROWBOX:
  360. 62112 ' ----->  SEE SHRINXBOX  
  361. 62114 '
  362. 62116 poke contrl + 2, 8
  363. 62118 poke contrl + 4, 1
  364. 62120 poke gintin     , xold
  365. 62122 poke gintin + 2 , yold
  366. 62124 poke gintin + 4 , width1
  367. 62126 poke gintin + 6 , height1
  368. 62128 poke gintin + 8 , xnew  + 1
  369. 62130 poke gintin + 10, ynew  + 38
  370. 62132 poke gintin + 12, width2
  371. 62134 poke gintin + 14, height2
  372. 62136 gemsys 73 + shrinx%
  373. 62138 shrinx% = 0
  374. 62140 return
  375. 62142 ' --------------------------------------------------
  376.  
  377. An example is:
  378.  
  379. 5   ' merge "INIT.bas"
  380. 6   ' merge "GROWBOX.bas"
  381. 7   ' merge "RECTANGLE.bas"
  382. 9   '
  383. 10  gosub INIT
  384. 20  fullw 2 : clearw 2
  385. 30  xold =   0 : yold = 300 : width1 =  40 : height1 =  40
  386. 40  xnew = 400 : ynew = 100 : width2 = 100 : height2 = 200
  387. 50  start:
  388. 60  xpos1 = xnew: ypos1 = ynew : xpos2 = xnew + width2
  389. 70  ypos2 = ynew + height2
  390. 80  color 1,1,0,0,0
  391. 90  gosub GROWBOX : gosub RECTANGLE
  392. 100 for a = 0 to 1000 : next
  393. 110 color 1,0
  394. 120 gosub RECTANGLE : gosub SHRINXBOX
  395. 130 for a = 0 to 1000 : next
  396. 140 goto start
  397. üMOVEBOX Ç:
  398.  
  399. The last routine of this group is 'MOVEBOX'. It moves a rectangle 
  400. from one point to another. The box keeps the same size. As in the 
  401. previous routines the routine only takes care of the movement. 
  402. The rectangle has to be drawn by another routine.
  403. The syntax is:
  404.  
  405. ä     XOLD = ....   : YOLD = ....
  406.      XNEW = ....   : YNEW = ....
  407.      WIDTHE = .... : HEIGHT = ....
  408.      gosub MOVEBOX Ç 
  409.  
  410. The routine is:
  411.  
  412. 62150 MOVEBOX:
  413. 62152 ' -----> WIDTHE ; HEIGHT ; XOLD ; YOLD
  414. 62154 ' -----> XNEW  ; YNEW  
  415. 62156 poke contrl + 2, 6
  416. 62158 poke contrl + 4, 1
  417. 62160 poke gintin    , widthe
  418. 62162 poke gintin + 2, height
  419. 62164 poke gintin + 4, xold + 1
  420. 62166 poke gintin + 6, yold + 38
  421. 62168 poke gintin + 8, xnew + 1
  422. 62170 poke gintin + 10,ynew + 38
  423. 62172 gemsys 72
  424. 62174 return
  425. 62176 ' --------------------------------------------------
  426.  
  427. An example is:
  428.  
  429. 5   ' merge "INIT.bas"
  430. 6   ' merge "MOVEBOX.bas"
  431. 7   ' merge "RECTANGLE.bas"
  432. 9   '
  433. 10  gosub INIT
  434. 20  fullw 2 : clearw 2
  435. 30  xold =  50 : yold =  50 : width = 50 : height = 100
  436. 40  xnew = 500 : ynew = 100
  437. 50  start :
  438. 60  gosub MOVEBOX
  439. 70  color 1,1,1,0,0
  440. 80  xpos1 = xnew : ypos1 = ynew : xpos2 = xnew + width
  441. 90  ypos2 = ynew + height : gosub RECTANGLE
  442. 100 swap xold , xnew : swap yold , ynew
  443. 110 for a = 0 to 1000 : next
  444. 120 color 1,0,0 : gosub RECTANGLE
  445. 130 goto start
  446. 140 end
  447.  
  448.  
  449.