home *** CD-ROM | disk | FTP | other *** search
/ Computer Club Elmshorn Atari PD / CCE_PD.iso / pc / 0600 / CCE_0636.ZIP / CCE_0636 / GEMLIB / GMLIBS30.ZOO / vdiesc1.c < prev    next >
C/C++ Source or Header  |  1993-05-21  |  20KB  |  843 lines

  1. /* vdiesc1.c - vdi - escapes missing from GEMLIB            */
  2. /* Reference:     Atari ST Profibuch                     */
  3. /*        Hans-Dieter Jankowski, Julian F. Reschke, Dietmar Rabich */
  4. /*        SYBEX-Verlag GmbH, Düsseldorf, Germany             */
  5. /*        7.th edition 1989                     */
  6. /*        ISBN : 3-88745-563-0                     */
  7. /*        Pages 413 ff.                         */
  8.  
  9. /* Thomas Koenig (UI0T@DKAUNI2.BITNET, UI0T@IBM3090.RZ.UNI-KARLSRUHE.DE) */
  10. /* This file is put into the public domain                 */
  11. /* Notice that, on the ST, some of these calls require GDOS.        */
  12.  
  13. #include <stddef.h>
  14. #include "common.h"
  15. #include <vdibind.h>
  16.  
  17. #ifdef __DEF_ALL__
  18.  
  19. #define L_vq_tabst
  20. #define L_v_hardco
  21. #define L_v_dspcur
  22. #define L_v_rmcur
  23. #define L_v_form_a
  24. #define L_v_output
  25. #define L_v_clear_
  26. #define L_v_bit_im
  27. #define L_vq_scan
  28. #define L_v_alpha_
  29. #define L_vs_palet
  30. #define L_v_sound
  31. #define L_vs_mute
  32. #define L_vt_resol
  33. #define L_vt_axis
  34. #define L_vt_origi
  35. #define L_vq_dimen
  36. #define L_vt_align
  37. #define L_vsp_film
  38. #define L_vqp_film
  39. #define L_vsc_expo
  40. #define L_v_meta_e
  41. #define L_v_write_
  42. #define L_vm_pages
  43. #define L_vm_coord
  44. #define L_vm_filen
  45. #define L_v_escape
  46.  
  47. #endif /* __DEF_ALL__ */
  48.  
  49.  
  50. #ifdef L_vq_tabst
  51.  
  52. /*        vq_tabstatus                         */
  53. /*         screen escape                         */
  54. /* INQUIRE TABLET STATUS                        */
  55. /* Inquiere wether a grapics tablet, a mouse, a Joystick or of something */
  56. /* like that.                                */
  57.  
  58. int vq_tabstatus(int handle)
  59. {
  60.     __vdi__(VDI_CONTRL_ENCODE(5, 0, 0, 16), handle);
  61.     return _intout[0];
  62. }
  63. #endif /* L_vq_tabst */
  64.  
  65.  
  66. /*        v_hardcopy                        */
  67. /*        screen escape                        */
  68. /* HARD COPY                                */
  69. /* Make a hard copy of the screen.                    */
  70.  
  71. #ifdef L_v_hardco
  72.  
  73. void v_hardcopy(int handle)
  74. {
  75.     __vdi__(VDI_CONTRL_ENCODE(5, 0, 0, 17), handle);
  76. }
  77. #endif /* L_v_hardco */
  78.  
  79.  
  80. /*        v_dspcur                        */
  81. /*        screen escape                        */
  82. /* PLACE GRAPHICS CURSOR AT LOCATION                    */
  83. /* Place the grapics cursor at the specified location.            */
  84.  
  85. #ifdef L_v_dspcur
  86.  
  87. void v_dspcur (int handle, int x, int y)
  88. /* Parameters:                                */
  89. /*    x: x - coordinate of new graphics cursor position        */
  90. /*    y: y - coordinate of new graphics cursor position        */
  91.  
  92. {
  93.     _ptsin[0] = x;
  94.     _ptsin[1] = y;
  95.     __vdi__(VDI_CONTRL_ENCODE(5, 1, 0, 18), handle);
  96. }
  97. #endif /* L_v_dspcur */
  98.  
  99. /*        v_rmcur                            */
  100. /*        screen escape                        */
  101. /* REMOVE LAST GRAPHICS CURSOR                        */
  102. /* Removes the last grapics cursor.                    */
  103.  
  104. #ifdef L_v_rmcur
  105.  
  106. void v_rmcur(int handle)
  107. {
  108.     __vdi__(VDI_CONTRL_ENCODE(5, 0, 0, 19), handle);
  109. }
  110. #endif /* L_v_rmcur */
  111.  
  112. /*        v_form_adv                        */
  113. /*        printer escape                        */
  114. /* FORM ADVANCE                                */
  115. /* form feed to printer, do not erase printer buffer            */
  116.  
  117. #ifdef L_v_form_a
  118.  
  119. void v_form_adv(int handle)
  120. {
  121.     __vdi__(VDI_CONTRL_ENCODE(5, 0, 0, 20), handle);
  122. }
  123. #endif /* L_v_form_a */
  124.  
  125.  
  126. /*        v_output_window                        */
  127. /*        printer escape                        */
  128. /* OUTPUT WINDOW                            */
  129. /* output part of the screen to printer, delimited by 2 points        */
  130.  
  131. #ifdef L_v_output
  132.  
  133. void v_output_window(int handle, int *pxyarray)
  134. /* Parameters:                                */
  135. /*    pxyarray[0] : x - coordinate of a corner of the ouptut window    */
  136. /*    pxyarray[1] : y - coordinate of ...                */
  137. /*    pxyarray[2] : x - coordinate of other corner of the window    */
  138. /*    pxyarray[3] : y - coordinate of ...                */
  139. {
  140. #ifdef __MSHORT__    /* we have 16 bit ints, just change vdi params */
  141.     _vdiparams[2] = (void *) &pxyarray[0];
  142. #else            /* 32 bit ints - let's copy */
  143.  
  144.     _ptsin[0] = pxyarray[0];
  145.     _ptsin[1] = pxyarray[1];
  146.     _ptsin[2] = pxyarray[2];
  147.     _ptsin[3] = pxyarray[3];
  148.     
  149. #endif
  150.  
  151.     __vdi__(VDI_CONTRL_ENCODE(5, 2, 0, 21), handle);
  152.  
  153. #ifdef __MSHORT__
  154.     _vdiparams[2] = (void *)&_ptsin[0]; /* restore vdi parameters */
  155. #endif
  156. }
  157. #endif /* L_v_output */
  158.  
  159. /*        v_clear_disp_list                    */
  160. /*        printer escape                        */
  161. /* CLEAR DISPLAY LIST                            */
  162. /* clear printer buffer, no form feed                    */
  163.  
  164. #ifdef L_v_clear_
  165.  
  166. void v_clear_disp_list(int handle)
  167. {
  168.     __vdi__(VDI_CONTRL_ENCODE(5, 0, 0, 22), handle);
  169. }
  170. #endif /* L_v_clear_ */
  171.  
  172.  
  173. /*        v_bit_image                        */
  174. /*        printer escape                        */
  175. /* OUTPUT BIT IMAGE FILE                        */
  176. /* output a bit image file (*.IMG) to a printer                */
  177.  
  178. #ifdef L_v_bit_im
  179.  
  180. void v_bit_image(int handle, const char *filename, int aspect, int x_scale,
  181.             int y_scale, int h_align, int v_align,
  182.             int *pxyarray)
  183. /* Parameter:                                */
  184. /*    aspect: =0 aspect ratio is ignored                */
  185. /*        =1 use aspect ratio (circles -> circles)        */
  186. /*    x_scale: scaling of the x - axis,     =0 : fractional        */
  187. /*                          =1 : whole number    */
  188. /*    y_scale: scaling of the y - axis, see x_axis            */
  189. /*    h_align: horizontal alignment, 0 = left, 1 = center, 2= right   */
  190. /*    v_align: vertical alignment, 0 = upper edge, 1 = center,    */
  191. /*                2 = lower edge                */
  192. /*    pxyarray[0], [1] : possible coordinates of upper left corner of */
  193. /*        the output area                        */
  194. /*    pxyarray[2], [3] : possible coordinates of lower right corner of */
  195. /*        the output area                         */
  196.  
  197. {
  198.     register short *ptmp;
  199.     short n;
  200.  
  201. #ifdef __MSHORT__    /* we have 16 bit ints, just change vdi params */
  202.     _vdiparams[2] = (void *) &pxyarray[0];
  203. #else            /* 32 bit ints - let's copy */
  204.  
  205.     _ptsin[0] = pxyarray[0];
  206.     _ptsin[1] = pxyarray[1];
  207.     _ptsin[2] = pxyarray[2];
  208.     _ptsin[3] = pxyarray[3];
  209.  
  210. #endif
  211.  
  212.     _intin[0] = aspect;
  213.     _intin[1] = x_scale;
  214.     _intin[2] = y_scale;
  215.     _intin[3] = h_align;
  216.     _intin[4] = v_align;
  217.  
  218. /* copy the file name */
  219.     ptmp = _intin + 5;
  220.     while( *ptmp ++ = (unsigned char) *filename++)
  221.         ;
  222.  
  223.     n = (ptmp - _intin) -1;
  224.  
  225.     __vdi__(VDI_CONTRL_ENCODE(5, 2, n, 23), handle);
  226.  
  227. #ifdef __MSHORT__
  228.     _vdiparams[2] = (void *)&_ptsin[0]; /* restore vdi parameters */
  229. #endif
  230. }
  231. #endif /* L_v_bit_im */
  232.  
  233.  
  234. /*        vq_scan                            */
  235. /*        printer escape                        */
  236. /* INQUIRE PRINTER SCAN                            */
  237. /* inquires different printer parameters                */
  238.  
  239. #ifdef L_vq_scan
  240.  
  241. void vq_scan(int handle, int *g_slice, int *g_page, int *a_slice,
  242.         int *a_page, int *div_fac)
  243. /* Parameters:                                */
  244. /*    *g_slice: The printer driver subdivides the page into several    */
  245. /*        'slices', which are formatted and output one after the    */
  246. /*        other to save memory; this is their number.        */
  247. /*    *g_page: number of pixels on a slice                */
  248. /*    *a_slice: height of a text line in pixels            */
  249. /*    *a_page: number of text lines per page                */
  250. /*    *div_fac: the other values have to be divided by this factor    */
  251.  
  252. {
  253.     __vdi__(VDI_CONTRL_ENCODE(5, 0, 0, 24), handle);
  254.  
  255.     *g_slice = _intout[0];
  256.     *g_page  = _intout[1];
  257.     *a_slice = _intout[2];
  258.     *a_page  = _intout[3];
  259.     *div_fac = _intout[4];
  260. }
  261. #endif /* L_vq_scan */
  262.  
  263. /*        v_alpha_text                        */
  264. /*        printer escape                        */
  265. /* OUTPUT ALPHA TEXT                            */
  266. /* output text to printer (not in graphics mode), with certain control    */
  267. /* codes.                                */
  268.  
  269. #ifdef L_v_alpha_
  270.  
  271. void v_alpha_text(int handle, const char *string)
  272. /* Parameters:                                 */
  273. /*    *string: pointer to string, which may contain the        */
  274. /*        following control sequences:                */
  275. /*            DC2 0:    bold type on                */
  276. /*            DC2 1:  bold type off                */
  277. /*            DC2 2:  slanted type on                */
  278. /*            DC2 3:  slanted type off            */
  279. /*            DC2 4:  underscore on                */
  280. /*            DC2 5:  underscore off                */
  281. /*         (DC2 is ASCII Nr. 18 = \022)                */
  282.  
  283. {
  284.     short n;
  285.     short *ptmp = _intin;
  286.  
  287.     while (*ptmp++ = (unsigned char) *string++)
  288.         ;
  289.  
  290.     n = (ptmp - _intin) -1;
  291.  
  292.     __vdi__(VDI_CONTRL_ENCODE(5, 0, n, 25), handle);
  293.  
  294. }
  295. #endif /* L_v_alpha_ */
  296.  
  297. /* WARNING: All bindings below this point require hand coding,
  298.    because the subcode is > 31 */
  299.  
  300. /*        vs_palette                        */
  301. /*        IBM CGA escape                        */
  302. /* SELECT PALETTE                            */
  303. /* selects a colour palette for IBM CGA grapics card in medium resolution */
  304.  
  305. #ifdef L_vs_palet
  306.  
  307. int vs_palette( int handle, int palette)
  308. {
  309.     short *wptr;
  310.     _intin[0] = palette;
  311.  
  312.      wptr = (short *)_contrl;
  313.     *wptr++ = 5;        /* 0  - opcode */
  314.     *wptr++ = 0;        /* 1 */
  315.      wptr++;        /* 2 */
  316.     *wptr++ = 1;        /* 3  - # of entries in _intin */
  317.      wptr++;        /* 4 */
  318.     *wptr++ = 60;        /* 5 - id */
  319.     *wptr   = handle;    /* 6 - handle */
  320.     vdi();
  321.  
  322.     return _intout[0];
  323. }
  324. #endif /* L_vs_palet */
  325.  
  326.  
  327. /*        v_sound                            */
  328. /*        screen escape                        */
  329. /* GENERATE SPECIFIED TONE                        */
  330. /* generates a tone of specified length and frequency.            */
  331.  
  332. #ifdef L_v_sound
  333.  
  334. void v_sound(int handle, int frequency, int duration)
  335. /* Parameters:                                */
  336. /*    frequency: Frequency of the tone in Hertz            */
  337. /*    duration: length of tone in timer ticks                */
  338. {
  339.     short *wptr;
  340.     _intin[0] = frequency;
  341.     _intin[1] = duration;
  342.  
  343.      wptr = (short *)_contrl;
  344.     *wptr++ = 5;        /* 0  - opcode */
  345.     *wptr++ = 0;        /* 1 */
  346.      wptr++;        /* 2 */
  347.     *wptr++ = 2;        /* 3  - # of entries in _intin */
  348.      wptr++;        /* 4 */
  349.     *wptr++ = 61;        /* 5 - id */
  350.     *wptr   = handle;    /* 6 - handle */
  351.     vdi();
  352. }
  353. #endif /* L_v_sound */
  354.  
  355.  
  356. /*        vs_mute                            */
  357. /*        screen escape                        */
  358. /* SET/CLEAR TONE MUTING FLAG                        */
  359. /* sets or clears the tone muting flag or reports its status        */
  360.  
  361. #ifdef L_vs_mute
  362.  
  363. int vs_mute(int handle, int action)
  364. /* Parameter: action : -1    inquire status                */
  365. /*            0    switch on sound                */
  366. /*            1    switch off sound            */
  367. /* return value: 0 : sound on                        */
  368. /*         1 : sound off                        */
  369. {
  370.     short *wptr;
  371.     _intin[0] = action;
  372.  
  373.      wptr = (short *)_contrl;
  374.     *wptr++ = 5;        /* 0  - opcode */
  375.     *wptr++ = 0;        /* 1 */
  376.      wptr++;        /* 2 */
  377.     *wptr++ = 1;        /* 3  - # of entries in _intin */
  378.      wptr++;        /* 4 */
  379.     *wptr++ = 62;        /* 5 - id */
  380.     *wptr   = handle;    /* 6 - handle */
  381.     vdi();
  382.     return _intout[0];
  383. }
  384. #endif /* L_vs_mute */
  385.  
  386.  
  387. /*        vt_resolution                        */
  388. /*        graphic tablet escape                    */
  389. /* SET TABLET AXIS RESOLUTION IN LINES/INCH                */
  390. /* set horizontal and vertical resolution of a grapichs tablet        */
  391.  
  392. #ifdef L_vt_resol
  393.  
  394. void vt_resolution( int handle, int xres, int yres, int *xset, int *yset)
  395. /* Parameters:                                */
  396. /*    xres, yres: resolution in lines per inch            */
  397. /*    *xset, *yset: the resolution set                */
  398. {
  399.     short *wptr;
  400.     _intin[0] = xres;
  401.     _intin[1] = yres;
  402.  
  403.      wptr = (short *)_contrl;
  404.     *wptr++ = 5;        /* 0  - opcode */
  405.     *wptr++ = 0;        /* 1 */
  406.      wptr++;        /* 2 */
  407.     *wptr++ = 2;        /* 3  - # of entries in _intin */
  408.      wptr++;        /* 4 */
  409.     *wptr++ = 81;        /* 5 - id */
  410.     *wptr   = handle;    /* 6 - handle */
  411.     vdi();
  412.  
  413.     *xset = _intout[0];
  414.     *yset = _intout[1];
  415. }
  416. #endif /* L_vt_resol */
  417.  
  418.  
  419. /*        vt_axis                            */
  420. /*        graphic tablet escape                    */
  421. /* SET TABLET AXIS RESOLUTION IN LINES                    */
  422. /* sets the horizontal and vertical resolution of the grapics tablet    */
  423.  
  424. #ifdef L_vt_axis
  425.  
  426. void vt_axis(int handle, int xres, int yres, int *xset, int *yset)
  427. /* Parameters:                                */
  428. /*    xres, yres: resolution in lines                 */
  429. /*    *xset, *yset: the resolution set                */
  430. {
  431.     short *wptr;
  432.     _intin[0] = xres;
  433.     _intin[1] = yres;
  434.  
  435.      wptr = (short *)_contrl;
  436.     *wptr++ = 5;        /* 0  - opcode */
  437.     *wptr++ = 0;        /* 1 */
  438.      wptr++;        /* 2 */
  439.     *wptr++ = 2;        /* 3  - # of entries in _intin */
  440.      wptr++;        /* 4 */
  441.     *wptr++ = 82;        /* 5 - id */
  442.     *wptr   = handle;    /* 6 - handle */
  443.     vdi();
  444.  
  445.     *xset = _intout[0];
  446.     *yset = _intout[1];
  447. }
  448. #endif /* L_vt_axis */
  449.  
  450.  
  451. /*        vt_origin                        */
  452. /*        graphics tablet escape                    */
  453. /* SET TABLET X AND Y ORIGIN                        */
  454. /* sets tablet origin.                            */
  455.  
  456. #ifdef L_vt_origi
  457.  
  458. void vt_origin(int handle, int xorigin, int yorigin)
  459. /* Parameters:                                */
  460. /*    xorigin: x - coordinate for the left upper corner        */
  461. /*    yorigin: y - coordinate for the left upper corner        */
  462. {
  463.     short *wptr;
  464.     _intin[0] = xorigin;
  465.     _intin[1] = yorigin;
  466.  
  467.      wptr = (short *)_contrl;
  468.     *wptr++ = 5;        /* 0  - opcode */
  469.     *wptr++ = 0;        /* 1 */
  470.      wptr++;        /* 2 */
  471.     *wptr++ = 2;        /* 3  - # of entries in _intin */
  472.      wptr++;        /* 4 */
  473.     *wptr++ = 83;        /* 5 - id */
  474.     *wptr   = handle;    /* 6 - handle */
  475.     vdi();
  476. }
  477. #endif /* L_vt_origi */
  478.  
  479.  
  480. /*        vt_tdimensions                        */
  481. /*        graphics tablet escape                    */
  482. /* RETURN TABLET X AND Y DIMENSIONS                    */
  483. /* returns the grapics tablet's dimensions in 1/10 inch            */
  484.  
  485. #ifdef L_vq_dimen
  486.  
  487. void vq_dimensions(int handle, int *xdimension, int *ydimension)
  488. /* Parameters: you can guess, can't you?                */
  489. {
  490.     short *wptr = (short *)_contrl;
  491.     *wptr++ = 5;        /* 0  - opcode */
  492.     *wptr++ = 0;        /* 1 */
  493.      wptr++;        /* 2 */
  494.     *wptr++ = 0;        /* 3  - # of entries in _intin */
  495.      wptr++;        /* 4 */
  496.     *wptr++ = 84;        /* 5 - id */
  497.     *wptr   = handle;    /* 6 - handle */
  498.     vdi();
  499.  
  500.     *xdimension = _intout[0];
  501.     *ydimension = _intout[1];
  502. }
  503. #endif /* L_vq_dimen */
  504.  
  505.  
  506. /*        vt_alignment                        */
  507. /*        graphics tablet escape                    */
  508. /* SET TABLET ALIGNMENT                            */
  509.  
  510. #ifdef L_vt_align
  511.  
  512. void vt_alignment(int handle, int dx, int dy)
  513. /* Parameters: dx, dy : offsets for X- and Y - coordinate from origin    */
  514.  
  515. {
  516.     short *wptr;
  517.     _intin[0] = dx;
  518.     _intin[1] = dy;
  519.  
  520.      wptr = (short *)_contrl;
  521.     *wptr++ = 5;        /* 0  - opcode */
  522.     *wptr++ = 0;        /* 1 */
  523.      wptr++;        /* 2 */
  524.     *wptr++ = 2;        /* 3  - # of entries in _intin */
  525.      wptr++;        /* 4 */
  526.     *wptr++ = 85;        /* 5 - id */
  527.     *wptr   = handle;    /* 6 - handle */
  528.     vdi();
  529. }
  530. #endif /* L_vt_align */
  531.  
  532.  
  533. /*        vsp_film                        */
  534. /*        polaroid palette escape                    */
  535. /* SET CAMERA FILM TYPE AND EXPOSURE TIME                */
  536. /* just what it says...                            */
  537.  
  538. #ifdef L_vsp_film
  539.  
  540. void vsp_film(int handle, int index, int lightness)
  541. /* Parameters:                                */
  542. /*    index: number of film type                    */
  543. /*    lightness: exposure time from -3 (half) to 0 (normal) to +3 (double) */
  544. {
  545.     short *wptr;
  546.     _intin[0] = index;
  547.     _intin[1] = lightness;
  548.  
  549.      wptr = (short *)_contrl;
  550.     *wptr++ = 5;        /* 0  - opcode */
  551.     *wptr++ = 0;        /* 1 */
  552.      wptr++;        /* 2 */
  553.     *wptr++ = 2;        /* 3  - # of entries in _intin */
  554.      wptr++;        /* 4 */
  555.     *wptr++ = 91;        /* 5 - id */
  556.     *wptr   = handle;    /* 6 - handle */
  557.     vdi();
  558. }
  559. #endif /* L_vsp_film */
  560.  
  561.  
  562. /*        vqp_filmname                        */
  563. /*        polaroid palette escape                    */
  564. /* INQUIRE CAMERA FILM NAME                        */
  565. /* returns the name of a film, given its index, or the null string if    */
  566. /* it does not exist, with a maximum of 24 characters.            */
  567.  
  568. #ifdef L_vqp_film
  569.  
  570. int vqp_filmname(int handle, int index, char *name)
  571. /* Parameters:                                */
  572. /*    index: Index of the film type                    */
  573. /*    *name: name of the film type                    */
  574. /* return value: 0: wrong number of film                */
  575. {
  576.     short tmp, res;
  577.     short *ptmp;
  578.     short *wptr;
  579.  
  580.     _intin[0] = index;
  581.  
  582.      wptr = (short *)_contrl;
  583.     *wptr++ = 5;        /* 0  - opcode */
  584.     *wptr++ = 0;        /* 1 */
  585.      wptr++;        /* 2 */
  586.     *wptr++ = 1;        /* 3  - # of entries in _intin */
  587.      wptr++;        /* 4 */
  588.     *wptr++ = 92;        /* 5 - id */
  589.     *wptr   = handle;    /* 6 - handle */
  590.     vdi();
  591.  
  592.     ptmp = _intout;
  593.     res = _contrl[4];
  594.     for (tmp = 0; tmp < res; tmp++)
  595.         *name++ = *ptmp++;
  596.  
  597.     return res;
  598. }
  599. #endif /* L_vqp_film */
  600.  
  601.  
  602. /*        vsc_expose(handle, state)                */
  603. /*        polaroid palette escape                    */
  604. /* DISABLE OR ENABLE FILM EXPOSURE FOR FRAME PREVIEW            */
  605. /* ...                                    */
  606.  
  607. #ifdef L_vsc_expo
  608.  
  609. void vsc_expose(int handle, int state)
  610. /* Parameters:                                */
  611. /*    state:     = 0: switch off exposure                */
  612. /*        != 0: switch on exposure                */
  613. {
  614.     short *wptr;
  615.     _intin[0] = state;
  616.  
  617.      wptr = (short *)_contrl;
  618.     *wptr++ = 5;        /* 0  - opcode */
  619.     *wptr++ = 0;        /* 1 */
  620.      wptr++;        /* 2 */
  621.     *wptr++ = 1;        /* 3  - # of entries in _intin */
  622.      wptr++;        /* 4 */
  623.     *wptr++ = 93;        /* 5 - id */
  624.     *wptr   = handle;    /* 6 - handle */
  625.     vdi();
  626. }
  627. #endif /* L_vsc_expo */
  628.  
  629.  
  630. /*        v_meta_extents                        */
  631. /*        metafile escape                        */
  632. /* UPDATE METAFILE EXTENTS                        */
  633. /* all the information in a metafile header is renewed.            */
  634.  
  635. #ifdef L_v_meta_e
  636.  
  637. void v_meta_extents(int handle, int min_x, int min_y, int max_x, int max_y)
  638. /* Parameters:                                */
  639. /*    min_x : minimum x - value of surrounding rectangle        */
  640. /*    min_y : dto., with y                        */
  641. /*    max_x : maximum y - value of surrounding rectangle        */
  642. /*    max_y : dto, with y                        */
  643. {
  644.     short *wptr;
  645.     _ptsin[0] = min_x;
  646.     _ptsin[1] = min_y;
  647.     _ptsin[2] = max_x;
  648.     _ptsin[3] = max_y;
  649.  
  650.      wptr = (short *)_contrl;
  651.     *wptr++ = 5;        /* 0  - opcode */
  652.     *wptr++ = 2;        /* 1 - # of points */
  653.      wptr++;        /* 2 */
  654.     *wptr++ = 0;        /* 3 - # of entries in _intin */
  655.      wptr++;        /* 4 */
  656.     *wptr++ = 98;        /* 5 - id */
  657.     *wptr   = handle;    /* 6 - handle */
  658.     vdi();
  659. }
  660. #endif /* L_v_meta_e */
  661.  
  662.  
  663. /*        v_write_meta                        */
  664. /*        metafile escape                        */
  665. /*        WRITE METAFILE ITEM                    */
  666. /* write a user - defined opcode into a metafile. Note that opcodes    */
  667. /* 0 to 100 are reserved.                        */
  668.  
  669. #ifdef L_v_write_
  670.  
  671. void v_write_meta(int handle, int num_intin, int *a_intin, int num_ptsin,
  672.             int *a_ptsin)
  673. /* parameters:                                */
  674. /*    num_intin: number of elements in the _intin - array        */
  675. /*    num_ptsin: number of elements in the _ptsin - array        */
  676. /*    a_intin[0] : user - defined sub - opcode            */
  677. /*    a_intin[1] ... a_intin[num_intin-1] : user - defined data    */
  678. /*    a_ptsin[0] ... a_ptsin[num_ptsin-1] : user - defined data    */
  679. /* GEM Draw uses the following opcodes:                    */
  680. /*    START GROUP (10)                        */
  681. /*    END GROUP (11)                            */
  682. /*    SET NO LINE STYLE (49)                        */
  683. /*    SET ATTRIBUTE SHADOW ON (50)                    */
  684. /*    SET ATTRIBUTE SHADOW OFF (51)                    */
  685. /*    START DRAW AREA PRIMITIVE (80)                    */
  686. /*    END DRAW AREA PRIMITIVE (81)                    */
  687. {
  688.     short *wptr;
  689. #ifdef __MSHORT__    /* we have 16 bit ints, just change vdi params */
  690.     _vdiparams[1] = (void *) &a_intin[0];
  691.     _vdiparams[2] = (void *) &a_ptsin[0];
  692. #else            /* 32 bit ints - let's copy */
  693.     register int i;
  694.  
  695.     for(i = 0; i < num_intin; i++)
  696.         _intin[i] = a_intin[i];
  697.  
  698.     for(i = 0; i < num_ptsin; i++)
  699.         _ptsin[i] = a_ptsin[i];
  700. #endif
  701.  
  702.      wptr = (short *)_contrl;
  703.     *wptr++ = 5;        /* 0  - opcode */
  704.     *wptr++ = num_ptsin;    /* 1 - # of points */
  705.      wptr++;        /* 2 */
  706.     *wptr++ = num_intin;    /* 3 - # of entries in _intin */
  707.      wptr++;        /* 4 */
  708.     *wptr++ = 99;        /* 5 - id */
  709.     *wptr   = handle;    /* 6 - handle */
  710.     vdi();
  711.  
  712. #ifdef __MSHORT__
  713.     _vdiparams[1] = (void *)&_intin[0]; /* restore vdi parameters */ 
  714.     _vdiparams[2] = (void *)&_ptsin[0]; 
  715. #endif
  716. }
  717. #endif /* L_v_write_ */
  718.  
  719.  
  720. /*        vm_pagesize                        */
  721. /*        metafile escape                        */
  722. /* PHYSICAL PAGE SIZE                            */
  723. /* set the page size in 1/10 mm                        */
  724.  
  725. #ifdef L_vm_pages
  726.  
  727. void vm_pagesize(int handle, int pgwidth, int pgheight)
  728. /* Parameters:                                */
  729. /*    pgwidth: width in 1/10 mm                    */
  730. /*    pgheight: height in 1/10 mm                    */
  731. {
  732.     short *wptr;
  733.     _intin[0] = 0;
  734.     _intin[1] = pgwidth;
  735.     _intin[2] = pgheight;
  736.  
  737.      wptr = (short *)_contrl;
  738.     *wptr++ = 5;        /* 0  - opcode */
  739.     *wptr++ = 0;        /* 1 */
  740.      wptr++;        /* 2 */
  741.     *wptr++ = 3;        /* 3  - # of entries in _intin */
  742.      wptr++;        /* 4 */
  743.     *wptr++ = 99;        /* 5 - id */
  744.     *wptr   = handle;    /* 6 - handle */
  745.     vdi();
  746. }
  747. #endif /* L_vm_pages */
  748.  
  749.  
  750. /*        vm_coords                        */
  751. /*        metafile escape                        */
  752. /* COORDINAT WINDOW                            */
  753. /* sets the coordinate system for the page.                */
  754.  
  755. #ifdef L_vm_coord
  756.  
  757. void vm_coords(int handle, int llx, int lly, int urx, int ury)
  758. /* Parameters:                                */
  759. /*    llx: x - coordinate in the left lower corner            */
  760. /*    lly: y - coordinate in the left lower corner            */
  761. /*    urx: x - coordinate in the right upper corner            */
  762. /*    ury: y - coordinate in the right upper corner            */
  763. {
  764.     short *wptr;
  765.     _intin[0] = 1;
  766.     _intin[1] = llx;
  767.     _intin[2] = lly;
  768.     _intin[3] = urx;
  769.     _intin[4] = ury;
  770.  
  771.      wptr = (short *)_contrl;
  772.     *wptr++ = 5;        /* 0  - opcode */
  773.     *wptr++ = 0;        /* 1 */
  774.      wptr++;        /* 2 */
  775.     *wptr++ = 5;        /* 3  - # of entries in _intin */
  776.      wptr++;        /* 4 */
  777.     *wptr++ = 99;        /* 5 - id */
  778.     *wptr   = handle;    /* 6 - handle */
  779.     vdi();
  780. }
  781. #endif /* L_vm_coord */
  782.  
  783.  
  784. /*        vm_filename                        */
  785. /*        metafile escape                        */
  786. /* CHANGE GEM VDI FILE NAME                        */
  787. /* changes a metafile name from GEMFILE.GEM to <something esle>.GEM.    */
  788. /* Has no effect unless executed immediately after OPEN WORKSTATION.    */
  789.  
  790. #ifdef L_vm_filen
  791.  
  792. void vm_filename(int handle, const char *filename)
  793. {
  794.     short n;
  795.     register short *ptmp = _intin;
  796.     short *wptr;
  797.     char  *s=filename;
  798.  
  799. /* copy string */
  800.     while (*ptmp++ = (unsigned char) *s++)
  801.          ;
  802.      n = (s - filename) -1;
  803.  
  804.      wptr = (short *)_contrl;
  805.     *wptr++ = 5;        /* 0  - opcode */
  806.     *wptr++ = 0;        /* 1 */
  807.      wptr++;        /* 2 */
  808.     *wptr++ = n;        /* 3  - # of entries in _intin */
  809.      wptr++;        /* 4 */
  810.     *wptr++ = 100;        /* 5 - id */
  811.     *wptr   = handle;    /* 6 - handle */
  812.     vdi();
  813.  
  814. }
  815. #endif /* L_vm_filen */
  816.  
  817.  
  818. /*        v_escape2000                        */
  819. /*        escape for Atari SLM804                    */
  820. /* ESCAPE 2000                                */
  821. /* prints the current page several times on the SLM804            */
  822.  
  823. #ifdef L_v_escape
  824.  
  825. void v_escape2000(int handle, int times)
  826. /* Parameters:                                */
  827. /*    times: number of times to print the current page        */
  828. {
  829.     short *wptr;
  830.           _intin[0] = times;
  831.  
  832.      wptr = (short *)_contrl;
  833.     *wptr++ = 5;        /* 0  - opcode */
  834.     *wptr++ = 0;        /* 1 */
  835.      wptr++;        /* 2 */
  836.     *wptr++ = 1;        /* 3  - # of entries in _intin */
  837.      wptr++;        /* 4 */
  838.     *wptr++ = 2000;        /* 5 - id */
  839.     *wptr   = handle;    /* 6 - handle */
  840.     vdi();
  841. }
  842. #endif /* L_v_escape */
  843.