home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / WINER.ZIP / MONITOR.BAS < prev    next >
BASIC Source File  |  1993-05-23  |  2KB  |  76 lines

  1. '********** MONITOR.BAS - shows how to detect the display adapter type
  2.  
  3. 'Copyright (c) 1992 Ethan Winer
  4.  
  5. DEFINT A-Z
  6.  
  7. DECLARE SUB INTERRUPT (IntNum, InRegs AS ANY, OutRegs AS ANY)
  8. DECLARE FUNCTION Monitor% (Segment)
  9.  
  10. TYPE RegType
  11.   AX    AS INTEGER
  12.   BX    AS INTEGER
  13.   CX    AS INTEGER
  14.   DX    AS INTEGER
  15.   BP    AS INTEGER
  16.   SI    AS INTEGER
  17.   DI    AS INTEGER
  18.   Flags AS INTEGER
  19. END TYPE
  20. DIM SHARED InRegs AS RegType, OutRegs AS RegType
  21.  
  22. SELECT CASE Monitor%(Segment)
  23.   CASE 1
  24.     PRINT "Monochrome";
  25.   CASE 2
  26.     PRINT "Hercules";
  27.   CASE 3
  28.     PRINT "CGA";
  29.   CASE 4
  30.     PRINT "EGA";
  31.   CASE 5
  32.     PRINT "VGA";
  33.   CASE ELSE
  34.     PRINT "Unknown";
  35. END SELECT
  36. PRINT " monitor at segment &H"; HEX$(Segment)
  37.  
  38. FUNCTION Monitor% (Segment) STATIC
  39.  
  40.   DEF SEG = 0                       'first see if it's color or mono
  41.   Segment = &HB800                  'assume color
  42.  
  43.   IF PEEK(&H463) = &HB4 THEN
  44.  
  45.     Segment = &HB000                'assign the monochrome segment
  46.     Status = INP(&H3BA)             'get the current video status
  47.     FOR X = 1 TO 30000              'test for a Hercules 30000 times
  48.       IF INP(&H3BA) <> Status THEN
  49.         Monitor% = 2                'the port changed, it's a Herc
  50.         EXIT FUNCTION               'all done
  51.       END IF
  52.     NEXT
  53.     Monitor% = 1                    'it's a plain monochrome
  54.  
  55.   ELSE                              'it's some sort of color monitor
  56.  
  57.     InRegs.AX = &H1A00              'first test for VGA
  58.     CALL INTERRUPT(&H10, InRegs, OutRegs)
  59.     IF (OutRegs.AX AND &HFF) = &H1A THEN
  60.       Monitor% = 5                  'it's a VGA
  61.       EXIT FUNCTION                 'all done
  62.     END IF
  63.  
  64.     InRegs.AX = &H1200              'now test for EGA
  65.     InRegs.BX = &H10
  66.     CALL INTERRUPT(&H10, InRegs, OutRegs)
  67.     IF (OutRegs.BX AND &HFF) = &H10 THEN
  68.       Monitor% = 3                  'if BL is still &H10 it's a CGA
  69.     ELSE
  70.       Monitor% = 4                  'otherwise it's an EGA
  71.     END IF
  72.  
  73.   END IF
  74.  
  75. END FUNCTION
  76.