home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / g / gs252src.zip / GS252 / GDEVPCFB.H < prev    next >
C/C++ Source or Header  |  1992-09-18  |  5KB  |  135 lines

  1. /* Copyright (C) 1989, 1992 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20. /* gdevpcfb.h */
  21. /* IBM PC frame buffer definitions for Ghostscript */
  22. /* (requires dos_.h) */
  23.  
  24. /* For testing, the 16-color display may be defined as a monochrome, */
  25. /* 8-color, or 16-color device. */
  26. #define ega_bits_of_color 2        /* 0, 1, or 2 */
  27.  
  28. /* Range of r-g-b values */
  29. #define rgb_max ega_bits_of_color
  30.  
  31. #ifndef USE_ASM
  32. #  define USE_ASM 0            /* don't use assembly language */
  33. #endif
  34.  
  35. /* Define the short (integer) version of "transparent" color. */
  36. /* ****** Depends on gx_no_color_index being all 1's. ******/
  37. #define no_color ((int)gx_no_color_index)
  38.  
  39. /* Procedures */
  40.  
  41.     /* See gxdevice.h for the definitions of the procedures. */
  42.  
  43. extern dev_proc_open_device(ega_open);
  44. extern dev_proc_close_device(ega_close);
  45. extern dev_proc_map_rgb_color(ega_map_rgb_color);
  46. extern dev_proc_map_color_rgb(ega_map_color_rgb);
  47. extern dev_proc_fill_rectangle(ega_fill_rectangle);
  48. extern dev_proc_tile_rectangle(ega_tile_rectangle);
  49. extern dev_proc_copy_mono(ega_copy_mono);
  50. extern dev_proc_copy_color(ega_copy_color);
  51. extern dev_proc_get_bits(ega_get_bits);
  52.  
  53. /* Types for frame buffer pointers. */
  54. /* Note that 'far' gets defined as null on 32-bit systems. */
  55. typedef byte far *fb_ptr;
  56. typedef volatile byte far *volatile_fb_ptr;
  57.  
  58. /* The device descriptor */
  59. typedef struct gx_device_ega_s gx_device_ega;
  60. struct gx_device_ega_s {
  61.     gx_device_common;
  62.     int raster;            /* frame buffer bytes per line */
  63.     int fb_seg_mult;        /* multiplier for segment part */
  64.                     /* of frame buffer pointer */
  65.     int fb_byte_mult;        /* multiplier for word part ditto */
  66. #define mk_fb_ptr(x, y)\
  67.   (fb_dev->fb_byte_mult == 0 ?\
  68.    (fb_ptr)MK_PTR(regen + (y) * (fb_dev->fb_seg_mult), (x) >> 3) :\
  69.    (fb_ptr)MK_PTR(regen + ((y) >> 4) * (fb_dev->fb_seg_mult),\
  70.          (((y) & 15) * fb_dev->fb_byte_mult) + ((x) >> 3)))
  71. /* Define the largest height that can be processed */
  72. /* within a single 64K segment.  If fb_dev->height > max_rop_height, */
  73. /* we may have to break up operations into pieces. */
  74.     unsigned max_rop_height;
  75.     int video_mode;
  76. };
  77.  
  78. /* Macro for creating instances */
  79. /* The initial parameters map an appropriate fraction of */
  80. /* the screen to an 8.5" x 11" coordinate space. */
  81. /* This may or may not be what is desired! */
  82. #define ega_device(dev_name, procs, fb_raster, screen_height, aspect_ratio, video_mode)\
  83.    {    sizeof(gx_device_ega),\
  84.     &procs,\
  85.     dev_name,\
  86.     fb_raster * 8, screen_height,\
  87.       (screen_height * (aspect_ratio)) / 11.0,    /* x density */\
  88.       screen_height / 11.0,        /* y density */\
  89.     no_margins,\
  90.        {    (rgb_max ? 3 : 1),    /* num_components */\
  91.         4,            /* depth */\
  92.         (rgb_max ? rgb_max : 1),    /* gray_max */\
  93.         rgb_max,\
  94.         3,            /* dither_gray */\
  95.         (rgb_max ? rgb_max + 1 : 0)    /* dither_rgb */\
  96.        },\
  97.     0,            /* not opened yet */\
  98.     fb_raster,\
  99.     (fb_raster & 15 ? fb_raster : fb_raster >> 4),\
  100.     (fb_raster & 15 ? fb_raster : 0),\
  101.     ((unsigned)(0xffff - fb_raster) / fb_raster),\
  102.     video_mode\
  103.    }
  104.  
  105. /* Define the device port and register numbers, and the regen map base */
  106. #define out2(port, index, data)\
  107.   (outportb(port, index), outportb((port)+1, data))
  108. #define outin2(port, index)\
  109.   (outportb(port, index), inportb((port)+1))
  110. #define seq_addr 0x3c4
  111. #define s_map 2
  112. #define set_s_map(mask) out2(seq_addr, s_map, mask)
  113. #define graph_addr 0x3ce
  114. #define g_const 0            /* set/reset */
  115. #define set_g_const(color) out2(graph_addr, g_const, color)
  116. #define g_const_map 1            /* enable set/reset */
  117. #define set_g_const_map(map) out2(graph_addr, g_const_map, map)
  118. #define g_function 3
  119. #define set_g_function(func) out2(graph_addr, g_function, func)
  120. #define g_read_plane 4
  121. #define set_g_read_plane(plane) out2(graph_addr, g_read_plane, plane)
  122. #  define gf_WRITE 0
  123. #  define gf_AND 8
  124. #  define gf_OR 0x10
  125. #  define gf_XOR 0x18
  126. #define g_mode 5
  127. #define set_g_mode(mode) out2(graph_addr, g_mode, mode)
  128. #  define gm_DATA 0
  129. #  define gm_FILL 2
  130. #define g_mask 8
  131. #define set_g_mask(mask) out2(graph_addr, g_mask, mask)
  132. #define select_g_mask() outportb(graph_addr, g_mask)
  133. #define out_g_mask(mask) outportb(graph_addr+1, mask)
  134. #define regen 0xa000
  135.