home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / magazi~1 / 226 / analog.49 / fx.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-10-14  |  6.6 KB  |  204 lines

  1.  
  2. /*********************************************************************
  3. * FAX Library: [9.X.86] |
  4. *-----------------------
  5. *
  6. * fx.c--  or, fun with ST fonts (generic text screen dump).
  7. *         (Megamax in-line assembly version.)
  8. *
  9. *   ( Test version is typed in at keyboard under TOS:                  )
  10. *   (      fx <top left x-coord of dump window> <top left y-coord>     )
  11. *   (         <width of dump window> <height of dump window>           )
  12. *   (         <keyboard abort enable: 'y' or 'Y' => enabled, else not> )
  13. *
  14. *    Files  (".ca" => in-line assembly code):
  15. *                   fxcomp.h: compiler switches.
  16. *                   fxd.h:    constants and data declarations.
  17. *                   fxm.h:    memory allocation constants.
  18. *                   fx.c:     C code top level: initialization.
  19. *                             (includes "fxd.h", "f5.ca", <stdio.h>, 
  20. *                                       and <osbind.h>.)
  21. *                   f5.ca:    top level of assembly language routines.
  22. *                             (includes "f6.ca", "f7.ca", "f8.ca", and
  23. *                                       "fs1.ca".)
  24. *                   f6.ca:    part 1 of special routines.
  25. *                   f7.ca:    part 2 of special routines.
  26. *                   f8.ca:    part 3 of special routines.
  27. *                   fs1.ca:   miscellaneous routines.
  28. *    --these are compiled and collected into "faxlib", which is then
  29. *      linked to from "fax.o" to produce "fax.acc".
  30. *
  31. *
  32. *********************************************************************/
  33.  
  34. #include <stdio.h>       /* for 'malloc()' use                      */
  35. #include <osbind.h>      /* for Gemdos calls                        */
  36. #include "fxcomp.h"      /* compiler switches                       */
  37. #include "fxm.h"         /* data structure sizes                    */
  38. #include "fxd.h"         /* constants and data declarations         */
  39.  
  40.  
  41. /* Memory for the following large data structures is allocated in   */
  42. /*   "fax.o":                                                       */
  43. #ifdef GEM_VER
  44. extern   long *scan_packs;    /* pointer to collision list          */
  45. extern   long *hash_table;    /* pointer to hash table              */
  46. extern   int *chunk;          /* pointer to saved window            */
  47. extern   char *dump_space;    /* pointer to dumped ascii codes      */
  48. #endif
  49.  
  50. #ifdef TEST_VER
  51. #ifdef SC_IMAGE
  52. int *chunk;  
  53. #endif
  54. long *scan_packs;             /* collision list   */
  55. long *hash_table;             /* hash table       */
  56. char *dump_space;             /* dumped codes     */
  57. #endif
  58.  
  59.  
  60. /****
  61. *
  62. * TOS test == 'main'-- some C code for initialization, &c.
  63. * Run version == 'fax_exec'-- called from desk accessory.
  64. *
  65. ****/          
  66.  
  67. #ifdef TEST_VER
  68. main(argc,argv)
  69. int argc;          
  70. char *argv[];       /* command line == test switches              */
  71. #endif
  72.  
  73. #ifdef GEM_VER
  74. int fax_exec(fx_x,fx_y,fx_w,fx_h,fx_to,fx_herr,fx_rerr,f_i,k_a,trgr,T_v,
  75.              h_5)
  76. int fx_x;           /* top left x-coord of dump area              */             
  77. int fx_y;           /* top left y-coord of dump area              */
  78. int fx_w;           /* pixel width of dump area                   */
  79. int fx_h;           /* pixel height of dump area                  */
  80. int *fx_to;         /* TRUE => printer timeout error              */
  81. int *fx_herr;       /* hash error count                           */
  82. int *fx_rerr;       /* recognize error count                      */
  83. int f_i;            /* nr of extra scan lines between text lines  */
  84. int k_a;            /* TRUE => keyboard abort enabled             */
  85. int trgr;           /* trigger code for TOS resident version      */
  86. int T_v;            /* TRUE => TOS version active                 */
  87. int h_5;            /* TRUE => 6 x 6 font in use                  */
  88. #endif
  89. {
  90.      int printed;   /* return from 'psend()'-- TRUE => timeout error  */
  91.  
  92. #ifdef TEST_VER
  93.      /* allocate memory for data structures  */  
  94.      scan_packs = (long *)calloc(SCAN_P_SIZE,1);
  95.      hash_table = (long *)calloc(HASH_T_SIZE,1);
  96.      dump_space = calloc(DUMP_SIZE,1);
  97. #ifdef SC_IMAGE
  98.      chunk = (int *)calloc(CHUNK_SIZE,1);
  99. #endif
  100. #endif
  101.  
  102.      /* initialize dump string storage area  */
  103.      for (i = 0, p_ptr = dump_space; i < DUMP_SIZE; i++)
  104.           *p_ptr++ = '\0';
  105.  
  106. #ifdef SC_IMAGE
  107.      /* clear window storage area            */
  108.      for (i = 0, p_ptr = (char *)chunk; i < CHUNK_SIZE; i++)
  109.           *p_ptr++ = ' ';
  110. #endif 
  111.  
  112.      /* clumsy transfer of parms from caller */
  113. #ifdef GEM_VER
  114.      form_inc = f_i;
  115.      kbd_abort = k_a;
  116.      trigger = trgr;
  117.      TOS_ver = T_v;
  118. #endif
  119.  
  120.      /* set dump coordinates      */
  121. #ifdef TEST_VER 
  122.      form_inc = 0;
  123.      kbd_abort = 0;
  124.  
  125.      if (argc >= ARG_NR)
  126.      {
  127.           w_xc = atol(argv[1]);
  128.           w_yc = atol(argv[2]);
  129.           w_width = atol(argv[3]);
  130.           w_height = atol(argv[4]);
  131.           a_test = (tolower(*argv[5]) == 'y') ? 0 : -1; 
  132.           hi50 = (argc > ARG_NR) ? 0 : -1;
  133.           printf("fx test version 1.0...\n");
  134.      }
  135.      else
  136.      {
  137.           printf("error\n");
  138.           exit(1);
  139.      }
  140. #endif
  141.  
  142. #ifdef GEM_VER        
  143.      w_xc = (long)fx_x;
  144.      w_yc = (long)fx_y;
  145.      w_width = (long)fx_w;
  146.      w_height = (long)fx_h;
  147.      a_test = 1;
  148.      hi50 = (long)h_5;           
  149. #endif
  150.  
  151.      bit_off = 0;   /* starting bit offset   */
  152.  
  153.      /* call dump routine     */
  154.      dumper();
  155.  
  156.      if (func_ret != ABORT)
  157.      {
  158.           /* print dumped strings     */
  159.           p_ptr = dump_space;
  160.           for (i = 0, stop_it = FALSE; (i < LINE_NR) && (!stop_it); i++)
  161.           {
  162. #ifdef TEST_VER 
  163.                printf("%s\n", p_ptr);
  164. #endif
  165. #ifdef GEM_VER
  166.                if (!(printed = psend(p_ptr)))
  167.                     break;
  168. #endif
  169.                p_ptr += LINE_LEN;
  170.                stop_it = (*p_ptr == '\0') ? TRUE : FALSE;    
  171.           }
  172. #ifdef TEST_VER  
  173.           if (!printed)
  174.                printf("printer timeout error\n");
  175.           if (hash_errors > 0)
  176.                printf("hash errors = %d\n",(int)hash_errors);
  177.           if (recg_errors > 0)
  178.                printf("recognize errors = %d\n",(int)recg_errors);
  179. #endif
  180.      }
  181.  
  182. #ifdef GEM_VER  
  183.      *fx_to = !printed;
  184.      *fx_herr = (int)hash_errors;
  185.      *fx_rerr = (int)recg_errors;
  186. #endif
  187.  
  188.      /* program exit     */
  189. #ifdef TEST_VER  
  190.      exit(0);
  191. #endif
  192. #ifdef GEM_VER
  193.      return GOOD;  
  194. #endif
  195.  
  196. }    /* end of 'main()' or 'fax_exec()'  */
  197.  
  198. #include "f9.c"           /* miscellaneous c routines        */
  199. #include "f5.ca"          /* assembly language routines      */
  200.  
  201.  
  202.  
  203.  
  204.