home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 14 / CDACTUAL.iso / cdactual / demobin / share / program / asm / RTGRAF.ZIP / SOURCE.ZIP / EMODE.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-06-30  |  4.3 KB  |  150 lines

  1. ;======================================================================
  2. ; hardware_check ( )
  3. ;
  4. ;      sets :
  5. ;
  6.       Public  _hardware_check
  7.       assume  cs:_text, ds:dgroup, ss:dgroup, es:dgroup
  8.  
  9. _hardware_check  proc far
  10.        push    bp
  11.        mov     bp,sp
  12.        ;
  13.        ;   Look for CGA or below
  14.        push    es                  ; look in the equipment bios byte
  15.        xor     ax,ax
  16.        mov     es,ax               ; segmwnt 0
  17.        mov     bl,es:[0487h]       ; byte 487h is equipment
  18.        pop     es
  19.        mov     ax,1                ; preset in case
  20.        test    bl,08h              ; is bit clear for EGA 0=EGA
  21.        jz      SMEgaOrVga          ; yes look at monitor stuff
  22.        mov     _curr_vid_card,CGA  ;
  23.        jmp     SMhwdone
  24.  
  25. SMEgaOrVga:
  26.        ;
  27.        ;   save away the old mode
  28.        mov     ah,0Fh
  29.        int     10h
  30.        xor     ah,ah
  31.        mov     _prior_vid_mode,ax
  32.  
  33.        ; bios VGA presence test
  34.        mov     bx,0
  35.        mov     ax,1a00h        ; fetch current mode
  36.        int     10h
  37.        cmp     al,1ah          ; VGA will not change it
  38.        jne     SMNoVga
  39.        ;
  40.        ;   Found VGA
  41.        ;
  42.        mov     _curr_vid_card,VGA
  43.        mov     al,bl           ; bl is monitor type
  44.        jmp     SMFoundVid
  45.  
  46. SMNoVga:
  47.        mov     _curr_vid_card,EGA
  48.        mov     ah,12h
  49.        mov     bl,10h
  50.        int     10h
  51.        mov     al,5
  52.        or      bh,bh
  53.        jnz    SMFoundVid
  54.  
  55.        mov     al,3
  56.        cmp     cl,9h
  57.        je      SMFoundVid
  58.  
  59.        cmp     cl,3
  60.        je      SMFoundVid
  61.  
  62.        mov     al,4
  63. SMFoundVid:
  64.        xor     ah,ah
  65.        mov     _curr_vid_mon,ax
  66.        ;
  67.        ;       Monitor type set
  68.        ;           0 = None        3=ECD or MS
  69.        ;           4 = Color       5=Monochrome
  70.        ;           7 = VGA Mono    8=VGA Color or MS
  71. SMhwdone:
  72.        mov     _curr_vid_seg,0a000h  ; set video ram segment to EGA
  73.        mov     ax,_curr_vid_card
  74.        pop     bp
  75.        ret
  76. _hardware_check  endp
  77.  
  78. ;======================================================================
  79. ; setmode(mode);
  80. ;
  81. ; SETMODE --- change the display mode
  82. ;       at entry:       AL =
  83. ;                           10h 640x350 COLOR (ega)
  84. ;                           12h 640x480 COLOR (ega)
  85. ;       globals set:
  86. ;              cur_vid_mode        requested mode
  87. ;              pixels_wide         screen width in pixels
  88. ;              bytes_per_line      video memory bytes per scan line
  89. ;              scan_deep           # of visible scan lines
  90. ;              max_scan_deep       # of video memory scan lines
  91. ;
  92. ;  When setting the mode, anything you pass will be used blindly.
  93. ;  If the value is greater than 13h, it is assumed that you went for
  94. ;  800x600.  This mode uses the same access methods as the classic
  95. ;  EGA/VGA modes.
  96. ;
  97.  
  98. _setmode  proc far
  99.        push    bp
  100.        mov     bp,sp
  101.        ;
  102.        ;   check that the hardware has been checked, if not do it
  103.        cmp     _curr_vid_seg,0
  104.        jne     SMhcdone
  105.        call    _hardware_check
  106. SMhcdone:
  107.        ;
  108.        ;   Now set the desired mode
  109.        ;
  110.        mov     ax,[bp+6]        ; get mode
  111.        mov     ah,0             ; bios int 10 function setmode
  112.        int     10h
  113.        ;
  114.        ;   save away the new mode
  115.        ;
  116.        mov     ah,0Fh
  117.        int     10h               ; what does the system say ??
  118.        xor     ah,ah
  119.        mov     _curr_vid_mode,ax
  120.        cmp     al,13h            ; kludge- >13h is assumed to be
  121.        jg      SM800x600         ;    800x600, same algor. as others
  122.        ;
  123.        ;   assume this is a standard EGA/VGA mode of 640 wide
  124.        ;
  125.        mov     _pixels_wide,640
  126.        mov     _bytes_per_line,80
  127.        mov     _max_scan_deep,819
  128.        cmp     al,10h
  129.        jne     SMnot10
  130.        mov     _scan_deep,350
  131.        jmp     SMallDone
  132. SMnot10:
  133.        cmp     al,12h
  134.        jne     SMnot12
  135.        mov     _scan_deep,480
  136.        jmp     SMallDone
  137. SMnot12:
  138.        mov     _scan_deep,0         ; you set this value
  139.        jmp     SMallDone
  140. SM800x600:
  141.        mov     _pixels_wide,800
  142.        mov     _bytes_per_line,100
  143.        mov     _scan_deep,600
  144.        mov     _max_scan_deep,655
  145. SMAllDone:
  146.        mov     sp,bp
  147.        pop     bp
  148.        ret
  149. _setmode  endp
  150.