home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_02 / 2n02024a < prev    next >
Text File  |  1990-12-17  |  2KB  |  64 lines

  1. #include <dos.h>
  2. #include "defs.h"
  3.  
  4. extern UCHAR _far *BiosData;      /* pointer to BIOS data area */
  5. extern UCHAR _far *BiosFontPtr;   /* pointer to BIOS char font */
  6. extern UCHAR _far *BottomOfMemory;/* pointer to DOS zero       */
  7. extern UINT  DOS_Extender;
  8.  
  9. #define BIOS_FONT_OFFSET  ((UINT)(4 * 0x43))
  10.  
  11. void SetVideoMode(int mode)
  12. {
  13.    UCHAR flag_mask;
  14.    union REGS regs;
  15. #if defined(_I386) || defined(_I486) || defined(__386__)
  16.    ULONG BiosFontVector;
  17. #else
  18.    ULONG _far *BiosFontVector;
  19. #endif
  20.  
  21.    if (mode < 0)
  22.       return;
  23.    if (mode == 7 || mode == 15)
  24.       flag_mask = 0x30;
  25.    else if (mode < 2)
  26.       flag_mask = 0x10;
  27.    else
  28.       flag_mask = 0x20;
  29.    *(BiosData + 0x0010) &= 0xCF;     
  30.    *(BiosData + 0x0010) |= flag_mask;
  31.    regs.x.AX  =  mode;               
  32.    int86(0x10, ®s, ®s);   
  33. #if defined(_I386) || defined(_I486) || defined(__386__)
  34.    if (DOS_Extender == PHARLAP_386 || DOS_Extender == ERGO_OS386)
  35.       {
  36.       BiosFontVector = *(ULONG _far *)(BottomOfMemory + BIOS_FONT_OFFSET);
  37.       BiosFontPtr    = BottomOfMemory + (UINT)RFP_LINEAR(BiosFontVector);
  38.       }
  39. #else
  40.    if (DOS_Extender == ERGO_OS286)
  41.       {
  42.       BiosFontVector = (ULONG _far *)(BottomOfMemory + BIOS_FONT_OFFSET);
  43.       FP_MAK(BiosFontPtr, *((UINT _far *)BiosFontVector), FP_SEG(BiosFontPtr));
  44.       }
  45.    else /* DOS Real Mode */
  46.       {
  47.       FP_MAK(BiosFontVector, BIOS_FONT_OFFSET, 0x0);
  48.       BiosFontPtr = *(UCHAR _far * _far *)BiosFontVector;
  49.       }
  50. #endif
  51.    return;
  52. }
  53.  
  54.  
  55. int GetVideoMode(void)
  56. {
  57.     union REGS regs;
  58.  
  59.     regs.x.AX = 0x0F00;
  60.     int86(0x10, ®s, ®s);
  61.     return(regs.x.AX & 0x7F);
  62. }
  63.  
  64.