home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / cdactual / demobin / share / program / Pascal / BGI256.ZIP / TRIDENT.INC < prev    next >
Encoding:
Text File  |  1992-12-27  |  5.3 KB  |  189 lines

  1. ;TRIDENT.INC - Writen by Erik Olbrys
  2. ;    History:
  3. ;        July 14, 1991 - first release
  4. ;        22 Nov 1992   - Adapted by Knight Software for protected mode
  5. ;
  6. ;----------------------------------------------------------------------
  7. ;Determine what sort of card is out there
  8. ;Assumed: DS=data segment
  9. ;Entry:   N/A
  10. ;Return:  Correct procedure pointers installed
  11. ;Destroy: AX
  12.  
  13. DetectCard PROC NEAR
  14.     PUSH    ES                      ;check if this is a Trident
  15.     PUSH    BX
  16.  
  17.     MOV    BX,DS:[SEGA000]        ;init video segment/selector
  18.     MOV    DS:[VideoSegment],BX
  19.  
  20. noncr:  mov     dx,3c4h                 ;Test for Trident
  21.     mov     al,0bh
  22.     out     dx,al           ;out(3c4,0b)
  23.     inc     dl
  24.     in      al,dx           ;al:=inp(3c5)
  25.     cmp     al,06h
  26.     ja      notri           ;if al>6
  27.     cmp     al,2
  28.     jb      notri           ;if al<2
  29.  
  30.     JAE     @IsTrident              ;yup, so go init it
  31.  
  32. notri:  MOV     AX,1                    ;bummer, it ain't so error out
  33.     MOV     DS:[NumberModes],AX        ;set number modes available
  34.     LEA     BX,VGABankSelect        ;set bank select proc pointer
  35.     MOV     DS:[BankSelectProc],BX
  36.  
  37.     LEA     BX,VGA320x200Init       ;we do all this so as to
  38.     MOV     DS:[InitDisplayProc],BX    ;keep things in some 
  39.     LEA     BX,DummyCard            ;form of order to prevent
  40.     MOV     DS:[CardNamePtr],BX        ;nasty things from happening
  41.     MOV     BX,64                   ;we are just telling the code
  42.     MOV     DS:[WinGran],BX            ;that we have a simple VGA 
  43.     MOV     AH,grNotDetected        ;or MCGA card set to mode 13H
  44.     MOV     DS:[StatBlock.stat],AH     ;then set no detect error
  45.     MOV    BYTE PTR DS:[ModeSelect],0 ;force mode to 0
  46.     OR      AX,255
  47.     JMP     @DetectExit
  48.  
  49. @IsTrident:
  50.     MOV     AX,MaxModes             ;set number modes available
  51.     MOV     DS:[NumberModes],AX
  52.     LEA     BX,TRBankSelect         ;set bank select proc pointer
  53.     MOV     DS:[BankSelectProc],BX
  54.  
  55.     MOV     AL,DS:[ModeSelect]
  56.     AND     AX,7
  57.     LEA     BX,TRModeProcTable      ;set display init proc pointer
  58.     ADD     BX,AX
  59.     ADD     BX,AX
  60.     MOV     BX,CS:[BX]
  61.     MOV     DS:[InitDisplayProc],BX
  62.     LEA     BX,TRname
  63.     MOV     DS:[CardNamePtr],BX        ;set up pointer to card name
  64.     MOV     BX,64
  65.     MOV     DS:[WinGran],BX            ;set window granularity
  66.     XOR     AX,AX
  67. @DetectExit:
  68.     POP     BX
  69.     POP     ES
  70.     RET
  71. DetectCard ENDP
  72.  
  73. MaxModes EQU 5  ;max number modes available for Trident
  74.  
  75. TRModeProcTable:
  76.     DW      VGA320x200Init          ;table of init proc ptrs
  77.     DW      TRvga640x400Init        ;for the various modes
  78.     DW      TRvga640x480Init 
  79.     DW      TRvga800x600Init 
  80.     DW      TRvga1024x768Init       ;Requires 1 meg ram
  81.  
  82.     DW      VGA320x200Init          ;dummy excess mode selects
  83.     DW      VGA320x200Init          ;to fill out to 8 positions
  84.     DW      VGA320x200Init 
  85.  
  86. TRname:
  87.     DB 8            ;name length
  88.     DB ' Trident',0 ;Card name preceeded with space
  89.             ;and taged with a zero
  90.  
  91. ;----------------------------------------------------------------------
  92. ;Select TRvga640x400 mode operation
  93. ;Assumed: DS=data segment
  94. ;Entry:   N/A
  95. ;Return:  Correct display mode selected
  96. ;Destroy: AX,BX
  97.  
  98. TRvga640x400Init PROC NEAR
  99.     mov     ax,5ch
  100.     INT     10H                     ;call BIOS to set the mode
  101.     XOR     AX,AX
  102.     RET
  103. TRvga640x400Init ENDP
  104.  
  105. ;----------------------------------------------------------------------
  106. ;Select TRvga640x480 mode operation
  107. ;Assumed: DS=data segment
  108. ;Entry:   N/A
  109. ;Return:  Correct display mode selected
  110. ;Destroy: AX,BX
  111.  
  112. TRvga640x480Init PROC NEAR
  113.     mov     ax,5dh
  114.     INT     10H                     ;call BIOS to set the mode
  115.     XOR     AX,AX
  116.     RET
  117. TRvga640x480Init ENDP
  118.  
  119. ;----------------------------------------------------------------------
  120. ;Select TRvga800x600 mode operation
  121. ;Assumed: DS=data segment
  122. ;Entry:   N/A
  123. ;Return:  Correct display mode selected
  124. ;Destroy: AX,BX
  125.  
  126. TRvga800x600Init PROC NEAR
  127.     mov     ax, 5eh
  128.     INT     10H                     ;call BIOS to set the mode
  129.     XOR     AX,AX
  130.     RET
  131. TRvga800x600Init ENDP
  132.  
  133. ;----------------------------------------------------------------------
  134. ;Select TRvga1024x768 mode operation
  135. ;Assumed: DS=data segment
  136. ;Entry:   N/A
  137. ;Return:  Correct display mode selected
  138. ;Destroy: AX,BX
  139.  
  140. TRvga1024x768Init PROC NEAR
  141.     mov     ax,62h
  142.     INT     10H                     ;call BIOS to set the mode
  143.     XOR     AX,AX
  144.     RET
  145. TRvga1024x768Init ENDP
  146.  
  147. ;----------------------------------------------------------------------
  148. ;Trident Bank select routines - We assume that full memory is
  149. ;available if you try to access it.
  150. ;Assumed: DS=data segment
  151. ;Entry:   DX = Bank to select
  152. ;Return:  Display Bank is selected
  153. ;Destroy: nothing
  154.  
  155. TRBankSelect PROC NEAR
  156.     PUSH    DX
  157.     PUSH    AX
  158.     CLI
  159.     mov     DS:[curbank],dx
  160.     mov     dx,3ceh                 ;set pagesize to 64k
  161.     mov     al,6
  162.     out     dx,al           ;out(03ce,6)
  163.     inc     dl
  164.     in      al,dx           ;inp
  165.     dec     dl
  166.     or      al,4
  167.     mov     ah,al
  168.     mov     al,6
  169.     out     dx,ax           ;out(03ce,6)
  170.  
  171.     mov     dl,0c4h                 ;switch to BPS mode
  172.     mov     al,0bh
  173.     out     dx,al           ;out(03ce,0b)
  174.     inc     dl
  175.     in      al,dx           ;inp
  176.     dec     dl
  177.  
  178.     mov     ah,byte ptr DS:[curbank]
  179.     xor     ah,2
  180.     mov     dx,3c4h
  181.     mov     al,0eh
  182.     out     dx,ax           ;out(03c4,0e)
  183.     sti
  184.     POP    AX
  185.     POP    DX
  186.     ret
  187. TRBankSelect ENDP
  188.  
  189.