home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / gmlibs23 / vdifsm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-30  |  10.6 KB  |  449 lines

  1. /*
  2.  * FSM gdos bindings
  3.  * this file has some relationship to a file supplied by Atari
  4.  * but it changed quite a bit (among other things it appears to work).
  5.  * v_shtext survived verbatim from the original.
  6.  */
  7.  
  8. #include "common.h"
  9. #ifndef _COMPILER_H
  10. # include <compiler.h>
  11. #endif
  12. #include <types.h>
  13.  
  14. /* FSMBIND functions
  15.  * ======================================================================
  16.  */
  17.  
  18. #ifdef __DEF_ALL__
  19.  
  20. #define L_v_getbit
  21. #define L_vqt_fext
  22. #define L_v_ftext
  23. #define L_v_killou
  24. #define L_v_getout
  25. #define L_vst_scra
  26. #define L_vst_erro
  27. #define L_v_shtext
  28. #define L_vst_arbp
  29. #define L_vqt_adva
  30. #define L_vqt_devi
  31. #define L_v_saveca
  32. #define L_v_loadca
  33. #define L_v_flushc
  34. #define L_vst_sets
  35. #define L_vst_skew
  36. #define L_vqt_get_
  37. #define L_vqt_cach
  38.  
  39. #endif /* __DEF_ALL__ */
  40.  
  41. #ifdef L_v_getbit
  42.  
  43. /* ---------------------------------------------------------------------------
  44.  * Retrieve placement information for FSM generated characters
  45.  * Information is placed in infoarray of 52 ints.
  46.  * Borrow a soothsayer from DRI or Atari to find its meaning.
  47.  *
  48.  * This is a temporary bindings since one genius decided
  49.  * that some entries in infoarray will represent real numbers.
  50.  * You may fully expect that that this representation of reals is
  51.  * absolutely different from what your compiler is using.
  52.  * Count your lucky stars if at least sizeof(double) == 2 * sizeof(int).
  53.  * Or maybe sizeof(double) is supposed to be sizeof(float)?
  54.  */
  55. void
  56. v_getbitmap_info(int handle, int ch, int infoarray[52])
  57. {
  58.     short *ptr = _intin;
  59.  
  60.     *ptr++ = ch;
  61.     *(int **)ptr = &infoarray[0];
  62.  
  63.     __vdi__(VDI_CONTRL_ENCODE(239, 0, 3, 0), handle);
  64.  
  65. #ifndef __MSHORT__
  66.     /* Repack returned information from an array of shorts into an
  67.        array of ints */
  68.     { /* dummy block to contain new declarations */
  69.     short *s_ptr = (short *)(&infoarray[0]) + 52;
  70.     short *bot   = (short *)(&infoarray[0]) +  4;
  71.     int   *i_ptr = (&infoarray[0]) + 52;
  72.  
  73.     do {
  74.         s_ptr -= 2;              /* copy y-offset */
  75.         *(--i_ptr) = *(int *)s_ptr;
  76.         *(--i_ptr) = 0;
  77.     
  78.         s_ptr -= 2;              /* copy x-offset */
  79.         *(--i_ptr) = *(int *)s_ptr;
  80.         *(--i_ptr) = 0;
  81.         
  82.         *(--i_ptr) = *(--s_ptr);  /* bitmap height */
  83.         *(--i_ptr) = *(--s_ptr);  /* bitmap width  */
  84.     } while (s_ptr > bot);
  85.  
  86.     *(--i_ptr) = *(--s_ptr);      /* remainder y-advance */
  87.     *(--i_ptr) = *(--s_ptr);      /* y-advance */
  88.     *(--i_ptr) = *(--s_ptr);      /* remainder x-advance */
  89.     *i_ptr     = *s_ptr;          /* x-advance */
  90.     }
  91. #endif /* __MSHORT__ */
  92. }
  93.  
  94. #endif /* L_v_getbit */
  95.  
  96. #ifdef L_vqt_fext
  97.  
  98. /* ---------------------------------------------------------------------------
  99.  * Inquire text extent, accounting for FSM text placement
  100.  */
  101. void
  102. vqt_f_extent(int handle, const char *str, int extent[8])
  103. {
  104.     unsigned char ch;
  105.     short *ptr;
  106.     int   *ept, *end;
  107.     
  108.     ptr = _intin;
  109.     while ( ch = *str++)
  110.     *ptr++ = ch;
  111.     *ptr = 0;    
  112.     __vdi__(VDI_CONTRL_ENCODE(240, 0, (int)(ptr - _intin), 0), handle);
  113.     
  114.     ptr = _ptsout;
  115.     ept = extent;
  116.     end = ept + 8;
  117.     do {
  118.     *ept++ = *ptr++;
  119.     } while (ept < end);
  120. }
  121.  
  122. #endif /* L_vqt_fext */
  123.  
  124.  
  125. #ifdef L_v_ftext
  126.  
  127. /* ---------------------------------------------------------------------------
  128.  * Draw FSM text (accounts for fractional advances in rotated text)
  129.  */
  130. void
  131. v_ftext(int handle, int x, int y, const char *str)
  132. {
  133.     unsigned char   ch;
  134.     short *ptr = _intin;
  135.     
  136.     _ptsin[0] = x;
  137.     _ptsin[1] = y;
  138.     while ( ch  = (unsigned const char) *str++)
  139.     *ptr++ = ch;
  140.     *ptr = 0;
  141.     
  142.     __vdi__(VDI_CONTRL_ENCODE(241, 1, (int)(ptr - _intin), 0), handle);
  143. }
  144.  
  145. #endif /* L_v_ftext */
  146.  
  147.  
  148. #ifdef L_v_killou
  149. /* ---------------------------------------------------------------------------
  150.  * Release memory associated with outline component generated by v_getoutline()
  151.  */
  152. void
  153. v_killoutline(int handle, void *component)
  154. {
  155.     *(void **)&_intin[0] =  component;
  156.     __vdi__(VDI_CONTRL_ENCODE(242, 0, 2, 0), handle);
  157. }
  158. #endif /* L_v_killou */
  159.  
  160.  
  161. #ifdef L_v_getout
  162. /* ---------------------------------------------------------------------------
  163.  * Generate an outline for character ch, and return the address of the outline.
  164.  */
  165. void
  166. v_getoutline(int handle, int ch, void **component)
  167. {
  168.     _intin[0] = ch;
  169.     *(void ***)&_intin[1] = component;
  170.     __vdi__(VDI_CONTRL_ENCODE(243, 0, 3, 0), handle);
  171. }
  172.  
  173. #endif /* L_v_getout */
  174.  
  175.  
  176. #ifdef L_vst_scra
  177. /* ---------------------------------------------------------------------------
  178.  * Set scratch buffer allocation mode.
  179.  * This buffes is used when creating special effects on fonts.
  180.  * mode=0: (default) account for FSM fonts when allocating scratch buffers
  181.  * mode=1: account only for BM fonts;  no special effects for outlines
  182.  * mode=2: allocate no scratch buffer; no special effects at all
  183.  */
  184. void
  185. vst_scratch(int handle, int mode)
  186. {
  187.     _intin[0] = mode;
  188.     __vdi__(VDI_CONTRL_ENCODE(244, 0, 1, 0), handle);
  189. }
  190.  
  191. #endif /* L_vst_scra */
  192.  
  193.  
  194. #ifdef L_vst_erro
  195.  
  196. /* ---------------------------------------------------------------------------
  197.  * Set FSM error mode.
  198.  * mode=1: (default) errors go to screen.
  199.  * mode=0: errors reported in error variable `errorvar'.
  200.  */
  201. void
  202. vst_error(int handle, int mode, int *errorvar)
  203. {
  204.     _intin[0] = mode;
  205.     *(int **)&_intin[1] = errorvar;
  206.     __vdi__(VDI_CONTRL_ENCODE(245, 0, 3, 0), handle);
  207. }
  208.  
  209. #endif /* L_vst_erro */
  210.  
  211.  
  212. #ifdef L_v_shtext
  213.  
  214. /* ----------------------------------------------------------------------
  215.  * v_gtext with shadow.
  216.  * Text color should be set to `color' before calling.
  217.  * This is not technically an FSM binding,
  218.  * but this module is a convenient place for it.
  219.  */
  220. void
  221. v_shtext( int wsid, 
  222.       int x,
  223.       int y,
  224.       const char * text,
  225.       int color,
  226.       int xshadow,
  227.       int yshadow )
  228. {
  229.     __EXTERN void v_ftext __PROTO((int, int, int, const char *));
  230.     __EXTERN int vst_color __PROTO((int, int));
  231.  
  232.     if( xshadow || yshadow )
  233.     {
  234.     v_ftext( wsid, x+xshadow*2, y+yshadow*2, text );
  235.     (void) vst_color( wsid, 0 );
  236.     v_ftext( wsid, x+xshadow, y+yshadow, text );
  237.     (void) vst_color( wsid, color );
  238.     }
  239.     v_ftext( wsid, x, y, text );
  240. }
  241. #endif /* L_v_shtext */
  242.  
  243.  
  244. #ifdef L_vst_arbp
  245.  
  246. /* ----------------------------------------------------------------------
  247.  * Set character cell height to arbitrary value.
  248.  * Height is given in printer points (more or less) and it does not
  249.  * have to be listed in extend.sys.
  250.  * Only for FSM outline fonts.
  251.  */
  252. int
  253. vst_arbpt( int handle,
  254.        int point,
  255.        int *wchar,
  256.        int *hchar,
  257.        int *wcell,
  258.        int *hcell )
  259. {
  260.     short    *outp = &_ptsout[0];
  261.  
  262.     _intin[0] = point;
  263.     __vdi__(VDI_CONTRL_ENCODE(246, 0, 1, 0), handle);
  264.     *wchar = *outp++;
  265.     *hchar = *outp++;
  266.     *wcell = *outp++;
  267.     *hcell = *outp;
  268.  
  269.     return _intout[0];
  270. }
  271. #endif /* L_vst_arbp */
  272.  
  273. #ifdef L_vqt_adva
  274.  
  275. /* ----------------------------------------------------------------------
  276.  * Inquire FSM text advance placement vector.
  277.  * Remainders xrem and yrem are modulo 16384 (2^14, 1 << 14)
  278.  */
  279. void
  280. vqt_advance( int handle, int ch, int *xadv, int *yadv, int *xrem, int *yrem)
  281. {
  282.     short    *outp = &_ptsout[0];
  283.  
  284.     _intin[0] = ch;
  285.     __vdi__(VDI_CONTRL_ENCODE(247, 0, 1, 0), handle);
  286.     *xadv = *outp++;
  287.     *yadv = *outp++;
  288.     *xrem = *outp++;
  289.     *yrem = *outp;
  290. }
  291. #endif /* L_vqt_adva */
  292.  
  293. #ifdef L_vqt_devi
  294.  
  295. /* ----------------------------------------------------------------------
  296.  * Inquire device status information.
  297.  * 
  298.  * Watch out!  Name is returned as a COUNTED string in 8+3 format,
  299.  * without separator, all in an upper case.  Missing character
  300.  * positions are filled with blanks.
  301.  * (At least this was the case for some versions of FSMGDOS.
  302.  * Who knows what will happen next.  This is NOT documented.
  303.  * Check before you jump!)
  304.  */
  305. void
  306. vqt_devinfo( int handle, int device, int *isdev, char *drivername )
  307. {
  308.     short    *ioutp, *end;
  309.  
  310.     _intin[0] = device;
  311.     __vdi__(VDI_CONTRL_ENCODE(248, 0, 1, 0), handle);
  312.     if (0 != (*isdev = _ptsout[0])) {
  313.     ioutp = _intout;
  314.     end  = ioutp + _contrl[4];
  315.     do {
  316.         *drivername++ = (char) *ioutp++;
  317.     } while (ioutp < end);
  318.     }
  319.     *drivername = '\0';
  320. }
  321. #endif /* L_vqt_devi */
  322.  
  323. #ifdef L_v_saveca
  324.  
  325. /* ----------------------------------------------------------------------
  326.  * Save FSM cache to disk.
  327.  */
  328. int
  329. v_savecache( int handle, char *filename )
  330. {
  331.     short       *inptr = _intin;
  332.  
  333.     while (*inptr++ = *filename++)
  334.     ;    /* nothing */
  335.     __vdi__(VDI_CONTRL_ENCODE(249, 0, (int)(inptr - _intin), 0), handle);
  336.  
  337.     return _intout[0];
  338. }
  339. #endif /* L_v_saveca */
  340.  
  341. #ifdef L_v_loadca
  342.  
  343. /* ----------------------------------------------------------------------
  344.  * Load/merge FSM cache from disk.
  345.  */
  346. int
  347. v_loadcache( int handle, char *filename, int mode )
  348. {
  349.     short *inptr = _intin;
  350.  
  351.     *inptr++ = mode;
  352.     while (*inptr++ = *filename++)
  353.     ;    /* nothing */
  354.     __vdi__(VDI_CONTRL_ENCODE(250, 0, (int)(inptr - _intin), 0), handle);
  355.  
  356.     return _intout[0];
  357. }
  358. #endif /* L_v_loadca */
  359.  
  360. #ifdef L_v_flushc
  361.  
  362. /* ----------------------------------------------------------------------
  363.  * Flush FSM cache.
  364.  */
  365. int
  366. v_flushcache( int handle )
  367. {
  368.     __vdi__(VDI_CONTRL_ENCODE(251, 0, 0, 0), handle);
  369.  
  370.     return _intout[0];
  371. }
  372. #endif /* L_v_flushc */
  373.  
  374. #ifdef L_vst_sets
  375.  
  376. /* ----------------------------------------------------------------------
  377.  * Set character cell width (set size) to arbitrary value.
  378.  * Width is given in printer points (more or less).
  379.  * Only for FSM outline fonts.
  380.  * Effects are cancelled by calls to vst_point, vst_arbpt or vst_height.
  381.  */
  382. int
  383. vst_setsize( int handle,
  384.          int point,
  385.          int *wchar,
  386.          int *hchar,
  387.          int *wcell,
  388.          int *hcell )
  389. {
  390.     short *outp = &_ptsout[0];
  391.     
  392.     _intin[0] = point;
  393.     __vdi__(VDI_CONTRL_ENCODE(252, 0, 1, 0), handle);
  394.  
  395.     *wchar = *outp++;
  396.     *hchar = *outp++;
  397.     *wcell = *outp++;
  398.     *hcell = *outp;
  399.  
  400.     return _intout[0];
  401. }
  402. #endif /* L_vst_sets */
  403.  
  404. #ifdef L_vst_skew
  405.  
  406. /* ----------------------------------------------------------------------
  407.  * Set FSM skew.
  408.  * Skew in tenths of degrees.  Valid values between -900 and 900.
  409.  */
  410. int
  411. vst_skew( int handle, int skew )
  412. {
  413.     _intin[0] = skew;
  414.     __vdi__(VDI_CONTRL_ENCODE(253, 0, 1, 0), handle);
  415.  
  416.     return _intout[0];
  417. }
  418. #endif /* L_vst_skew */
  419.  
  420. #ifdef L_vqt_get_
  421.  
  422. /* ----------------------------------------------------------------------
  423.  * Get FSM GASCII tables.
  424.  */
  425. void
  426. vqt_get_tables( int handle, void **gascii, void **style )
  427. {
  428.     __vdi__(VDI_CONTRL_ENCODE(254, 0, 0, 0), handle);
  429.     *gascii = *(void **)&_intout[0];
  430.     *style =  *(void **)&_intout[2];
  431. }
  432. #endif /* L_vqt_get_ */
  433.  
  434. #ifdef L_vqt_cach
  435.  
  436. /* ----------------------------------------------------------------------
  437.  * Get FSM cashe size
  438.  */
  439. void
  440. vqt_cachesize( int handle, int which_cache, size_t *size )
  441. {
  442.     _intin[0] = which_cache;
  443.     __vdi__(VDI_CONTRL_ENCODE(255, 0, 1, 0), handle);
  444.     *size = *(size_t *)&_intout[0];
  445. }
  446. #endif /* L_vqt_cach */
  447.  
  448. /* -eof- */
  449.