home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / grafik / pmod01 / source / isvesa.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-10  |  2.6 KB  |  92 lines

  1. /****************************************************************************
  2. *
  3. *                          Protected Mode Library
  4. *
  5. *                   Copyright (C) 1994 SciTech Software.
  6. *                            All rights reserved.
  7. *
  8. * Filename:        $RCSfile: isvesa.c $
  9. * Version:        $Revision: 1.1 $
  10. *
  11. * Language:        ANSI C
  12. * Environment:    any
  13. *
  14. * Description:  Test program to check the ability to allocate real mode
  15. *                memory and to call real mode interrupt handlers such as
  16. *                the VESA VBE BIOS from protected mode. Compile and link
  17. *                with the appropriate command line for your DOS extender.
  18. *
  19. *                Functions tested:    PMODE_allocRealSeg()
  20. *                                    PMODE_freeRealSeg()
  21. *                                    PMODE_int86x()
  22. *
  23. * $Id: isvesa.c 1.1 1994/03/10 09:05:43 kjb release $
  24. *
  25. ****************************************************************************/
  26.  
  27. #include <stdlib.h>
  28. #include <stdio.h>
  29. #include <string.h>
  30. #include <mem.h>
  31. #include "pmode.h"
  32.  
  33. /* SuperVGA information block */
  34.  
  35. typedef struct {
  36.     char    VESASignature[4];       /* 'VESA' 4 byte signature          */
  37.     short   VESAVersion;            /* VBE version number               */
  38.     long    OEMStringPtr;           /* Far pointer to OEM string        */
  39.     long    Capabilities;           /* Capabilities of video card       */
  40.     long    VideoModePtr;           /* Far pointer to supported modes   */
  41.     short   TotalMemory;            /* Number of 64kb memory blocks     */
  42.     char    reserved[236];          /* Pad to 256 byte block size       */
  43.     } VgaInfoBlock;
  44.  
  45. void main(void)
  46. {
  47.     RMREGS            regs;
  48.     RMSREGS            sregs;
  49.     VgaInfoBlock    *vgaInfo;
  50.     unsigned long    vgaInfo_segid;
  51.     unsigned        vgaInfo_segment;
  52.     unsigned        vgaInfo_offset;
  53.  
  54.     printf("Program running in ");
  55.     switch (_PMODE_modeType) {
  56.         case PMODE_realMode:
  57.             printf("real mode.\n\n");
  58.             break;
  59.         case PMODE_286:
  60.             printf("16 bit protected mode.\n\n");
  61.             break;
  62.         case PMODE_386:
  63.             printf("32 bit protected mode.\n\n");
  64.             break;
  65.         }
  66.  
  67.     /* Allocate a 256 byte block of real memory for communicating with
  68.      * the VESA BIOS.
  69.      */
  70.  
  71.     vgaInfo = PMODE_allocRealSeg(256, &vgaInfo_segid, &vgaInfo_segment,
  72.         &vgaInfo_offset);
  73.     if (vgaInfo == NULL) {
  74.         fprintf(stderr, "Unable to allocate real mode memory!\n");
  75.         exit(1);
  76.         }
  77.  
  78.     /* Call the VESA VBE to see if it is out there */
  79.  
  80.     regs.x.ax = 0x4F00;
  81.     regs.x.di = vgaInfo_offset;
  82.     sregs.es = vgaInfo_segment;
  83.     PMODE_int86x(0x10, ®s, ®s, &sregs);
  84.     if (regs.x.ax == 0x004F && strncmp(vgaInfo->VESASignature,"VESA",4) == 0) {
  85.         printf("VESA VBE version %d.%d BIOS detected\n",
  86.             vgaInfo->VESAVersion >> 8, vgaInfo->VESAVersion & 0xF);
  87.         }
  88.     else printf("VESA VBE not found\n");
  89.  
  90.     PMODE_freeRealSeg(vgaInfo_segid);
  91. }
  92.