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

  1. ;  modified quite a bit by Eric Praetzel
  2. ;
  3. ; removed the memory bank-switching routines because that is set seperately
  4. ; memory tests removed because the code was big enough to cross a bank boundary
  5. ; hi_color flag is not being set yet by tseng or ATI
  6. ; moved video testing routines to vidtest.asm
  7.  
  8.     include  model.h
  9.  
  10. ;
  11. ;  from VGAKIT Version 4.1
  12. ;
  13. ;  Copyright 1988,89,90,91 John Bridges
  14. ;  Free for use in commercial, shareware or freeware applications
  15. ;
  16. ;  BANKS.ASM
  17. ;
  18. .data
  19.  
  20. OSEG  equ   DS:      ;segment override for variable access
  21.  
  22. extrn bankadr:word
  23. ;if @Codesize
  24. extrn bankseg:word
  25. ;endif
  26.  
  27.     public retval
  28.  
  29. extrn curbk:word
  30.  
  31. extrn vga512:word
  32. extrn vga1024:word
  33.  
  34.  
  35. extrn video_resolution:word
  36. extrn cirrus:word
  37. extrn everex:word
  38. extrn paradise:word
  39. extrn tseng:word
  40. extrn trident:word
  41. extrn t8900:word
  42. extrn ativga:word
  43. extrn aheada:word
  44. extrn aheadb:word
  45. extrn oaktech:word
  46. extrn video7:word
  47. extrn chipstech:word
  48. extrn tseng4:word
  49. extrn genoa:word
  50. extrn ncr:word
  51. extrn compaq:word
  52. extrn vesa:word
  53.  
  54. first    dw ?     ;flag so whichvga() is only called once
  55. retval   dw ?     ;first return value from whichvga()
  56. extrn ati_extended:word  ;ati extended reg. location
  57.  
  58. vgainfo  label word
  59. vesaid   db 'VESA'      ; 4 signature bytes
  60. vesaver  dw ?     ; VESA version number
  61. oemstr   dd ?     ; Pointer to OEM string
  62. capabil  db 4 dup (?)   ; Capabilities of the video environment
  63. modelst  dd ?     ; Pointer to supported Super VGA modes
  64.  
  65. extrn vesashift:byte   ; number of bits to shift bank number left
  66.  
  67. .code
  68.  
  69.     public   whichvga
  70.  
  71.  
  72. nojmp macro
  73.     local lbl
  74.     jmp   lbl
  75. lbl:
  76.     endm
  77.  
  78.  
  79.  
  80. whichvga proc  uses si di
  81.     local vesabuf[256]:byte
  82.  
  83.     cmp   [first],'FI'
  84.     jnz   gotest
  85.     mov   ax,[retval]
  86.     ret
  87. gotest:
  88. ;    mov   [bankadr],offset _nobank
  89. ;if @Codesize
  90. ;    mov   [bankseg],seg _nobank
  91. ;endif
  92.     xor   ax,ax
  93.     mov   [curbk],ax
  94.     mov   [vga512],ax
  95.     mov   [vga1024],ax
  96.     mov   [cirrus],ax
  97.     mov   [everex],ax
  98.     mov   [paradise],ax
  99.     mov   [tseng],ax
  100.     mov   [trident],ax
  101.     mov   [t8900],ax
  102.     mov   [ativga],ax
  103.     mov   [aheada],ax
  104.     mov   [aheadb],ax
  105.     mov   [oaktech],ax
  106.     mov   [video7],ax
  107.     mov   [chipstech],ax
  108.     mov   [tseng4],ax
  109.     mov   [genoa],ax
  110.     mov   [ncr],ax
  111.     mov   [compaq],ax
  112.     mov   [vesa],ax
  113.     mov   [first],'FI'
  114.  
  115.     mov   ax,ss
  116.     mov   es,ax
  117.     lea   di,vesabuf[0]
  118.     mov   ax,4f00h
  119.     int   10h
  120.     cmp   ax,4fh
  121.     jnz   novesa
  122.     lea   si,vesabuf[0]
  123.     mov   di,offset vgainfo
  124.     mov   ax,ds
  125.     mov   es,ax
  126.     push  ds
  127.     mov   ax,ss
  128.     mov   ds,ax
  129.     mov   cx,7
  130.     cld
  131.     rep   movsw
  132.     pop   ds
  133. mov vesa, 1
  134. ;    bkadr vesa
  135.     mov   [vga512],1
  136. ;    mov   [vga1024],1
  137.     jmp   fini
  138.  
  139. novesa:  mov   si,1
  140.     mov   ax,0c000h
  141.     mov   es,ax
  142.     cmp   word ptr es:[40h],'13'  ;ATI Signiture on the Video BIOS
  143.     jnz   noati
  144. mov ativga, 1
  145. ;    bkadr ativga
  146.  
  147.     mov   ax, 0c000h     ; find the location of the ATI extended reg
  148.     mov   es, ax
  149.     mov   bx, 10h
  150.     mov   dx, es:[bx] ; fetch the extended reg value
  151.     mov   [ati_extended], dx
  152.  
  153.     cli
  154.     mov   dx,1ceh
  155.     mov   al,0bbh
  156.     out   dx,al
  157.     inc   dl
  158.     in    al,dx
  159.     sti
  160.     and   al,20h
  161.     jz    no512
  162.     mov   [vga512],1
  163. no512:
  164.         jmp   fini
  165.  
  166. noati:   mov   ax,7000h    ;Test for Everex
  167.     xor   bx,bx
  168.     cld
  169.     int   10h
  170.     cmp   al,70h
  171.     jnz   noev
  172. mov everex, 1
  173. ;    bkadr everex
  174.     and   ch,11000000b      ;how much memory on board
  175.     jz skp
  176.     mov   [vga512],1
  177. skp:              ;fall through for Everex boards using Trident or Tseng4000
  178.  
  179. noev: mov   ax,0bf03h      ;Test for Compaq
  180.     xor   bx,bx
  181.     mov   cx,bx
  182.     int   10h
  183.     cmp   ax,0bf03h
  184.     jnz   nocp
  185.     test  cl,40h         ;is 640x480x256 available?
  186.     jz nocp
  187. mov compaq, 1
  188. ;    bkadr compaq
  189.     mov   [vga512],1
  190.     jmp   fini
  191.  
  192. nocp: mov   dx,3c4h        ;Test for NCR 77C22E
  193.     mov   ax,0ff05h
  194.     call  _isport2
  195.     jnz   noncr
  196.     mov   ax,5        ;Disable extended registers
  197.     out   dx,ax
  198.     mov   ax,0ff10h      ;Try to write to extended register 10
  199.     call  _isport2    ;If it writes then not NCR
  200.     jz noncr
  201.     mov   ax,105h        ;Enable extended registers
  202.     out   dx,ax
  203.     mov   ax,0ff10h
  204.     call  _isport2
  205.     jnz   noncr       ;If it does NOT write then not NCR
  206. mov ncr, 1
  207. ;    bkadr ncr
  208.     mov   [vga512],1
  209.     jmp   fini
  210.  
  211. noncr:   mov   dx,3c4h        ;Test for Trident
  212.     mov   al,0bh
  213.     out   dx,al
  214.     inc   dl
  215.     in al,dx
  216.     cmp   al,06h
  217.     ja notri
  218.     cmp   al,2
  219.     jb notri
  220. mov trident, 1
  221. ;    bkadr trident
  222.     cmp   al,3
  223.     jb no89
  224.     mov   [t8900],1
  225.     mov   dx,3d5h
  226.     mov   al,1fh
  227.     out   dx,al
  228.     inc   dx
  229.     in al,dx
  230.     and   al,3
  231.     cmp   al,1
  232.     jb notmem
  233.     mov   [vga512],1
  234.     je notmem
  235. ;    mov   [vga1024],1            don't assume 1M since the card is probably old
  236. notmem:  jmp   fini
  237.  
  238. no89:
  239.     mov   [vga512],1
  240.     jmp   fini
  241.  
  242. notri:   mov   ax,6f00h    ;Test for Video 7
  243.     xor   bx,bx
  244.     cld
  245.     int   10h
  246.     cmp   bx,'V7'
  247.     jnz   nov7
  248. mov video7, 1
  249. ;    bkadr video7
  250.     mov   ax,6f07h
  251.     cld
  252.     int   10h
  253.     and   ah,7fh
  254.     cmp   ah,1
  255.     jbe   skp2
  256.     mov   [vga512],1
  257. skp2: cmp   ah,3
  258.     jbe   skp3
  259.     mov   [vga1024],1
  260. skp3: jmp   fini
  261.  
  262. nov7: mov   dx,3d4h        ;Test for GENOA GVGA
  263.     mov   ax,032eh    ;check for Herchi Register
  264.     call  _isport2
  265.     jnz   nogn
  266.     mov   dx,3c4h        ;check for memory segment register
  267.     mov   ax,3f06h
  268.     call  _isport2
  269.     jnz   nogn
  270. mov genoa, 1
  271. ;    bkadr genoa
  272.     mov   [vga512],1
  273.     jmp   fini
  274.  
  275. nogn: call  _cirrus        ;Test for Cirrus
  276.     cmp   [cirrus],0
  277.     je noci
  278.     jmp   fini
  279.  
  280. noci: mov   dx,3ceh        ;Test for Paradise
  281.     mov   al,9        ;check Bank switch register
  282.    out   dx,al
  283.    inc   dx
  284.    in al,dx
  285.     dec   dx
  286.    or al,al
  287.    jnz   nopd
  288.  
  289.    mov   ax,50fh        ;turn off write protect on VGA registers
  290.    out   dx,ax
  291.    mov   dx,offset _pdrsub
  292.    mov   cx,1
  293.    call  _chkbk
  294.     jc nopd        ;if bank 0 and 1 same not paradise
  295. mov paradise, 1
  296. ;    bkadr paradise
  297.     mov   dx,3ceh
  298.     mov   al,0bh         ;512k detect from Bob Berry
  299.     out   dx,al
  300.     inc   dx
  301.     in al,dx
  302.     test  al,80h         ;if top bit set then 512k
  303.     jz nop512
  304.     mov   [vga512],1
  305. nop512:  jmp   fini
  306.  
  307. nopd: mov   ax,5f00h    ;Test for Chips & Tech
  308.     xor   bx,bx
  309.     cld
  310.     int   10h
  311.     cmp   al,5fh
  312.     jnz   noct
  313. mov chipstech, 1
  314. ;    bkadr chipstech
  315.     cmp   bh,1
  316.     jb skp4
  317.     mov   [vga512],1
  318. skp4: jmp   fini
  319.  
  320. noct: mov   ch,0
  321.     mov   dx,3d4h        ;check for Tseng 4000 series
  322.     mov   ax,0f33h
  323.     call  _isport2
  324.     jnz   not4
  325.     mov   ch,1
  326.  
  327.     mov   dx,3bfh        ;Enable access to extended registers
  328.     mov   al,3
  329.     out   dx,al
  330.     mov   dx,3d8h
  331.     mov   al,0a0h
  332.     out   dx,al
  333.     jmp   short yes4
  334.  
  335. not4: mov   dx,3d4h        ;Test for Tseng 3000 or 4000
  336.     mov   ax,1f25h    ;is the Overflow High register there?
  337.     call  _isport2
  338.     jnz   nots
  339.     mov   al,03fh        ;bottom six bits only
  340.     jmp   short yes3
  341. yes4: mov   al,0ffh
  342. yes3: mov   dx,3cdh        ;test bank switch register
  343.     call  _isport1
  344.     jnz   nots
  345. mov tseng, 1
  346. ;    bkadr tseng
  347.     cmp   ch,0
  348.     jnz   t4mem
  349.     mov   [vga512],1
  350.     jmp   fini
  351.  
  352. t4mem:   mov   dx,3d4h        ;Tseng 4000 memory detect 1meg
  353.     mov   al,37h
  354.     out   dx,al
  355.     inc   dx
  356.     in al,dx
  357.     test  al,1000b    ;if using 64kx4 RAMs then no more than 256k
  358.     jz nomem
  359.     and   al,3
  360.     cmp   al,1        ;if 8 bit wide bus then only two 256kx4 RAMs
  361.     jbe   nomem
  362.     mov   [vga512],1
  363.     cmp   al,2        ;if 16 bit wide bus then four 256kx4 RAMs
  364. ;    je nomem
  365. ;    mov   [vga1024],1    ;full meg with eight 256kx4 RAMs
  366. nomem:
  367. mov tseng4, 1
  368. ;   bkadr tseng4
  369.     jmp   short fini
  370.  
  371. nots:
  372.     mov   dx,3ceh        ;Test for Above A or B chipsets
  373.     mov   ax,200fh
  374.     out   dx,ax
  375.     inc   dx
  376.     nojmp
  377.     in al,dx
  378.     cmp   al,21h
  379.     jz verbt
  380.     cmp   al,20h
  381.     jnz   noab
  382. mov aheada, 1
  383. ;    bkadr aheada
  384.     mov   [vga512],1
  385.     jmp   short fini
  386.  
  387. verbt:
  388. mov aheadb, 1
  389. ;    bkadr aheadb
  390.     mov   [vga512],1
  391.     jmp   short fini
  392.  
  393.  
  394. noab: mov   dx,3deh        ;Test for Oak Technology
  395.     mov   ax,0ff11h      ;look for bank switch register
  396.     call  _isport2
  397.     jnz   nooak
  398. mov oaktech, 1
  399. ;   bkadr oaktech
  400.     mov   al,0dh
  401.     out   dx,al
  402.     inc   dx
  403.     nojmp
  404.     in al,dx
  405.     test  al,80h
  406.     jz no4ram
  407.     mov   [vga512],1
  408. no4ram:  jmp   short fini
  409.  
  410. nooak:   mov   si,0
  411.  
  412. fini: mov   ax,si
  413.     mov   [retval],ax
  414.     ret
  415. whichvga endp
  416.  
  417.  
  418. _cirrus  proc  near
  419.     mov   dx,3d4h     ; assume 3dx addressing
  420.     mov   al,0ch      ; screen a start address hi
  421.     out   dx,al    ; select index
  422.     inc   dx    ; point to data
  423.     mov   ah,al    ; save index in ah
  424.     in al,dx    ; get screen a start address hi
  425.     xchg  ah,al    ; swap index and data
  426.     push  ax    ; save old value
  427.     push  dx    ; save crtc address
  428.     xor   al,al    ; clear crc
  429.     out   dx,al    ; and out to the crtc
  430.  
  431.     mov   al,1fh      ; Eagle ID register
  432.     dec   dx    ; back to index
  433.     out   dx,al    ; select index
  434.     inc   dx    ; point to data
  435.     in al,dx    ; read the id register
  436.     mov   bh,al    ; and save it in bh
  437.  
  438.    mov   cl,4     ; nibble swap rotate count
  439.    mov   dx,3c4h     ; sequencer/extensions
  440.    mov   bl,6     ; extensions enable register
  441.  
  442.    ror   bh,cl    ; compute extensions disable value
  443.    mov   ax,bx    ; extensions disable
  444.    out   dx,ax    ; disable extensions
  445.    inc   dx    ; point to data
  446.    in al,dx    ; read enable flag
  447.    or al,al    ; disabled ?
  448.    jnz   exit     ; nope, not an cirrus
  449.  
  450.     ror   bh,cl    ; compute extensions enable value
  451.    dec   dx    ; point to index
  452.     mov   ax,bx    ; extensions enable
  453.    out   dx,ax    ; enable extensions
  454.     inc   dx    ; point to data
  455.     in al,dx    ; read enable flag
  456.    cmp   al,1     ; enabled ?
  457.    jne   exit     ; nope, not an cirrus
  458.    mov   [cirrus],1
  459. ;    mov   [bankadr],offset _nobank
  460. ;if @Codesize
  461. ;   mov   [bankseg],seg _nobank
  462. ;endif
  463. exit: pop   dx    ; restore crtc address
  464.    dec   dx    ; point to index
  465.    pop   ax    ; recover crc index and data
  466.    out   dx,ax    ; restore crc value
  467.    ret
  468. _cirrus  endp
  469.  
  470. _chkbk   proc  near     ;bank switch check routine
  471.    mov   di,0b800h
  472.     mov   es,di
  473.     xor   di,di
  474.     mov   bx,1234h
  475.     call  _gochk
  476.     jnz   badchk
  477.     mov   bx,4321h
  478.    call  _gochk
  479.    jnz   badchk
  480.    clc
  481.    ret
  482. badchk:  stc
  483.    ret
  484. _chkbk   endp
  485.  
  486. _gochk   proc  near
  487.     push  si
  488.    mov   si,bx
  489.  
  490.     mov   al,cl
  491.     call  dx
  492.    xchg  bl,es:[di]
  493.     mov   al,ch
  494.     call  dx
  495.    xchg  bh,es:[di]
  496.  
  497.    xchg  si,bx
  498.  
  499.     mov   al,cl
  500.    call  dx
  501.    xor   bl,es:[di]
  502.    mov   al,ch
  503.    call  dx
  504.    xor   bh,es:[di]
  505.  
  506.    xchg  si,bx
  507.  
  508.    mov   al,ch
  509.    call  dx
  510.    mov   es:[di],bh
  511.    mov   al,cl
  512.     call  dx
  513.    mov   es:[di],bl
  514.  
  515.    mov   al,0
  516.     call  dx
  517.    or si,si
  518.    pop   si
  519.    ret
  520. _gochk   endp
  521.  
  522.  
  523. _pdrsub  proc  near     ;Paradise
  524.    push  dx
  525.     mov   ah,al
  526.    mov   dx,3ceh
  527.    mov   al,9
  528.    out   dx,ax
  529.    pop   dx
  530.    ret
  531. _pdrsub  endp
  532.  
  533.  
  534. _isport2 proc  near
  535.    push  bx
  536.     mov   bx,ax
  537.    out   dx,al
  538.    mov   ah,al
  539.    inc   dx
  540.    in al,dx
  541.    dec   dx
  542.    xchg  al,ah
  543.     push  ax
  544.    mov   ax,bx
  545.    out   dx,ax
  546.    out   dx,al
  547.    mov   ah,al
  548.    inc   dx
  549.    in al,dx
  550.    dec   dx
  551.    and   al,bh
  552.     cmp   al,bh
  553.    jnz   noport
  554.    mov   al,ah
  555.    mov   ah,0
  556.    out   dx,ax
  557.     out   dx,al
  558.    mov   ah,al
  559.    inc   dx
  560.     in al,dx
  561.    dec   dx
  562.    and   al,bh
  563.    cmp   al,0
  564. noport:  pop   ax
  565.    out   dx,ax
  566.    pop   bx
  567.    ret
  568. _isport2 endp
  569.  
  570. _isport1 proc  near
  571.    mov   ah,al
  572.    in al,dx
  573.    push  ax
  574.     mov   al,ah
  575.    out   dx,al
  576.    in al,dx
  577.    and   al,ah
  578.    cmp   al,ah
  579.     jnz   noport2
  580.    mov   al,0
  581.    out   dx,al
  582.    in al,dx
  583.    and   al,ah
  584.    cmp   al,0
  585. noport2: pop   ax
  586.    out   dx,al
  587.    ret
  588. _isport1 endp
  589.  
  590.    end
  591.  
  592.