home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR2 / DVPG30FS.ZIP / SVGAMODE.ASM < prev    next >
Assembly Source File  |  1993-12-04  |  5KB  |  224 lines

  1.  
  2.     include model.h
  3.  
  4. ;
  5. ;    VGAKIT Version 4.1
  6. ;
  7. ;    Copyright 1988,89,90,91 John Bridges
  8. ;    Free for use in commercial, shareware or freeware applications
  9. ;
  10. ;    SVGAMODE.ASM
  11. ;
  12. ;
  13. .data
  14.     extrn    cirrus:byte,everex:byte,paradise:byte,tseng:byte,trident:byte
  15.     extrn    t8900:byte,ativga:byte,aheada:byte,aheadb:byte
  16.     extrn    oaktech:byte,video7:byte,chipstech:byte,tseng4:byte,genoa:byte
  17.     extrn    ncr:byte,compaq:byte,vesa:byte
  18.     extrn    vga512:byte,vga1024:byte
  19.  
  20.     extrn    curbk:word
  21.     extrn vesashift:byte
  22.  
  23.     public    maxx,maxy,xwidth
  24.  
  25. maxx    dw    ?        ;xwidth of screen in pixels
  26. maxy    dw    ?        ;height of screen in pixels
  27. xwidth        dw    ?        ;actual xwidth of screen in bytes
  28. BIOSmode        db 0    ; the BIOS text mode # that was being used when the program was started
  29. fifty_lines dw 0    ; flag to indicate if 50 line mode was originally used
  30.  
  31. .code
  32.  
  33.     public    svgamode
  34.     public    txtmode
  35.     public    setmany
  36.     public    get_video
  37.     public    rtn_video
  38.  
  39. svgamode proc vid_mode:word, bx_reg:word, max_x:word, vid_card:word        ;Set SVGA mode
  40.     push    di
  41.     push    es
  42.     mov ax, [vid_mode]
  43.     and ax, 0fff0h        ; strip off last nibble (has info needed )
  44.     cmp ax, 0fff0h        ;the Tseng card has to be called in two steps ie set mode then set 15 bit DAC
  45.     jz  right_one
  46.     mov ax, [vid_mode]
  47.     jmp no_patch
  48. ;    cmp ax, 10f0h
  49. ;    jnz no_patch
  50. right_one:
  51.     mov bx, [vid_mode]
  52.     and bx, 0007h
  53.     mov ax, 10f2h
  54.     int 10h
  55.     mov ax, 10f0h
  56. no_patch:
  57.     mov bx, [bx_reg]
  58.  
  59.     int    10h
  60.  
  61.     mov    [curbk],-1
  62.     mov    ax, [max_x]
  63.     mov    [maxx],ax        ;default xwidth to whatever for now
  64.     mov    [xwidth],ax
  65.  
  66. ; If it was VESA then find the granularity and other info
  67. ;
  68.     mov    ax, [vid_card]
  69.     cmp   ax, 15
  70.     jnz    all_done
  71.  
  72.     sub    sp, 260        ; space to get VESA info + 4 byte buffer (needed)
  73.     push    ss
  74.     pop    es        ; setup ES:DI with pointer to the 256 byte space
  75.     mov    di, sp
  76.     mov    cx, [bx_reg]
  77.     mov    ax, 4f01h        ; get VESA info
  78.     int    10h
  79.     mov    cx, es:[di+4]    ; the WinGranularity info
  80.  
  81.     mov        al,1
  82.     cmp        cx,0                ; Some BIOS'S fuck this up!
  83.     je        @@NoDivide
  84.     mov        ax,64
  85.     div        cl
  86. @@NoDivide:
  87.     mov     [vesashift],al        ; Save the granularity scale factor
  88.  
  89.     mov     cx, es:[di+10h]     ; VESA bytes per line
  90.     mov ax, [max_x]
  91.     shr ax,1                    ; set ax = 1/2 expected line width in bytes
  92.     cmp     cx,ax        ; if the returned width is > this then it may be right so use it
  93.     jae     no_modify
  94.     jmp skip_modify
  95. no_modify:
  96.     mov    [maxx],cx
  97.     mov    [xwidth],cx
  98. skip_modify:
  99.  
  100. ; *****************************************
  101. ;mov al, 0
  102. ; *****************************************
  103.  
  104. ;    mov    [vesashift], al
  105.  
  106.  
  107.     add    sp, 260            ; clear the temp space on the stack
  108.  
  109. all_done:
  110. ;    mov    ax,40h
  111. ;    mov    es,ax
  112. ;    mov    al,es:[84h]        ;get height of screen
  113. ;    inc    al
  114. ;    mul    byte ptr es:[85h]
  115. ;    mov    [maxy],ax
  116.  
  117.     pop    es
  118.     pop    di
  119.     ret
  120. svgamode endp
  121.  
  122.  
  123.  
  124. ;
  125. ; return to the textmode
  126. ;
  127.  
  128. txtmode    proc
  129.     mov    ax,3
  130.     int    10h
  131.     ret
  132. txtmode    endp
  133.  
  134.  
  135.  
  136. setmany proc    palbuf:ptr byte,begcol:word,numcol:word
  137. if @Datasize
  138.     les    dx,[palbuf]
  139. else
  140.     mov    ax,ds
  141.     mov    es,ax
  142.     mov    dx,[palbuf]
  143. endif
  144.     mov    bx,[begcol]
  145.     mov    cx,[numcol]
  146.     mov    ax,1012h
  147.     int    10h
  148.     ret
  149. setmany endp
  150.  
  151.  
  152. ;
  153. ;  Return the video mode to that which was in use when the program was first run
  154. ;
  155. ; this is from svgakit version 3.2
  156. ;
  157. ;
  158.  
  159. rtn_video proc
  160.     push    bp                    ; INT 10h kills bp sometimes
  161.     push    si                    ; Save regs
  162.     push    di
  163.  
  164.     mov        ah,0                ; Set video mode service
  165.     mov        al,[BIOSmode]    ; Get old BIOS mode number
  166.     int        10h                    ; Set the video mode
  167.  
  168.     cmp        [fifty_lines],0        ; Was 50 line mode set?
  169.     je        @@Exit                ; No, don't set it up
  170.  
  171. ; Load video BIOS 8x8 characters into alphanumeric character generator
  172.  
  173.     mov        ax,1112h            ; AH := INT 10h function number
  174.                                     ; AL := 8x8 character set load
  175.     mov        bl,0                ; BL := block to load
  176.     int        10h                    ; load 8x8 characters into RAM
  177.  
  178. @@Exit:
  179.     pop        di                    ; Restore regs
  180.     pop        si
  181.     pop        bp                    ; Restore bp
  182.     ret
  183. rtn_video endp
  184.  
  185.  
  186. ;
  187. ;  store the video mode to that which was in use when the program was first run
  188. ;
  189. ; returns: 1 if 50 line mode was achieved by 8 * 8 character set; 0 otherwise
  190. ;
  191. ; this is from svgakit version 3.2
  192. ;
  193. ;
  194.  
  195. get_video proc
  196.     push    bp
  197.     push    si
  198.     push    di
  199.     mov        ah,0Fh                ; Get current video mode service
  200.     int        10h
  201.     and     al,7Fh
  202.     mov     [BIOSmode],al    ; Save old video mode
  203.     mov        [fifty_lines],0        ; Default to non-50 line mode
  204.  
  205.     mov        ax,1130h            ; AH := INT 10h function number
  206.                                     ; AL := Get character gen information
  207.     mov        bh,00                ; Get contents of INT 1Fh
  208.     xor        dl,dl                ; Clear dl
  209.     int        10h                    ; Determine number of lines (in dl)
  210.     cmp        dl,49                ; 50 line mode?
  211.     jne        @@SetMode            ; No, must have been 25 lines
  212.     mov        [fifty_lines],1        ; Yes, 50 line mode was on
  213. @@SetMode:
  214.     pop    di
  215.     pop    si
  216.     pop    bp
  217.  
  218.     mov    ax, [fifty_lines]
  219.     ret
  220. get_video endp
  221.  
  222.     end
  223.  
  224.