home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / asmlib.zip / MODECHNG.ASM < prev    next >
Assembly Source File  |  1992-05-25  |  1KB  |  89 lines

  1. ; MODECHNG.ASM - Sample program for ASMLIB graphics
  2. ; Programmer: Douglas Herr
  3. ; date: 5/24/1992
  4.  
  5. ; detect video equipment and switch to highest resolution mode available
  6. ; does not attempt to detect non-default monitor or SVGA or VESA equipment
  7.  
  8. include    asm.inc
  9.  
  10. public    graphmode, textmode
  11.  
  12. extrn    getcrt:proc, hgraph0:proc, htext:proc
  13.  
  14. .data
  15. crt    dw 0
  16. nocard    db 'graphics card required',0Dh,0Ah,7,'$'
  17.  
  18. grmode    db 0,0
  19.  
  20. .code
  21. graphmode    proc
  22.     call    getcrt
  23.     mov    crt,ax
  24.     cmp    al,-1
  25.     je    cga
  26.     cmp    al,127
  27.     ja    hercules
  28.     or    al,al
  29.     jnz    evga
  30.  
  31.     or    ah,ah
  32.     jnz    egamono
  33.     lea    dx,nocard    ; point to error message
  34.     jmp    oops        ; exit with CF = 1
  35.  
  36. egamono:mov    ax,000Fh
  37.     int    10h
  38.     mov    ah,07h
  39.     jmp    short g10
  40.  
  41. ; if CGA, use 2-color "high" resolution mode
  42. cga:    mov    ax,6
  43.     push    bp
  44.     int    10h
  45.     pop    bp
  46.     mov    ah,03h
  47.     jmp    short g10
  48.  
  49. ; EGA color, VGA color or MCGA
  50. evga:    add    al,0Fh
  51.     int    10h
  52.     mov    ah,03h
  53.     jmp    short g10
  54.  
  55. hercules:
  56.     call    hgraph0
  57.     mov    ax,0708h
  58.  
  59. g10:    mov    word ptr grmode,ax
  60.     clc
  61.     ret
  62. oops:    stc
  63.     ret
  64. graphmode    endp
  65.  
  66.  
  67. ; use TextMode to return to text mode after calling GraphMode
  68. ; call with: no parameters
  69. ; returns: nothing in particular
  70. ; uses: AX, flags
  71. textmode    proc
  72.     mov    ax,word ptr grmode
  73.     cmp    al,08h
  74.     je    herctext
  75.     mov    al,ah
  76.     xor    ah,ah
  77.  
  78.     push    bp
  79.     int    10h
  80.     pop    bp
  81.     ret
  82.  
  83. herctext:
  84.     call    htext
  85.     ret
  86. textmode    endp
  87.  
  88.     end
  89.