home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / SVGALIB / SVGALIB1.TAR / svgalib / src / interface.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-21  |  1.6 KB  |  62 lines

  1.  
  2. #include "stdlib.h"
  3.  
  4. #include "timing.h"
  5. #include "ramdac.h"
  6. #include "accel.h"
  7. #include "libvga.h"    /* for __svgalib_infotable */
  8.  
  9.  
  10. /*
  11.  * This is a temporary function that allocates and fills in a ModeInfo
  12.  * structure based on a svgalib mode number.
  13.  */
  14.  
  15. ModeInfo *createModeInfoStructureForSvgalibMode( int mode ) {
  16.     ModeInfo *modeinfo;
  17.     /* Create the new ModeInfo structure. */
  18.     modeinfo = malloc(sizeof(ModeInfo));
  19.     modeinfo->width = __svgalib_infotable[mode].xdim;
  20.     modeinfo->height = __svgalib_infotable[mode].ydim;
  21.     modeinfo->bytesPerPixel = __svgalib_infotable[mode].bytesperpixel;
  22.     switch (__svgalib_infotable[mode].colors) {
  23.     case 16 : modeinfo->colorBits = 4; break;
  24.     case 256 : modeinfo->colorBits = 8; break;
  25.     case 32768 : modeinfo->colorBits = 15; break;
  26.     case 65536 : modeinfo->colorBits = 16; break;
  27.     case 256 * 65536 : modeinfo->colorBits = 24; break;
  28.     }
  29.     modeinfo->bitsPerPixel = modeinfo->bytesPerPixel * 8;
  30.     if (__svgalib_infotable[mode].colors == 16)
  31.         modeinfo->bitsPerPixel = 4;
  32.     modeinfo->lineWidth = __svgalib_infotable[mode].xbytes;
  33.     return modeinfo;
  34. }
  35.  
  36.  
  37. /*
  38.  * This function converts a number of significant color bits to a matching
  39.  * DAC mode type as defined in the RAMDAC interface.
  40.  */
  41.  
  42. int colorbits_to_colormode( int colorbits ) {
  43.     if (colorbits == 8)
  44.         return CLUT8_6;
  45.     if (colorbits == 15)
  46.         return RGB16_555;
  47.     if (colorbits == 16)
  48.         return RGB16_565;
  49.     if (colorbits == 24)
  50.         return RGB32_888_B;
  51.     return CLUT8_6;
  52. }
  53.  
  54.  
  55. /*
  56.  * Clear the accelspecs structure (disable acceleration).
  57.  */
  58.  
  59. void clear_accelspecs( AccelSpecs *accelspecs ) {
  60.     accelspecs->operations = 0;
  61. }
  62.