home *** CD-ROM | disk | FTP | other *** search
/ World of Graphics / WOGRAPH.BIN / 435.SV_PAGE.ASM < prev    next >
Assembly Source File  |  1993-03-07  |  11KB  |  375 lines

  1. ;****************************************************************************
  2. ;*
  3. ;*                        MegaGraph Graphics Library
  4. ;*
  5. ;*                  Copyright (C) 1993 Kendall Bennett.
  6. ;*                            All rights reserved.
  7. ;*
  8. ;* Filename:    $RCSfile: sv_page.asm $
  9. ;* Version:        $Revision: 1.1 $
  10. ;*
  11. ;* Language:    80386 Assembler
  12. ;* Environment:    IBM PC (MS DOS)
  13. ;*
  14. ;* Description:    This source file contains the code needed to change display
  15. ;*                pages on supported SuperVGA adapters, along with tables to
  16. ;*                find the correct routines for a specified video card.
  17. ;*
  18. ;*                Not all SuperVGA's support extended page flipping, so
  19. ;*                unsupported cards are marked in the table.
  20. ;*
  21. ;* $Id: sv_page.asm 1.1 1993/03/03 10:27:23 kjb Exp $
  22. ;*
  23. ;* Revision History:
  24. ;* -----------------
  25. ;*
  26. ;* $Log: sv_page.asm $
  27. ;* Revision 1.1  1993/03/03  10:27:23  kjb
  28. ;* Initial revision
  29. ;*
  30. ;****************************************************************************
  31.  
  32. ; Table of SuperVGA page flipping routines by video card. Unsupported cards
  33. ; are marked with a NONE_page.
  34.  
  35. SVGAPage:        dw    VESA_page        ; VESA SuperVGA
  36.                 dw    ATI_page        ; ATI Technologies SuperVGA (NONE)
  37.                 dw    NONE_page        ; AHEAD A SuperVGA (NONE)
  38.                 dw    AHEADB_page        ; AHEAD B SuperVGA
  39. CHIPSPageOfs    dw    CHIPS_page        ; Chips & Technologies SuperVGA
  40. EVEREXPageOfs    dw    NONE_page        ; Everex SuperVGA (NONE)
  41.                 dw    NONE_page        ; Genoa Systems SuperVGA (NONE)
  42.                 dw    NONE_page        ; OAK Technologies SuperVGA (NONE)
  43.                 dw    PARADISE_page    ; Paradise SuperVGA
  44.                 dw    TRIDENT88_page    ; Trident 8800 SuperVGA
  45.                 dw    TRIDENT89_page    ; Trident 8900 SuperVGA
  46.                 dw    VIDEO7_page        ; Video7 SuperVGA
  47.                 dw    ET3000_page        ; Tseng Labs ET3000 SuperVGA
  48.                 dw    ET4000_page        ; Tseng Labs ET4000 SuperVGA
  49.                 dw    NCR_page        ; NCR 77C22E SuperVGA
  50.                 dw    S3_page            ; S3 SuperVGA
  51.                 dw    NONE_page        ; AcuMos SuperVGA
  52.                 dw    NONE_page        ; AL2101 SuperVGA
  53.                 dw    NONE_page        ; MXIC SuperVGA
  54.                 dw    P2000_page        ; P2000 SuperVGA
  55.                 dw    NONE_page        ; RT3106 SuperVGA
  56.                 dw    CIRRUS_page        ; Cirrus 5422 SuperVGA
  57.  
  58. NewPage        dw    NONE_page        ; Address of page flipping routine
  59. BankOffset    dw    0                ; Current bank offset for visible page
  60.  
  61. ;----------------------------------------------------------------------------
  62. ; SetupPaging    Setup the SuperVGA extended page flipping routines
  63. ;----------------------------------------------------------------------------
  64. ;
  65. ; Given the id of the SuperVGA card that is installed, this routine sets
  66. ; up the following extended page flipping code.
  67. ;
  68. ; Exit:            CF = 1 if paging not supported on adapter
  69. ;
  70. ; Registers:    AX,CX,SI,DI
  71. ;
  72. ;----------------------------------------------------------------------------
  73. PROC    SetupPaging    near
  74.  
  75.         mov        [NewPage],offset NONE_page
  76.         mov        [BankOffset],0
  77.         mov        ax,[CntDriver]
  78.         cmp        ax,grSVGA
  79.         jl        @@Invalid            ; Not a SuperVGA adapter
  80.         je        @@VESASuperVGA        ; We have a VESA SuperVGA adapter
  81.  
  82.         mov        si,offset SVGAPage
  83.         mov        ax,[CntDriver]        ; AX := number of current driver
  84.         sub        ax,grSVGA            ; Adjust to start at 0 for SVGA's
  85.         shl        ax,1
  86.         add        si,ax                ; SI := index into table of SVGA banks
  87.         mov        ax,[cs:si]            ; Load page flip routine address
  88.         mov        [NewPage],ax        ; and save it for later
  89.  
  90.         cmp        ax,offset NONE_page
  91.         jz        @@Invalid            ; Paging not supported on this adapter
  92.         clc
  93.         jmp        @@Exit
  94.  
  95. ; We have a VESA SuperVGA adapter, so determine if extended page flipping
  96. ; is supported by the video BIOS.
  97.  
  98. @@VESASuperVGA:
  99.         call    checkVESAPageFlip
  100.         jc        @@Exit                ; No page flipping available
  101.  
  102. ; Horrah! We have page flipping on a VESA board.
  103.  
  104.         mov        ax,offset VESA_page    ; Setup for VESA page flipping
  105.         mov        [NewPage],ax
  106.         clc
  107.         jmp        @@Exit
  108.  
  109. @@Invalid:
  110.         stc
  111.  
  112. @@Exit:
  113.         ret
  114.  
  115. ENDP    SetupPaging
  116.  
  117. ;----------------------------------------------------------------------------
  118. ; NewPage    Set the visible page start address.
  119. ;----------------------------------------------------------------------------
  120. ;
  121. ; Program the start address for the appropriate video cards. If the card
  122. ; is not a SuperVGA, we simply set the lower 16 bits of the start address,
  123. ; otherwise we also set the top bits for the SuperVGA adapter.
  124. ;
  125. ; Note that interrupts will be off when these routines are called.
  126. ;
  127. ; These routines assumes that access to the SuperVGA's extended registers
  128. ; has already been set up (if required).
  129. ;
  130. ; Entry:        BL    - Index of start address low register
  131. ;                BH    - Bits 7-0 of new start address
  132. ;                CL    - Index of start address high register
  133. ;                CH    - Bits 15-8 of new start address
  134. ;                SI    - Bits 16+ for new start address
  135. ;
  136. ; Registers:    AX,BX,CX,DX,SI
  137. ;
  138. ;----------------------------------------------------------------------------
  139.  
  140. ; Macro to set the low start address bits, and to load BX with the
  141. ; top bits for SuperVGA adapters.
  142.  
  143. MACRO    SetLowStartAddress
  144.         mov        dx,03D4h            ; DX := CRTC I/O port (3D4h)
  145.         mov        ax,bx
  146.         out        dx,ax
  147.         mov        ax,cx
  148.         out        dx,ax
  149.         mov        bx,si                ; BX := Bits 16+ for start address
  150. ENDM
  151.  
  152. NONE_page:
  153.         SetLowStartAddress
  154.         ret
  155.  
  156. VESA_page:
  157.         mov        cl,bh                ; CX := Bits 15-0 of start address
  158.         mov        ax,cx
  159.         mov        dx,si                ; DX:AX := start address
  160.         div        [BytesPerLine]        ; Divide by bytes per line value
  161.         mov        cx,dx
  162.         cmp        [CntColors],gr16Color
  163.         jne        @@V1
  164.         shl        cx,3                ; CX := leftmost pixel in scanline
  165. @@V1:    mov        dx,ax                ; DX := starting scanline number
  166.         mov        ax,4F07h            ; Set display start service
  167.         xor        bx,bx
  168.         int        10h                    ; Set the display start address
  169.         ret
  170.  
  171. ATI_page:
  172.         SetLowStartAddress
  173.         mov        dx,1CEh
  174.         mov        al,0B0h                ; Index of start address register
  175.         out        dx,al
  176.         inc        dx
  177.         in        al,dx                ; Read old value
  178.         and        al,3Fh                ; Mask out old bits 7-6
  179.         and        bl,3                ; Mask out bottom two bits
  180.         shl        bl,6                ; Shift into position
  181.         or        al,bl                ; Combine the values
  182.         out        dx,al                ; Output the result
  183.         ret
  184.  
  185. AHEADB_page:
  186.         SetLowStartAddress
  187.         mov        dx,03CEh
  188.         mov        al,01Ch
  189.         out        dx,al                ; Index the start address register
  190.         inc        dx
  191.         in        al,dx                ; Read current value
  192.         and        al,0FCh                ; Mask out old address values
  193.         and        bl,3                ; Mask out bottom two bits
  194.         or        al,bl                ; Or in the new start address
  195.         out        dx,al                ; Output the address
  196.         ret
  197.  
  198. CHIPS_page:
  199.         SetLowStartAddress
  200.         mov        dx,03D6h
  201.         mov        al,0Ch
  202.         mov        ah,bl
  203.         out        dx,ax                ; Set the extended start address
  204.         mov        al,04h
  205.         out        dx,al                ; Index memory map register
  206.         inc        dx
  207.         in        al,dx                ; Read register value
  208.         or        al,4                ; Set bit 2 for extended paging
  209.         out        dx,al                ; Set the value
  210.         ret
  211.  
  212. PARADISE_page:
  213.         SetLowStartAddress
  214.         mov        dx,03CEh
  215.         mov        al,0Dh
  216.         out        dx,al                ; Index PR3 CRT Control register
  217.         inc        dx
  218.         in        al,dx                ; Read current value
  219.         and        al,0E7h                ; Zero out bits 4-3
  220.         and        bl,3                ; Mask out bottom 2 bits
  221.         shl        bl,3                ; Shift into correct position
  222.         or        al,bl                ; Or in the new start address
  223.         out        dx,al                ; Output the address
  224.         ret
  225.  
  226. TRIDENT88_page:
  227.         SetLowStartAddress
  228.         mov        dx,3D4h                ; DX := CRTC I/O port
  229.         mov        al,01Eh
  230.         out        dx,al                ; Index module testing register
  231.         inc        dx
  232.         in        al,dx                ; Read current value
  233.         and        al,0DFh                ; Mask out start address bit 5
  234.         and        bl,1                ; Only want one bit
  235.         shl        bl,5                ; Put into correct position
  236.         or        al,bl               ; Or in the new start address
  237.         or        al,80h                ; Set bit 7 for enable bit 16
  238.         out        dx,al                ; Output the address
  239.         ret
  240.  
  241. TRIDENT89_page:
  242.         SetLowStartAddress
  243.         push    bx
  244.         mov        dx,3D4h                ; DX := CRTC I/O port
  245.         mov        al,01Eh
  246.         out        dx,al                ; Index module testing register
  247.         inc        dx
  248.         in        al,dx                ; Read current value
  249.         and        al,05Fh                ; Mask out start address
  250.         and        bl,1                ; Only want one bit
  251.         shl        bl,5                ; Put into correct position
  252.         or        al,bl                ; Or in new start address values
  253.         or        al,80h                ; Set bit 7 for enable bit 16
  254.         out        dx,al                ; Output the address
  255.         mov        dx,3C4h
  256.         mov        al,0Bh
  257.         out        dx,al
  258.         inc        dl
  259.         xor        al,al
  260.         out        dx,al                ; Select old mode control registers
  261.         dec        dl
  262.         mov        al,0Eh                ; Index old mode control register
  263.         out        dx,al
  264.         inc        dl
  265.         in        al,dx                ; Read old value
  266.         and        al,0FEh             ; Mask out old value
  267.         pop        bx
  268.         shr        bl,1
  269.         and        bl,1                  ; Mask out only bit 17 of address
  270.         or        al,bl               ; Combine with old value
  271.         out        dx,al                ; Output the address
  272.         ret
  273.  
  274. VIDEO7_page:
  275.         SetLowStartAddress
  276.         mov        dx,3C4h
  277.         mov        al,0F6h
  278.         out        dx,al                ; Index extended start address
  279.         inc        dx
  280.         in        al,dx                ; Read current value
  281.         and        al,0CFh                ; Zero out start address 17-16 bit 5-4
  282.         and        bl,3                ; Mask out all but bottom 2 bits
  283.         shl        bl,4                ; Shift left into correct position
  284.         or        al,bl                ; Or in the new start address
  285.         out        dx,al                ; Output the address
  286.         ret
  287.  
  288. ET3000_page:
  289.         SetLowStartAddress
  290.         mov        dx,3D4h                ; DX := CRTC I/O port
  291.         mov        al,23h                ; Index extended start address
  292.         out        dx,al
  293.         inc        dx
  294.         in        al,dx                ; Read current value
  295.         and        al,0FDh                ; Zero out start address
  296.         and        bl,1                ; Only one bit is valid
  297.         shl        bl,1                ; Put bit into correct pos.
  298.         or        al,bl                ; Or in the new start address
  299.         out        dx,al                ; Output the address
  300.         ret
  301.  
  302. ET4000_page:
  303.         SetLowStartAddress
  304.         mov        dx,3D4h                ; DX := CRTC I/O port
  305.         mov        al,33h                 ; Index extended start address
  306.         out        dx,al
  307.         inc        dx
  308.         in        al,dx                ; Read current value
  309.         and        al,0FCh                ; Zero out start address
  310.         and        bl,3                  ; Mask out all but bottom 2 bits
  311.         or        al,bl                ; Or in new start address
  312.         out        dx,al                ; Output the address
  313.         ret
  314.  
  315. NCR_page:
  316.         SetLowStartAddress
  317.         mov        dx,3C4h
  318.         mov        al,31h                ; Index of start address register
  319.         out        dx,al
  320.         inc        dx
  321.         in        al,dx                ; Read old value
  322.         and        al,0F0h                ; Clear bottom three bits
  323.         and        bl,0Fh                ; Mask out bottom four bits
  324.         or        al,bl
  325.         out        dx,al                ; Set the new value
  326.         ret
  327.  
  328. S3_page:
  329.         SetLowStartAddress
  330.         mov        dx,3D4h                ; DX := CRTC I/O port
  331.         mov        ax,4838h            ; Enable extended registers
  332.         out        dx,ax
  333.         mov        al,31h                ; Index of S3R1
  334.         out        dx,al
  335.         inc        dl
  336.         in        al,dx                ; Read old value of S3R1
  337.         and        al,0CFh                ; Mask off bits 5-4
  338.         shl        bl,4                ; Shift into bit pos 5-4
  339.         or        al,bl                ; Or in starting address value
  340.         out        dx,al                ; Set the new value
  341.         dec        dl
  342.         mov        ax,0038h            ; Disable extended registers
  343.         out        dx,ax
  344.         ret
  345.  
  346. P2000_page:
  347.         SetLowStartAddress
  348.         mov        dx,3CEh
  349.         mov        al,21h                ; Index of start address register
  350.         out        dx,al
  351.         inc        dx
  352.         in        al,dx                ; Read old value
  353.         and        al,0F8h                ; Clear out bottom 3 bits
  354.         and        bl,7                ; Mask off bottom three bits
  355.         or        al,bl                ; Or in starting address value
  356.         out        dx,al                ; Set the new value
  357.         ret
  358.  
  359. CIRRUS_page:
  360.         SetLowStartAddress
  361.         mov        dx,3D4h                ; DX := CRTC I/O port
  362.         mov        al,1Bh                ; Index of start address register
  363.         out        dx,al
  364.         inc        dx
  365.         in        al,dx                ; Read old value
  366.         and        al,0FAh                ; Clear out bits 0 and 2
  367.         mov        bh,bl
  368.         and        bh,2                ; BH := bit 17 of start address
  369.         shl        bh,1                ; BH := bit 17 in bit pos 2
  370.         and        bl,1                ; BL := bit 16 of start address
  371.         or        bl,bh                ; BL := combined bit 16 and bit 17
  372.         or        al,bl                ; Or in starting address value
  373.         out        dx,al                ; Set the new value
  374.         ret
  375.