home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / ASM / ASMLIB40.ZIP / ASM4DEMO.ZIP / MODECHNG.ASM < prev    next >
Encoding:
Assembly Source File  |  1994-06-20  |  1.7 KB  |  114 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. extrn    crtinfo:proc, mode43:proc, hram8043:proc
  14. extrn    viewlimit:proc
  15. extrn    svga256:proc
  16.  
  17. .data
  18. public    maxx, maxy
  19. crt    dw 0
  20. maxx    dw 0
  21. maxy    dw 0
  22. nocard    db 'graphics card required',0Dh,0Ah,7,'$'
  23. rows    dw 25
  24. grmode    db 0,0
  25.  
  26. .code
  27. graphmode    proc
  28. ;    mov    ax,3
  29. ;    call    svga256
  30. ;    mov    ah,3
  31. ;    jmp    g10
  32.  
  33.     xor    ah,ah
  34.     call    crtinfo
  35.     mov    rows,ax
  36.     call    getcrt
  37.     mov    crt,ax
  38.     cmp    al,-1
  39.     je    cga
  40.     cmp    al,127
  41.     ja    hercules
  42.     or    al,al
  43.     jnz    evga
  44.  
  45.     or    ah,ah
  46.     jnz    egamono
  47.     lea    dx,nocard    ; point to error message
  48.     jmp    oops        ; exit with CF = 1
  49.  
  50. egamono:mov    ax,000Fh
  51.     int    10h
  52.     mov    ah,07h
  53.     jmp    short g10
  54.  
  55. ; if CGA, use 2-color "high" resolution mode
  56. cga:    mov    ax,6
  57.     push    bp
  58.     int    10h
  59.     pop    bp
  60.     mov    ah,03h
  61.     jmp    short g10
  62.  
  63. ; EGA color, VGA color or MCGA
  64. evga:    add    al,0Fh
  65.     int    10h
  66.     mov    ah,03h
  67.     jmp    short g10
  68.  
  69. hercules:
  70.     call    hgraph0
  71.     mov    ax,0708h
  72.  
  73. g10:    mov    word ptr grmode,ax
  74.     call    viewlimit
  75.     mov    ax,es:[bx]
  76.     mov    maxx,ax
  77.     mov    ax,es:2[bx]
  78.     mov    maxy,ax
  79.     clc
  80.     ret
  81. oops:    stc
  82.     ret
  83. graphmode    endp
  84.  
  85.  
  86. ; use TextMode to return to text mode after calling GraphMode
  87. ; call with: no parameters
  88. ; returns: nothing in particular
  89. ; uses: AX, flags
  90. textmode    proc
  91.     mov    ax,word ptr grmode
  92.     cmp    al,08h
  93.     je    herctext
  94.     mov    al,ah
  95.     xor    ah,ah
  96.  
  97.     push    bp
  98.     int    10h
  99.     pop    bp
  100.     cmp    rows,25
  101.     jbe    t9
  102.     call    mode43
  103. t9:    ret
  104.  
  105. herctext:
  106.     call    htext
  107.     cmp    rows,25
  108.     jbe    t10
  109.     call    hram8043
  110. t10:    ret
  111. textmode    endp
  112.  
  113.     end
  114.