home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume26 / ltroff / part01 / cat.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-15  |  5.4 KB  |  178 lines

  1. #ifndef lint
  2. #ifndef NOID
  3. static char    cathid[] = "@(#)cat.h    4.1";
  4. #endif /* !defined NOID */
  5. #endif /* !defined lint */
  6. /* mask for high order 4 bits of byte */
  7. #define CAT_HIGH_NIBBLE 0xf0
  8. #define CAT_MAX_BYTE 0xff
  9.  
  10. #define CAT_ESCAPE_CODE 0x80
  11. #define CAT_ESCAPE_MASK 0x7f
  12. #define CAT_MAX_ESCAPE 0x7f
  13. /* nonzero if escape command and zero otherwise */
  14. #define CAT_IS_ESCAPE(x) (((x) & (CAT_HIGH_NIBBLE << 3)) == CAT_ESCAPE_CODE)
  15. /* magnitude of escape */
  16. #define CAT_ESCAPE(x) (~(x) & CAT_ESCAPE_MASK)
  17. #define CAT_ENCODE_ESCAPE(n) (CAT_ESCAPE_CODE | (~(n) & CAT_ESCAPE_MASK))
  18.  
  19. #define CAT_LEAD_CODE 0x60
  20. #define CAT_LEAD_MASK 0x1f
  21. #define CAT_MAX_LEAD 0x1f
  22. /* nonzero if leading command and zero otherwise */
  23. #define CAT_IS_LEADING(x) (((x) & (CAT_HIGH_NIBBLE << 1)) == CAT_LEAD_CODE)
  24. /* magnitude of leading */
  25. #define CAT_LEAD(x) (~(x) & CAT_MAX_LEAD)
  26. #define CAT_ENCODE_LEAD(n) (CAT_LEAD_CODE | (~(n) & CAT_LEAD_MASK))
  27.  
  28. #define CAT_SIZE_CHANGE_CODE 0x50
  29. /* nonzero if point size change command and zero otherwise */
  30. #define CAT_IS_SIZE_CHANGE(x) (((x) & CAT_HIGH_NIBBLE) == CAT_SIZE_CHANGE_CODE)
  31.  
  32. /* translates from the weird CAT point size change codes into something sane */
  33. #define CAT_SIZE_CHANGE(x) \
  34.     ((x) == 0x50 ? 7 : \
  35.      (x) == 0x51 ? 8 : \
  36.      (x) == 0x52 ? 10 : \
  37.      (x) == 0x53 ? 11 : \
  38.      (x) == 0x54 ? 12 : \
  39.      (x) == 0x55 ? 14 : \
  40.      (x) == 0x56 ? 18 : \
  41.      (x) == 0x57 ? 9 : \
  42.      (x) == 0x58 ? 6 : \
  43.      (x) == 0x59 ? 16 : \
  44.      (x) == 0x5a ? 20 : \
  45.      (x) == 0x5b ? 22 : \
  46.      (x) == 0x5c ? 24 : \
  47.      (x) == 0x5d ? 28 : \
  48.      (x) == 0x5e ? 36 : 0)
  49.  
  50. /* translates from sane point sizes into the weird CAT encodings */
  51. #define CAT_ENCODE_SIZE(x) \
  52.     ((x) == 6 ? 0x58 : \
  53.      (x) == 7 ? 0x50 : \
  54.      (x) == 8 ? 0x51 : \
  55.      (x) == 9 ? 0x57 : \
  56.      (x) == 10 ? 0x52 : \
  57.      (x) == 11 ? 0x53 : \
  58.      (x) == 12 ? 0x54 : \
  59.      (x) == 14 ? 0x55 : \
  60.      (x) == 16 ? 0x59 : \
  61.      (x) == 18 ? 0x56 : \
  62.      (x) == 20 ? 0x5a : \
  63.      (x) == 22 ? 0x5b : \
  64.      (x) == 24 ? 0x5c : \
  65.      (x) == 28 ? 0x5d : \
  66.      (x) == 36 ? 0x5e : 0)
  67.  
  68. #define CAT_FLASH_CODE 0x00
  69. #define CAT_FLASH_MASK 0x3f
  70. #define CAT_MAX_FLASH 0x3f
  71. /* nonzero if printable character and zero otherwise */
  72. #define CAT_IS_FLASH(x) (((x) & (CAT_HIGH_NIBBLE << 2)) == CAT_FLASH_CODE)
  73. #define CAT_FLASH(x) ((x) & CAT_MAX_FLASH)
  74. #define CAT_ENCODE_FLASH(n) (CAT_FLASH_CODE | ((n) & CAT_FLASH_MASK))
  75.  
  76. #define CAT_CONTROL_CODE 0x40
  77. /* nonzero if control command and zero otherwise */
  78. #define CAT_IS_CONTROL(x) (((x) & CAT_HIGH_NIBBLE) == CAT_CONTROL_CODE)
  79.  
  80. /* CAT-8 control commands */
  81. #define CAT_INITIALIZE 0x40
  82. #define CAT_LOWER_RAIL 0x41
  83. #define CAT_UPPER_RAIL 0x42
  84. #define CAT_UPPER_MAGAZINE 0x43
  85. #define CAT_LOWER_MAGAZINE 0x44
  86. #define CAT_LOWER_FONT 0x45
  87. #define CAT_UPPER_FONT 0x46
  88. #define CAT_ESCAPE_FORWARD 0x47
  89. #define CAT_ESCAPE_BACKWARD 0x48
  90. #define CAT_STOP 0x49
  91. #define CAT_LEAD_FORWARD 0x4a
  92. #define CAT_LEAD_BACKWARD 0x4c
  93. #define CAT_TILT_UP 0x4e
  94. #define CAT_TILT_DOWN 0x4f
  95. #define CAT_NOOP 0x00
  96. /* trapdoor for CAT extensions */
  97. #define CAT_EXTENSION 0x4b
  98.  
  99. /* CAT_BIG_LEAD means take the next byte * 64 to obtain leading */
  100. #define CAT_BIG_LEAD 0x01
  101. #define CAT_BIG_LEAD_MULTIPLIER 64
  102. #define CAT_MIN_BIG_LEAD (CAT_BIG_LEAD_MULTIPLIER * 0x01)
  103. #define CAT_MAX_BIG_LEAD (CAT_BIG_LEAD_MULTIPLIER * 0xff)
  104.  
  105. /* CAT_BIG_ESCAPE means take the next byte * 128 to obtain escape */
  106. #define CAT_BIG_ESCAPE 0x02
  107. #define CAT_BIG_ESCAPE_MULTIPLIER 128
  108. #define CAT_MIN_BIG_ESCAPE (CAT_BIG_ESCAPE_MULTIPLIER * 0x01)
  109. #define CAT_MAX_BIG_ESCAPE (CAT_BIG_ESCAPE_MULTIPLIER * 0xff)
  110.  
  111. /*
  112.  * CAT_FORMFEED means advance to next page resetting current row
  113.  * and column to <0,0>.
  114.  */
  115. #define CAT_FORMFEED 0x03
  116.  
  117. /*
  118.  * Returns nonzero if a single point size and zero otherwise.
  119.  * The parameter is the `sane' point size and NOT the weird CAT encoding.
  120.  */
  121. #define CAT_IS_SINGLE(p) ((6 <= (p) && (p) <= 14) || (p) == 18)
  122.  
  123. /*
  124.  * Returns nonzero is a double point size and zero otherwise.
  125.  * The parmeter is the `sane' point size and NOT the weird CAT encoding.
  126.  */
  127. #define CAT_IS_DOUBLE(p) ((p) == 16 || (p) >= 20)
  128.  
  129. /*
  130.  * Returns nonzero if the old to new point size transition is a
  131.  * single to double transition and zero otherwise.
  132.  * The parameters are the `sane' point sizes NOT the weird CAT encodings.
  133.  */
  134. #define CAT_IS_SINGLE_TO_DOUBLE(old, new) \
  135.     (CAT_IS_SINGLE(old) && CAT_IS_DOUBLE(new))
  136.  
  137. /*
  138.  * Returns nonzero if the old to new point size transition is a
  139.  * double to single transition and zero otherwise.
  140.  * The parameters are the `sane' point sizes NOT the weird CAT encodings.
  141.  */
  142. #define CAT_IS_DOUBLE_TO_SINGLE(old, new) \
  143.     (CAT_IS_DOUBLE(old) && CAT_IS_SINGLE(new))
  144.  
  145. typedef struct CAT {
  146.     char escape_where;    /* BACKWARD or FORWARD */
  147.     char lead_where;    /* BACKWARD or FORWARD */
  148.     char font;        /* bit 0 => tilt, bit 1 => rail, bit 2 => magazine */
  149.     char font_half;        /* LOWER or UPPER */
  150.     char point_size;    /* current point size */
  151. } CAT;
  152.  
  153. #define CAT_FORWARD 0
  154. #define CAT_BACKWARD 1
  155. #define CAT_UPPER 0
  156. #define CAT_LOWER 1
  157.  
  158. /* vertical resolution per inch */
  159. #define CAT_VERTICAL_UNITS 144.0
  160. /* horizontal resolution per inch */
  161. #define CAT_HORIZONTAL_UNITS 432.0
  162.  
  163. /* compensatory escape for single/double point size transitions */
  164. #define CAT_LENSE_COMPENSATION 55
  165.  
  166. #define CAT_TILT 01
  167. #define CAT_RAIL 02
  168. #define CAT_MAGAZINE 04
  169.  
  170. /* default troff and scribe font mountings for CAT-8 */
  171. #define CAT_ROMAN_FONT 0
  172. #define CAT_ITALIC_FONT 2
  173. #define CAT_BOLD_FONT 4
  174. #define CAT_SPECIAL_FONT 6
  175.  
  176. /* the maximum number of characters on a filmstrip */
  177. #define CAT_MAX_FONT_INDEX 108
  178.