home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / graphics / vesa24_2.zip / VESAINF.CPP < prev    next >
C/C++ Source or Header  |  1993-04-09  |  3KB  |  102 lines

  1. /******************************* vesainf.cpp ********************************/
  2. /*    Author: Don Lewis                                                       */
  3. /*  Date:   February 22, 1993                                               */
  4. /* Description:                                                             */
  5. /*                This set of routines is the VESA interface. It allows       */
  6. /*              access to VESA functions and information.           */
  7. /****************************************************************************/
  8.  
  9. #include <stdio.h>
  10. #include <dos.h>
  11. #include <process.h>
  12. #include <string.h>
  13. #include "vheader.h" /* VESA, PCX and TARGA header info. */
  14.  
  15.  
  16. #define VIDEO 0x10
  17.  
  18. struct VgaInfoBlock info;
  19. struct ModeInfoBlock modeinfo;
  20. struct REGPACK reg;
  21.  
  22. ReturnCurrentMode(int curmode);
  23. int VesaFunctions(void);
  24. void SetSvgaMode(int);
  25. void GetSvgaInfo(void);
  26. void ReturnSvgaMode(int);
  27. void tone(void);        /* I threw this in for fun */
  28.  
  29.  
  30. void VesaFunctions(int NewMode)
  31. {
  32.    SetSvgaMode (NewMode); /* use vga24.asm init function */
  33.    GetSvgaInfo();     /* retrieves all kinda good info */
  34.    ReturnSvgaMode(NewMode); /* retrieves even more great stuff */
  35. }
  36. /* Get SVGA VESA information and pass back to VgaInfoBlock structure */
  37. void GetSvgaInfo(void)
  38. {
  39.     reg.r_ax = 0x4F00;
  40.     reg.r_es = FP_SEG(&info);
  41.     reg.r_di = FP_OFF(&info);
  42.     intr(VIDEO, ®);
  43.  
  44.     if (reg.r_ax != 0x004f) {
  45.     printf("Current configuration does not support GetSvgaInfo .\n");
  46.     exit(1);
  47.     }
  48. }
  49. /* Get SVGA MODE information and return to ModeInfoBlock structure */
  50. void ReturnSvgaMode(int nmode)
  51. {
  52.     memset(&modeinfo, '\0', 256);
  53.     reg.r_ax = 0x4F01;
  54.     reg.r_cx = nmode;
  55.     reg.r_es = FP_SEG(&modeinfo);
  56.     reg.r_di = FP_OFF(&modeinfo);
  57.     intr(VIDEO, ®);
  58.  
  59.     if (reg.r_ax != 0x004f) {
  60.     printf("Current configuration does not support ReturnSvgaMode.\n");
  61.     exit(1);
  62.     }
  63. }
  64.  
  65. /* Sets the video card to VESA mode if it is supported */
  66. void SetSvgaMode(int nmode)
  67. {
  68.     reg.r_ax = 0x4F02;
  69.     reg.r_bx = nmode;
  70.     intr(VIDEO, ®);
  71.  
  72.     if (reg.r_ax != 0x004f) {
  73.     printf("Configuration does not support VESA set VGA mode 0x%xh\n",
  74.             nmode);
  75.     exit(1);
  76.     }
  77. }
  78. /* like it says, Returns the video mode currently in use. */
  79. ReturnCurrentMode(int curmode)
  80. {
  81.     reg.r_ax = 0x4F03;
  82.     intr(VIDEO, ®);
  83.  
  84.     if (reg.r_ax != 0x004f) {
  85.     printf("Return current video mode failed!\n");
  86.     exit(1);
  87.     }
  88.     curmode = reg.r_bx;
  89.     return(curmode);
  90. }
  91. /* Generate an attention sound. */
  92. void tone(void)
  93. {
  94.     int i;
  95.     for (i=440; i<=3520; i+=880)
  96.     {
  97.        sound(i);
  98.        delay(100);
  99.        nosound();
  100.     }
  101. }
  102.