home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_BAS / MONITOR.ZIP / MONITOR.ASM < prev    next >
Assembly Source File  |  1993-09-22  |  6KB  |  166 lines

  1. ;
  2. ; MONITOR.ASM - Copyright (C) 1993 - Tony Doimeadios - All Rights Reserved
  3. ;
  4. ;         Made-----------: 09/22/93
  5. ;         Last Modified--: 09/22/93
  6. ;
  7. ;         This function will return the type of video card in the system.
  8. ;           1 = MCGA Color
  9. ;           2 = MCGA Mono
  10. ;           3 = VGA Color
  11. ;           4 = VGA Mono
  12. ;           5 = EGA
  13. ;           6 = CGA
  14. ;           7 = Hercules
  15. ;           8 = MDA
  16. ;
  17. ;         How to use it:
  18. ;           This function is linked in with QB4.5 or PDS7.1
  19. ;           Declare Function Monitor%()
  20. ;           Print Monitor%
  21. ;           would declare and activate the function.
  22. ;
  23. ;         Technical Details:
  24. ;           I used Turbo Assembler 3.0 to compile this source code.
  25. ;           TASM MONITOR
  26. ;           LIB MONITOR.LIB +MONITOR.OBJ;
  27. ;           LINK /Q /SEG:1024 MONITOR.LIB,,NUL,QBXQLB;
  28. ;           This produces MONITOR.LIB and MONITOR.QLB
  29. ;           To load it into QB/QBX: QBX /L MONITOR
  30. ;
  31. ;
  32. ;
  33. ;
  34. ;         This program is hereby released into the Public Domain.
  35. ;           This program can be freely copied and distributed as
  36. ;           long as the information in this block of comments is
  37. ;           not changed.
  38. ;
  39. ;         If you have any problems, complaints or requests, you can
  40. ;           address them to the author.  I'm always happy to hear
  41. ;           from people that use my programs.
  42. ;            ┌─────────────────────────────────────────────────────┐ 
  43. ;            │ Tony Doimeadios, P.O. Box 431, Brunswick, GA  31521 │
  44. ;            └─────────────────────────────────────────────────────┘
  45.     
  46.     
  47.     DOSSEG
  48.     .MODEL MEDIUM, BASIC
  49.     .DATA
  50.  
  51.     
  52.     .CODE
  53.     mov ax,@Data
  54.     mov ds,ax                   ;set DS to point to the data segment
  55.  
  56.     public Monitor
  57.  
  58.  
  59. ;---------------------------------------------------------------------
  60. Monitor PROC FAR
  61.     
  62.     ;this is a BASIC FUNCTION that returns a number, indicating monitor type
  63.     ;usage--: PRINT Monitor%
  64.     
  65.     mov ax,1A00h                ;function number
  66.     int 10h                     ;call VIDEO BIOS
  67.     cmp al,1Ah                  ;is this a VGA/MCGA system?
  68.     jne TryEGA                  ;nope, go test for EGA
  69.  
  70.  
  71. TryMCGAColor:    
  72.     cmp bl,Ch                   ;see if we're MCGA Color
  73.     jne TryMCGAMono             ;nope, go see if we're MCGA Mono
  74.     xor ax,ax                   ;yes, zero out register
  75.     mov ax,1                    ;put 1 in returned register
  76.     jmp short Done              ;bail out
  77.  
  78.  
  79. TryMCGAMono:
  80.     cmp bl,Bh                   ;see if we're MCGA Mono
  81.     jne TryVGAColor             ;nope, go see if we're VGA Color
  82.     xor ax,ax                   ;yes, zero out register
  83.     mov ax,2                    ;put 2 in returned register
  84.     jmp short Done              ;bail out
  85.  
  86.  
  87. TryVGAColor:
  88.     cmp bl,08h                  ;see if we're VGA Color
  89.     jne TryVGAMono              ;nope, go see if we're VGA Mono
  90.     xor ax,ax                   ;yes, zero out register
  91.     mov ax,3                    ;put 3 in returned register
  92.     jmp short Done              ;bail out
  93.  
  94.  
  95. TryVGAMono:
  96.     cmp bl,07h                  ;see if we're VGA Mono
  97.     jne TryEGA                  ;nope, go see if we're VGA Mono
  98.     xor ax,ax                   ;yes, zero out register
  99.     mov ax,4                    ;put 4 in returned register
  100.     jmp short Done              ;bail out
  101.  
  102.  
  103. TryEGA:
  104.     xor ax,ax                   ;zero out register
  105.     mov ah,12h                  ;function number
  106.     mov bl,10h                  ;request EGA info
  107.     int 10h                     ;call EGA BIOS
  108.     cmp bl,10h                  ;bl will still hold 10h if its not an EGA
  109.     je TryCGA                   ;yes, can't be EGA
  110.     xor ax,ax                   ;no, zero out register
  111.     mov ax,5                    ;put 5 in returned register
  112.     jmp short Done              ;bail out
  113.  
  114.  
  115. TryCGA:
  116.     mov dx,3D4h                 ;point to 6845 address register
  117.     xor ax,ax                   ;zero out register
  118.     mov al,0Fh                  ;request cursor register
  119.     out dx,al                   ;index the register
  120.     inc dx                      ;point to data register
  121.     in al,dx                    ;get current reading
  122.     xchg ah,al                  ;save the value
  123.     mov al,100                  ;use 100 as a test value
  124.     out dx,al                   ;send it
  125.     mov cx,100h                 ;must delay a bit
  126.     Delay: Loop Delay           ;make the delay
  127.     in al,dx                    ;read back the value
  128.     cmp al,100                  ;compare
  129.     jne TryHerc                 ;jump if it changed (no CGA)
  130.     xchg ah,al                  ;CGA is there, so restore original reading
  131.     out dx,al                   ;send it
  132.     xor ax,ax                   ;zero out register
  133.     mov ax,6                    ;put 6 in returned register
  134.     jmp short Done              ;bail out
  135.  
  136.  
  137. TryHerc:                        ;it's monochrome - test for Herc
  138.     mov dx,3BAh                 ;CRT Status
  139.     in al,dx                    ;read the port
  140.     and al,80h                  ;isolate bit 7
  141.     mov bl,al                   ;save the value
  142.     mov cx,8000h                ;ready to loop
  143.     Repeat:in al,dx             ;read the port again
  144.     and al,80h                  ;isolate bit 7
  145.     cmp bl,al                   ;compare to saved value
  146.     loope Repeat                ;repeat if no change
  147.     je MDA                      ;it didn't change - must be MDA
  148.     xor ax,ax                   ;it changed - must be a Herc - zero register
  149.     mov ax,7                    ;put 7 in returned register
  150.     jmp short Done              ;bail out
  151.  
  152.  
  153. MDA:
  154.     xor ax,ax                   ;zero out register
  155.     mov ax,8                    ;put 8 in returned register
  156.  
  157.  
  158. Done:    
  159.     ret                         ;we're thru
  160.  
  161. Monitor ENDP
  162. ;---------------------------------------------------------------------
  163.  
  164.  
  165.     END
  166.