postbgi.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*
  2. *
  3. * BGI opcodes.
  4. *
  5. */
  6. #define BRCHAR 033 /* rotated character mode */
  7. #define BCHAR 034 /* graphical character mode */
  8. #define BGRAPH 035 /* graphical master mode */
  9. #define BSUB 042 /* subroutine definition */
  10. #define BRET 043 /* end of subroutine */
  11. #define BCALL 044 /* subroutine call */
  12. #define BEND 045 /* end page */
  13. #define BERASE 046 /* erase - obsolete */
  14. #define BREP 047 /* repeat */
  15. #define BENDR 050 /* end repeat */
  16. #define BSETX 051 /* set horizontal position */
  17. #define BSETY 052 /* set vertical position */
  18. #define BSETXY 053 /* set horizontal and vertical positions */
  19. #define BINTEN 054 /* intensify - mark current pixel */
  20. #define BVISX 055 /* manhattan vector - change x first */
  21. #define BINVISX 056 /* same as BVISX but nothing drawn */
  22. #define BVISY 057 /* manhattan vector - change y first */
  23. #define BINVISY 060 /* same as BVISY but nothing drawn */
  24. #define BVEC 061 /* arbitrary long vector */
  25. #define BSVEC 062 /* arbitrary short vector */
  26. #define BRECT 063 /* outline rectangle */
  27. #define BPOINT1 064 /* point plot - mode 1 */
  28. #define BPOINT 065 /* point plot - mode 2 */
  29. #define BLINE 066 /* line plot */
  30. #define BCSZ 067 /* set character size */
  31. #define BLTY 070 /* select line type */
  32. #define BARC 071 /* draw circular arc */
  33. #define BFARC 072 /* filled circular arc */
  34. #define BFRECT 073 /* filled rectangle */
  35. #define BRASRECT 074 /* raster rectangle */
  36. #define BCOL 075 /* select color */
  37. #define BFTRAPH 076 /* filled trapezoid */
  38. #define BPAT 077 /* pattern are for filling - no info */
  39. #define BNOISE 0 /* from bad file format */
  40. /*
  41. *
  42. * Character size is controlled by the spacing of dots in a 5x7 dot matrix, which
  43. * by default is set to BGISIZE.
  44. *
  45. */
  46. #define BGISIZE 2 /* default character grid spacing */
  47. /*
  48. *
  49. * Definitions used to decode the bytes read from a BGI file.
  50. *
  51. */
  52. #define CHMASK 0177 /* characters only use 7 bits */
  53. #define DMASK 077 /* data values use lower 6 bits */
  54. #define MSB 0100 /* used to check for data or opcode */
  55. #define SGNB 040 /* sign bit for integers */
  56. #define MSBMAG 037 /* mag of most sig byte in a BGI int */
  57. /*
  58. *
  59. * Descriptions of BGI vectors and what's done when they're drawn.
  60. *
  61. */
  62. #define X_COORD 0 /* change x next in manhattan vector */
  63. #define Y_COORD 1 /* same but y change comes next */
  64. #define LONGVECTOR 2 /* arbitrary long vector */
  65. #define SHORTVECTOR 3 /* components given in 6 bits */
  66. #define VISIBLE 0 /* really draw the vector */
  67. #define INVISIBLE 1 /* just move the current position */
  68. /*
  69. *
  70. * What's done with a closed path.
  71. *
  72. */
  73. #define OUTLINE 0 /* outline the defined path */
  74. #define FILL 1 /* fill it in */
  75. /*
  76. *
  77. * BGI line style definitions. They're used as an index into the STYLES array,
  78. * which really belongs in the prologue.
  79. *
  80. */
  81. #define SOLID 0
  82. #define DOTTED 1
  83. #define SHORTDASH 2
  84. #define DASH 3
  85. #define LONGDASH 4
  86. #define DOTDASH 5
  87. #define THREEDOT 6
  88. #define STYLES \
  89. \
  90. { \
  91. "[]", \
  92. "[.5 2]", \
  93. "[2 4]", \
  94. "[4 4]", \
  95. "[8 4]", \
  96. "[.5 2 4 2]", \
  97. "[.5 2 .5 2 .5 2 4 2]" \
  98. }
  99. /*
  100. *
  101. * Three constants used to choose which component (RED, GREEN, or BLUE) we're
  102. * interested in. BGI colors are specified as a single data byte and pulling a
  103. * particular component out of the BGI color byte is handled by procedure
  104. * get_color().
  105. *
  106. */
  107. #define RED 0
  108. #define GREEN 1
  109. #define BLUE 2
  110. /*
  111. *
  112. * An array of type Disp is used to save the horizontal and vertical displacements
  113. * that result after a subroutine has been called. Needed so we can properly adjust
  114. * our horizontal and vertical positions after a subroutine call. Entries are made
  115. * immediately after a subroutine is defined and used after the call. Subroutine
  116. * names are integers that range from 0 to 63 (assigned in the BG file) and the
  117. * name is used as an index into the Disp array when we save or retrieve the
  118. * displacement.
  119. *
  120. */
  121. typedef struct {
  122. int dx; /* horizontal and */
  123. int dy; /* vertical displacements */
  124. } Disp;
  125. /*
  126. *
  127. * An array of type Fontmap helps convert font names requested by users into
  128. * legitimate PostScript names. The array is initialized using FONTMAP, which must
  129. * end with and entry that has NULL defined as its name field.
  130. *
  131. */
  132. typedef struct {
  133. char *name; /* user's font name */
  134. char *val; /* corresponding PostScript name */
  135. } Fontmap;
  136. #define FONTMAP \
  137. \
  138. { \
  139. "R", "Courier", \
  140. "I", "Courier-Oblique", \
  141. "B", "Courier-Bold", \
  142. "CO", "Courier", \
  143. "CI", "Courier-Oblique", \
  144. "CB", "Courier-Bold", \
  145. "CW", "Courier", \
  146. "PO", "Courier", \
  147. "courier", "Courier", \
  148. "cour", "Courier", \
  149. "co", "Courier", \
  150. NULL, NULL \
  151. }
  152. /*
  153. *
  154. * Two macros that are useful in processing BGI files:
  155. *
  156. * MAG(A, B) - Takes bytes A and B which have been read from a BGI file
  157. * and returns the magnitude of the integer represented by
  158. * the two bytes.
  159. *
  160. * LINESPACE(A) - Takes BGI size A and returns the number of address units
  161. * that can be used for a reasonable interline spacing.
  162. *
  163. */
  164. #define MAG(A, B) (((A & MSBMAG) << 6) | (B & DMASK))
  165. #define LINESPACE(A) (8 * A)
  166. /*
  167. *
  168. * Some of the non-integer valued functions in postdmd.c.
  169. *
  170. */
  171. char *get_font();