home *** CD-ROM | disk | FTP | other *** search
/ Shareware Supreme Volume 6 #1 / swsii.zip / swsii / 099 / TGE101.ZIP / 640X480.ASM < prev    next >
Assembly Source File  |  1993-02-04  |  26KB  |  1,580 lines

  1. ; 640X480x256 for SuperVGA and VESA adapters
  2. ; loadable driver for The Graphics Engine
  3. ; Copyright (c) 1993 by Matthew Hildebrand
  4.  
  5. ; Turbo Assembler syntax
  6. ; Portions by John Bridges
  7.  
  8. IDEAL
  9. P286
  10. MODEL LARGE
  11.  
  12.  
  13. SCREEN_WIDE    EQU    640        ; screen width in bytes & pixels
  14. SCREEN_DEEP    EQU    480
  15. SCREEN_SEG    EQU    0A000h        ; base screen segment
  16.  
  17.  
  18.     CODESEG
  19.     ORG    0
  20.  
  21.     db    'GRAP'
  22.     dw    initGraphics        ; initGraphics
  23.     dw    ?
  24.     dw      deInitGraphics        ; deInitGraphics
  25.     dw      ?
  26.         dw      0            ; putImage
  27.         dw    ?
  28.         dw    0            ; putImageInv
  29.         dw    ?
  30.         dw    0            ; getImage
  31.         dw    ?
  32.         dw    putLine            ; putLine
  33.         dw    ?
  34.         dw    getLine            ; getLine
  35.         dw    ?
  36.         dw    0            ; imageSize
  37.         dw    ?
  38.     dw      putPixel        ; putPixel
  39.     dw    ?
  40.     dw    getPixel        ; getPixel
  41.     dw    ?
  42.     dw    0            ; line
  43.         dw      ?
  44.         dw    horizLine        ; horizLine
  45.     dw    ?
  46.     dw    0            ; drawRect
  47.     dw    ?
  48.         dw      0            ; filledRect
  49.     dw    ?
  50.     dw    setPaletteReg        ; setPaletteReg
  51.     dw    ?
  52.         dw    getPaletteReg        ; getPaletteReg
  53.     dw    ?
  54.     dw    setBlockPalette        ; setBlockPalette
  55.     dw    ?
  56.         dw    getBlockPalette        ; getBlockPalette
  57.         dw    ?
  58.         dw    clearGraphics        ; clearGraphics
  59.         dw    ?
  60.     dw    SCREEN_WIDE-1        ; maximum X-coordinate
  61.     dw    SCREEN_DEEP-1        ; maximum Y-coordinate
  62.     dw    255            ; maximum colour number (0-?)
  63.  
  64.     db    'The Graphics Engine -- Copyright (c) 1993 by Matthew Hildebrand'
  65.  
  66. inited        db    0
  67. colourPalette    db    768    DUP(?)
  68. lineOffs    dw    SCREEN_DEEP    DUP(?)
  69. bankNum        dw    SCREEN_DEEP    DUP(?)
  70. bankChanges    dw    SCREEN_DEEP    DUP(?)
  71. curBank        dw    ?
  72. screenWide    dw    ?
  73.  
  74.     LABEL    vesaBuf    WORD
  75. vesaid        db    4 DUP(?)    ; 4 signature bytes
  76. vesaver        dw    ?        ; VESA version number
  77. oemstr        dd    ?        ; Pointer to OEM string
  78. capabil        db    4 DUP(?)    ; Capabilities of the video environment
  79. modelst        dd    ?        ; Pointer to supported Super VGA modes
  80. vesashift    db    0        ; number of bits to shift bank number left
  81.     db    243    DUP(?)        ; pad to 256 bytes
  82.  
  83. bankadr        dw    ?
  84. vga512        dw    ?
  85. vga1024        dw    ?
  86. cirrus        dw    ?
  87. everex        dw    ?
  88. paradise     dw    ?
  89. tseng        dw    ?
  90. trident        dw    ?
  91. t8900        dw    ?
  92. ativga        dw    ?
  93. aheada        dw    ?
  94. aheadb        dw    ?
  95. oaktech        dw    ?
  96. video7        dw    ?
  97. chipstech     dw    ?
  98. tseng4        dw    ?
  99. genoa        dw    ?
  100. ncr        dw    ?
  101. compaq        dw    ?
  102. vesa        dw    ?
  103. retval        dw    ?        ; first return value from whichvga()
  104.  
  105.  
  106. MACRO    GETPALETTE
  107.   push    di
  108.   mov    cx,256
  109.   mov    di,cs
  110.   mov    es,di
  111.   mov    di,OFFSET colourPalette
  112.   cld
  113.   mov    dx,3C7h                ; set for right first pal reg
  114.   xor    ax,ax
  115.   out    dx,al
  116.   mov    dx,3C9h
  117.     @@GetPaletteLoop:
  118.   in    al,dx
  119.   shl    al,2
  120.   stosb        ; red
  121.   in    al,dx
  122.   shl    al,2
  123.   stosb        ; green
  124.   in    al,dx
  125.   shl    al,2
  126.   stosb        ; blue
  127.   loop    @@GetPaletteLoop
  128.   pop    di
  129. ENDM
  130.  
  131. MACRO    SETPALETTE
  132.   push    ds si
  133.   mov    si,cs
  134.   mov    ds,si
  135.   mov    si,OFFSET colourPalette
  136.   mov    cx,256
  137.   cld
  138.   mov    dx,3C8h                ; set for right first pal reg
  139.   xor    ax,ax
  140.   out    dx,al
  141.   inc    dx
  142.     @@SetPaletteLoop:
  143.   lodsb            ; red
  144.   shr    al,2
  145.   jnc    @@L1
  146.   cmp    al,63
  147.   je    @@L1
  148.   inc    al
  149.       @@L1:
  150.   out    dx,al
  151.   lodsb            ; green
  152.   shr    al,2
  153.   jnc    @@L2
  154.   cmp    al,63
  155.   je    @@L2
  156.   inc    al
  157.       @@L2:
  158.   out    dx,al
  159.   lodsb            ; blue
  160.   shr    al,2
  161.   jnc    @@L3
  162.   cmp    al,63
  163.   je    @@L3
  164.   inc    al
  165.       @@L3:
  166.   out    dx,al
  167.   loop    @@SetPaletteLoop
  168.   pop    si ds
  169. ENDM
  170.  
  171. MACRO    NEWBANK
  172.   call    [bankadr]
  173. ENDM
  174.  
  175.  
  176.     PUBLIC C    initGraphics
  177. PROC    C    initGraphics
  178.   cmp    [inited],0
  179.   je    @@NotInited
  180.   call    setMode
  181.   SETPALETTE
  182.   mov    ax,1
  183.   retf
  184.  
  185.       @@NotInited:
  186.   call    whichVGA
  187.   or    ax,ax
  188.   jz    @@NoDetect
  189.   call    setMode
  190.  
  191.   push    si di
  192.   mov    si,OFFSET lineOffs
  193.   mov    di,OFFSET bankNum
  194.   mov    cx,SCREEN_DEEP
  195.   xor    bx,bx
  196.  
  197.     @@Loop1:
  198.   mov    ax,[screenWide]            ; calculate bank and offsets
  199.   mul    bx                ; for each line start
  200.   mov    [cs:si],ax
  201.   add    si,2
  202.   mov    [cs:di],dx
  203.   add    di,2
  204.   inc    bx
  205.   loop    @@Loop1
  206.  
  207.   mov    bx,1                ; set flag table for bank change
  208.   mov    cx,SCREEN_DEEP            ; mid-line
  209.   mov    si,OFFSET bankChanges
  210.   mov    [word ptr cs:si],0
  211.   add    si,2
  212.       @@Loop2:
  213.   mov    ax,[screenWide]
  214.   mul    bx
  215.   mov    di,dx
  216.   mov    ax,[screenWide]
  217.   inc    bx
  218.   mul    bx
  219.   sub    ax,1
  220.   sbb    dx,0
  221.   cmp    di,dx
  222.   jne    @@BankChange
  223.   mov    [word ptr cs:si],0
  224.   jmp    short    @@NextIteration
  225.       @@BankChange:
  226.   mov    [word ptr cs:si],1
  227.       @@NextIteration:
  228.   add    si,2
  229.   loop    @@Loop2
  230.  
  231.   pop    di si
  232.   mov    ax,1
  233.   mov    [inited],al
  234.   retf
  235.  
  236.     @@NoDetect:
  237.   xor    ax,ax
  238.   retf
  239. ENDP
  240.  
  241.     PUBLIC    C    deInitGraphics
  242. PROC    C    deInitGraphics
  243.   GETPALETTE
  244.   mov    ax,0003h
  245.   int    10h
  246.   retf
  247. ENDP
  248.  
  249.     PUBLIC    C    putLine
  250. PROC    C    putLine
  251.     ARG    lineNum:WORD, xOff:WORD, lineLen:WORD, buf:DATAPTR
  252.   push    ds si di
  253.  
  254.   cld
  255.   mov    bx,[lineNum]            ; Decide if bank changes mid-line
  256.   shl    bx,1
  257.   cmp    [cs:bankChanges+bx],0
  258.   jne    @@BankChanged
  259.  
  260.   mov    ax,[cs:bankNum+bx]
  261.   cmp    ax,[curBank]            ; set bank only if necessary
  262.   je    @@NoNewBank
  263.   NEWBANK
  264.  
  265.       @@NoNewBank:
  266.   mov    cx,[lineLen]            ; blast the line into video memory
  267.   mov    ax,SCREEN_SEG
  268.   mov    es,ax
  269.   mov    di,[cs:lineOffs+bx]
  270.   add    di,[xOff]
  271.   lds    si,[buf]
  272.   shr    cx,1
  273.   rep    movsw
  274.   jnc    @@Exit
  275.   movsb
  276.       @@Exit:
  277.   pop    di si ds
  278.   leave
  279.   retf
  280.  
  281.       @@BankChanged:                  ; slow pixel-by-pixel
  282.   mov    cx,[lineLen]
  283.   mov    dx,[lineNum]
  284.   mov    bx,[xOff]
  285.   lds    si,[buf]
  286.       @@Loop:
  287.   lodsb
  288.   push    bx cx dx si
  289.   call    far putPixel C,bx,dx,ax
  290.   pop    si dx cx bx
  291.   inc    bx
  292.   loop    @@Loop
  293.  
  294.   pop    di si ds
  295.   leave
  296.   retf
  297. ENDP
  298.  
  299.     PUBLIC    C    getLine
  300. PROC    C    getLine
  301.     ARG    lineNum:WORD, xOff:WORD, lineLen:WORD, buf:DATAPTR
  302.   push    ds si di
  303.  
  304.   cld
  305.   mov    bx,[lineNum]            ; Decide if bank changes mid-line
  306.   shl    bx,1
  307.   cmp    [cs:bankChanges+bx],0
  308.   jne    @@BankChanged
  309.  
  310.   mov    ax,[cs:bankNum+bx]
  311.   cmp    ax,[curBank]            ; set bank only if necessary
  312.   je    @@NoNewBank
  313.   NEWBANK
  314.  
  315.       @@NoNewBank:
  316.   mov    cx,[lineLen]            ; blast the line into video memory
  317.   mov    ax,SCREEN_SEG
  318.   mov    ds,ax
  319.   mov    si,[cs:lineOffs+bx]
  320.   add    si,[xOff]
  321.   les    di,[buf]
  322.   shr    cx,1
  323.   rep    movsw
  324.   jnc    @@Exit
  325.   movsb
  326.       @@Exit:
  327.   pop    di si ds
  328.   leave
  329.   retf
  330.  
  331.       @@BankChanged:                  ; slow pixel-by-pixel
  332.   mov    cx,[lineLen]
  333.   mov    dx,[lineNum]
  334.   mov    bx,[xOff]
  335.   les    di,[buf]
  336.       @@Loop:
  337.   push    bx cx dx di es
  338.   call    far getPixel C,bx,dx
  339.   pop    es di dx cx bx
  340.   stosb
  341.   inc    bx
  342.   loop    @@Loop
  343.  
  344.   pop    di si ds
  345.   leave
  346.   retf
  347. ENDP
  348.  
  349.     PUBLIC    C    putPixel
  350. PROC    C    putPixel
  351.     ARG    x:WORD, y:WORD, colour:BYTE
  352.   mov    bx,[x]
  353.   mov    ax,[y]
  354.   mov    dx,[screenWide]
  355.   mul      dx
  356.   add    bx,ax
  357.   adc    dx,0
  358.   cmp    dx,[curBank]
  359.   je    @@NoNew
  360.   mov    ax,dx
  361.   NEWBANK            ; switch banks if a new bank entered
  362.     @@NoNew:
  363.   mov    ax,SCREEN_SEG        ; setup screen segment A000
  364.   mov    es,ax
  365.   mov    al,[colour]        ; get color of pixel to plot
  366.   mov    [es:bx],al
  367.   leave
  368.   retf
  369. ENDP
  370.  
  371.     PUBLIC    C    getPixel
  372. PROC    C    getPixel
  373.     ARG    x:WORD, y:WORD
  374.   mov    ax,[screenWide]
  375.   mul    [y]
  376.   add    ax,[x]
  377.   adc    dx,0
  378.   mov    bx,ax
  379.   cmp    dx,[curBank]
  380.   je    @@noNewBank
  381.   mov    ax,dx
  382.   NEWBANK            ; switch banks if a new bank entered
  383.     @@noNewBank:
  384.   mov    ax,SCREEN_SEG        ; setup screen segment
  385.   mov    es,ax
  386.   mov    al,[es:bx]
  387.   xor    ah,ah
  388.   leave
  389.   retf
  390. ENDP
  391.  
  392.     PUBLIC    C    horizLine
  393. PROC    C    horizLine
  394.     ARG    y:WORD, x1:WORD, x2:WORD, colour:BYTE
  395.   push    di
  396.  
  397.   cld
  398.   mov    bx,[y]                ; Decide if bank changes mid-line
  399.   shl    bx,1
  400.   cmp    [cs:bankChanges+bx],0
  401.   jne    @@BankChanged
  402.  
  403.   mov    ax,[cs:bankNum+bx]
  404.   cmp    ax,[curBank]            ; set bank only if necessary
  405.   je    @@NoNewBank
  406.   NEWBANK
  407.  
  408.       @@NoNewBank:
  409.   mov    ax,SCREEN_SEG
  410.   mov    es,ax
  411.   mov    ax,[x1]
  412.   mov    di,[cs:lineOffs+bx]
  413.   add    di,ax
  414.   mov    cx,[x2]                ; blast the line into video memory
  415.   inc    cx
  416.   sub    cx,ax
  417.   mov    al,[colour]
  418.   mov    ah,al
  419.   shr    cx,1
  420.   rep    stosw
  421.   jnc    @@Exit
  422.   stosb
  423.  
  424.       @@Exit:
  425.   pop    di
  426.   leave
  427.   retf
  428.  
  429.       @@BankChanged:                  ; slow pixel-by-pixel
  430.   mov    bx,[x1]
  431.   mov    cx,[x2]
  432.   inc    cx
  433.   sub    cx,bx
  434.   mov    dx,[y]
  435.       @@Loop:
  436.   push    bx cx dx
  437.   mov    al,[colour]
  438.   call    far putPixel C,bx,dx,ax
  439.   pop    dx cx bx
  440.   inc    bx
  441.   loop    @@Loop
  442.  
  443.   pop    di
  444.   leave
  445.   retf
  446. ENDP
  447.  
  448.     PUBLIC    C    setPaletteReg
  449. PROC    C    setPaletteReg
  450.     ARG    palNum:WORD,red:BYTE,green:BYTE,blue:BYTE
  451.   mov    bx,[palNum]
  452.  
  453.   mov    dx,3C8h                ; set for the right palette register
  454.   mov    ax,[palNum]
  455.   out    dx,al
  456.   inc    dx
  457.  
  458.   mov    al,[red]            ; red
  459.   shr    al,2
  460.   jnc    @@L1
  461.   cmp    al,63
  462.   je    @@L1
  463.   inc    al
  464.     @@L1:
  465.   out    dx,al
  466.  
  467.   mov    al,[green]            ; green
  468.   shr    al,2
  469.   jnc    @@L2
  470.   cmp    al,63
  471.   je    @@L2
  472.   inc    al
  473.     @@L2:
  474.   out    dx,al
  475.  
  476.   mov    al,[blue]            ; blue
  477.   shr    al,2
  478.   jnc    @@L3
  479.   cmp    al,63
  480.   je    @@L3
  481.   inc    al
  482.     @@L3:
  483.   out    dx,al
  484.  
  485.   leave
  486.   retf
  487. ENDP
  488.  
  489.     PUBLIC    C    getPaletteReg
  490. PROC    C    getPaletteReg
  491.     ARG    palNum:WORD,red:DATAPTR,green:DATAPTR,blue:DATAPTR
  492.   push    ds si
  493.  
  494.   mov    dx,3C7h                ; set for right palette register
  495.   mov    ax,[palNum]
  496.   out    dx,al
  497.   mov    dx,3C9h
  498.  
  499.   in    al,dx                ; red
  500.   lds    si,[red]
  501.   shl    al,2
  502.   mov    [ds:si],al
  503.   in    al,dx                ; green
  504.   lds    si,[green]
  505.   shl    al,2
  506.   mov    [ds:si],al
  507.   in    al,dx                ; blue
  508.   lds    si,[blue]
  509.   shl    al,2
  510.   mov    [ds:si],al
  511.  
  512.   pop    si ds
  513.   leave
  514.   retf
  515. ENDP
  516.  
  517.     PUBLIC    C    setBlockPalette
  518. PROC    C    setBlockPalette
  519.     ARG    firstReg:WORD,numRegs:WORD,paletteData:DATAPTR
  520.   push    ds si
  521.   lds    si,[paletteData]
  522.   mov    cx,[numRegs]
  523.   jcxz    @@LExit
  524.   cld
  525.  
  526.   mov    dx,3C8h                ; set for right first pal reg
  527.   mov    ax,[firstReg]
  528.   out    dx,al
  529.   inc    dx
  530.  
  531.     @@LLoop:
  532.   lodsb            ; red
  533.   shr    al,2
  534.   jnc    @@L1
  535.   cmp    al,63
  536.   je    @@L1
  537.   inc    al
  538.       @@L1:
  539.   out    dx,al
  540.  
  541.   lodsb            ; green
  542.   shr    al,2
  543.   jnc    @@L2
  544.   cmp    al,63
  545.   je    @@L2
  546.   inc    al
  547.       @@L2:
  548.   out    dx,al
  549.  
  550.   lodsb            ; blue
  551.   shr    al,2
  552.   jnc    @@L3
  553.   cmp    al,63
  554.   je    @@L3
  555.   inc    al
  556.       @@L3:
  557.   out    dx,al
  558.  
  559.   loop    @@LLoop
  560.  
  561.     @@LExit:
  562.   pop    si ds
  563.   leave
  564.   retf
  565. ENDP
  566.  
  567.     PUBLIC    C    getBlockPalette
  568. PROC    C    getBlockPalette
  569.     ARG    firstReg:WORD,numRegs:WORD,paletteData:DATAPTR
  570.   push    di
  571.   mov    cx,[numRegs]
  572.   jcxz    @@LExit
  573.   les    di,[paletteData]
  574.   cld
  575.  
  576.   mov    dx,3C7h                ; set for right first pal reg
  577.   mov    ax,[firstReg]
  578.   out    dx,al
  579.   mov    dx,3C9h
  580.  
  581.     @@L1:
  582.   in    al,dx
  583.   shl    al,2
  584.   stosb        ; red
  585.   in    al,dx
  586.   shl    al,2
  587.   stosb        ; green
  588.   in    al,dx
  589.   shl    al,2
  590.   stosb        ; blue
  591.   loop    @@L1
  592.  
  593.     @@LExit:
  594.   pop    di
  595.   leave
  596.   retf
  597. ENDP
  598.  
  599.     PUBLIC    C    clearGraphics
  600. PROC    C    clearGraphics
  601.     ARG    colour:BYTE
  602.   push    di
  603.  
  604.   cmp    [curBank],0
  605.   je    @@NoNewBank
  606.   xor    ax,ax
  607.   NEWBANK
  608.  
  609.       @@NoNewBank:
  610.   mov    ax,SCREEN_SEG            ; clear bank 0
  611.   mov    es,ax
  612.   xor    di,di
  613.   mov    al,[colour]
  614.   mov    ah,al
  615.   mov    dx,ax
  616.   mov    cx,32768
  617.   rep    stosw
  618.  
  619.   mov    ax,1                ; clear bank 1
  620.   NEWBANK
  621.   mov    ax,dx
  622.   mov    cx,32768
  623.   rep    stosw
  624.  
  625.   mov    ax,2                ; clear bank 2
  626.   NEWBANK
  627.   mov    ax,dx
  628.   mov    cx,32768
  629.   rep    stosw
  630.  
  631.   mov    ax,3                ; clear bank 3
  632.   NEWBANK
  633.   mov    ax,dx
  634.   mov    cx,32768
  635.   rep    stosw
  636.  
  637.   mov    ax,4                ; clear bank 4
  638.   NEWBANK
  639.   mov    ax,dx
  640.   mov    cx,22528
  641.   rep    stosw
  642.  
  643.   pop    di
  644.   leave
  645.   retf
  646. ENDP
  647.  
  648. ;PROC    newBank    NEAR            ; bank number is in AX
  649. ;  cli
  650. ;  mov    [curBank],ax
  651. ;  jmp    [word ptr bankadr]
  652.  
  653.  
  654. _tseng:                    ; Tseng
  655.   cli
  656.   mov    [curBank],ax
  657.   push    ax dx
  658.   and    al,7
  659.   mov    ah,al
  660.   shl    al,3
  661.   or    al,ah
  662.   or    al,01000000b
  663.   mov    dx,3CDh
  664.   out    dx,al
  665.   sti
  666.   pop    dx ax
  667.   ret
  668.  
  669. _tseng4:                ; Tseng 4000 series
  670.   cli
  671.   mov    [curBank],ax
  672.   push    ax dx
  673.   mov    ah,al
  674.   mov    dx,3bfh            ; Enable access to extended registers
  675.   mov    al,3
  676.   out    dx,al
  677.   mov    dl,0D8h
  678.   mov    al,0A0h
  679.   out    dx,al
  680.   and    ah,15
  681.   mov    al,ah
  682.   shl    al,4
  683.   or    al,ah
  684.   mov    dl,0CDh
  685.   out    dx,al
  686.   sti
  687.   pop    dx ax
  688.   ret
  689.  
  690. _trident:                ; Trident
  691.   cli
  692.   mov    [curBank],ax
  693.   push    ax dx
  694.   mov    dx,3CEh            ; set pagesize to 64k
  695.   mov    al,6
  696.   out    dx,al
  697.   inc    dl
  698.   in    al,dx
  699.   dec    dl
  700.   or    al,4
  701.   mov    ah,al
  702.   mov    al,6
  703.   out    dx,ax
  704.  
  705.   mov    dl,0C4h            ; switch to BPS mode
  706.   mov    al,0Bh
  707.   out    dx,al
  708.   inc    dl
  709.   in    al,dx
  710.   dec    dl
  711.  
  712.   mov    ah,[byte ptr curBank]
  713.   xor    ah,2
  714.   mov    dx,3C4h
  715.   mov    al,0Eh
  716.   out    dx,ax
  717.   sti
  718.   pop    dx ax
  719.   ret
  720.  
  721. _video7:                ; Video 7
  722.   cli
  723.   mov    [curBank],ax
  724.   push    ax dx cx
  725.   and    ax,15
  726.   mov    ch,al
  727.   mov    dx,3C4h
  728.   mov    ax,0EA06h
  729.   out    dx,ax
  730.   mov    ah,ch
  731.   and    ah,1
  732.   mov    al,0F9h
  733.   out    dx,ax
  734.   mov    al,ch
  735.   and    al,1100b
  736.   mov    ah,al
  737.   shr    ah,2
  738.   or    ah,al
  739.   mov    al,0F6h
  740.   out    dx,al
  741.   inc    dx
  742.   in    al,dx
  743.   dec    dx
  744.   and    al,NOT 1111b
  745.   or    ah,al
  746.   mov    al,0F6h
  747.   out    dx,ax
  748.   mov    ah,ch
  749.   mov    cl,4
  750.   shl    ah,cl
  751.   and    ah,100000b
  752.   mov    dl,0CCh
  753.   in    al,dx
  754.   mov    dl,0C2h
  755.   and    al,NOT 100000b
  756.   or    al,ah
  757.   out    dx,al
  758.   sti
  759.   pop    cx dx ax
  760.   ret
  761.  
  762. _paradise:                ; Paradise
  763.   cli
  764.   mov    [curBank],ax
  765.   push    ax dx
  766.   mov    dx,3CEh
  767.   mov    ax,50Fh            ; turn off write protect on VGA registers
  768.   out    dx,ax
  769.   mov    ah,[byte ptr curBank]
  770.   shl    ah,4            ; change 64k bank number into 4k bank number
  771.   mov    al,9
  772.   out    dx,ax
  773.   sti
  774.   pop    dx ax
  775.   ret
  776.  
  777. _chipstech:                ; Chips & Tech
  778.   cli
  779.   mov    [curBank],ax
  780.   push    ax dx
  781.   mov    dx,46E8h        ; place chip in setup mode
  782.   mov    ax,1Eh
  783.   out    dx,ax
  784.   mov    dx,103h            ; enable extended registers
  785.   mov    ax,0080h
  786.   out    dx,ax
  787.   mov    dx,46E8h        ; bring chip out of setup mode
  788.   mov    ax,0Eh
  789.   out    dx,ax
  790.   mov    ah,[byte ptr curBank]
  791.   shl    ah,2            ; change 64k bank number into 16k bank number
  792.   mov    al,10h
  793.   mov    dx,3D6h
  794.   out    dx,ax
  795.   sti
  796.   pop    dx ax
  797.   ret
  798.  
  799. _ativga:                ; ATI VGA Wonder
  800.   cli
  801.   mov    [curBank],ax
  802.   push    ax dx
  803.   mov    ah,al
  804.   mov    dx,1CEh
  805.   mov    al,0B2h
  806.   out    dx,al
  807.   inc    dl
  808.   in    al,dx
  809.   shl    ah,1
  810.   and    al,0E1h
  811.   or    ah,al
  812.   mov    al,0B2h
  813.   dec    dl
  814.   out    dx,ax
  815.   sti
  816.   pop    dx ax
  817.   ret
  818.  
  819. _everex:                ; Everex
  820.   cli
  821.   mov    [curBank],ax
  822.   push    ax dx cx
  823.   mov    cl,al
  824.   mov    dx,3C4h
  825.   mov    al,8
  826.   out    dx,al
  827.   inc    dl
  828.   in    al,dx
  829.   dec    dl
  830.   shl    al,1
  831.   shr    cl,1
  832.   rcr    al,1
  833.   mov    ah,al
  834.   mov    al,8
  835.   out    dx,ax
  836.   mov    dl,0CCh
  837.   in    al,dx
  838.   mov    dl,0C2h
  839.   and    al,0DFh
  840.   shr    cl,1
  841.   jc    @@nob2
  842.   or    al,20h
  843.       @@nob2:
  844.   out    dx,al
  845.   sti
  846.   pop    cx dx ax
  847.   ret
  848.  
  849. _aheada:                ; Ahead Systems Ver A
  850.   cli
  851.   mov    [curBank],ax
  852.   push    ax dx cx
  853.   mov    ch,al
  854.   mov    dx,3CEh            ; Enable extended registers
  855.   mov    ax,200Fh
  856.   out    dx,ax
  857.   mov    dl,0CCh            ; bit 0
  858.   in    al,dx
  859.   mov    dl,0C2h
  860.   and    al,11011111b
  861.   shr    ch,1
  862.   jnc    @@skpa
  863.   or    al,00100000b
  864.       @@skpa:
  865.   out    dx,al
  866.   mov    dl,0CFh            ; bits 1,2,3
  867.   xor    al,al
  868.   out    dx,al
  869.   inc    dx
  870.   in    al,dx
  871.   dec    dx
  872.   and    al,11111000b
  873.   or    al,ch
  874.   mov    ah,al
  875.   xor    al,al
  876.   out    dx,ax
  877.   sti
  878.   pop    cx dx ax
  879.   ret
  880.  
  881. _aheadb:                ; Ahead Systems Ver B
  882.   cli
  883.   mov    [curBank],ax
  884.   push    ax dx cx
  885.   mov    ch,al
  886.   mov    dx,3CEh            ; Enable extended registers
  887.   mov    ax,200Fh
  888.   out    dx,ax
  889.   mov    ah,ch
  890.   mov    cl,4
  891.   shl    ah,cl
  892.   or    ah,ch
  893.   mov    al,0Dh
  894.   out    dx,ax
  895.   sti
  896.   pop    cx dx ax
  897.   ret
  898.  
  899. _oaktech:                ; Oak Technology Inc OTI-067
  900.   cli
  901.   mov    [curBank],ax
  902.   push    ax dx
  903.   and    al,15
  904.   mov    ah,al
  905.   shl    al,4
  906.   or    ah,al
  907.   mov    al,11h
  908.   mov    dx,3DEh
  909.   out    dx,ax
  910.   sti
  911.   pop    dx ax
  912.   ret
  913.  
  914. _genoa:                    ; GENOA GVGA
  915.   cli
  916.   mov    [curBank],ax
  917.   push    ax dx
  918.   mov    ah,al
  919.   shl    al,3
  920.   or    ah,al
  921.   mov    al,6
  922.   or    ah,40h
  923.   mov    dx,3C4h
  924.   out    dx,ax
  925.   sti
  926.   pop    dx ax
  927.   ret
  928.  
  929. _ncr:                    ; NCR 77C22E
  930.   cli
  931.   mov    [curBank],ax
  932.   push    ax ax
  933.   push    dx
  934.   shl    al,2            ; change 64k bank number into 16k bank number
  935.   mov    ah,al
  936.   mov    al,18h
  937.   mov    dx,3C4h
  938.   out    dx,ax
  939.   mov    ax,19h
  940.   out    dx,ax
  941.   sti
  942.   pop    dx ax
  943.   ret
  944.  
  945. _compaq:                ; Compaq
  946.   cli
  947.   mov    [curBank],ax
  948.   push    ax dx
  949.   mov    dx,3CEh
  950.   mov    ax,50Fh            ; unlock extended registers
  951.   out    dx,ax
  952.   mov    ah,[byte ptr curBank]
  953.   shl    ah,4            ; change 64k bank number into 4k bank number
  954.   mov    al,45h
  955.   out    dx,ax
  956.   sti
  957.   pop    dx ax
  958.   ret
  959.  
  960. _vesa:                ; Vesa SVGA interface
  961.   cli
  962.   mov    [curBank],ax
  963.   push    ax bx cx dx
  964.   mov    cl,[vesashift]
  965.   shl    ax,cl
  966.   mov    dx,ax
  967.   xor    bx,bx
  968.   mov    ax,4F05h
  969.   int    10h
  970.   sti
  971.   pop    dx cx bx ax
  972.   ret
  973.  
  974. _nobank:
  975.   cli
  976.   mov    [curBank],ax
  977.   sti
  978.   ret
  979. ;ENDP
  980.  
  981.  
  982. MACRO    BKADR    func
  983.   mov    [func],1
  984.   mov    [bankadr],OFFSET _&func
  985. ENDM
  986.  
  987. MACRO    NOJMP
  988.   local    lbl
  989.   jmp    short    lbl
  990.     lbl:
  991. ENDM
  992.  
  993.  
  994. PROC    whichVGA    NEAR
  995.   push    si di
  996.  
  997.   cmp    [inited],1
  998.   jne    @@goTest
  999.   mov    ax,[retval]
  1000.   pop    di si
  1001.   ret
  1002.     @@goTest:
  1003.   mov    [bankadr],OFFSET _nobank
  1004.   xor    ax,ax
  1005.   mov    [curBank],ax
  1006.   mov    [vga512],ax
  1007.   mov    [vga1024],ax
  1008.   mov    [cirrus],ax
  1009.   mov    [everex],ax
  1010.   mov    [paradise],ax
  1011.   mov    [tseng],ax
  1012.   mov    [trident],ax
  1013.   mov    [t8900],ax
  1014.   mov    [ativga],ax
  1015.   mov    [aheada],ax
  1016.   mov    [aheadb],ax
  1017.   mov    [oaktech],ax
  1018.   mov    [video7],ax
  1019.   mov    [chipstech],ax
  1020.   mov    [tseng4],ax
  1021.   mov    [genoa],ax
  1022.   mov    [ncr],ax
  1023.   mov    [compaq],ax
  1024.   mov    [vesa],ax
  1025.  
  1026.   mov    ax,cs
  1027.   mov    es,ax
  1028.   lea    di,[vesaBuf]
  1029.   mov    ax,4F00h
  1030.   int    10h
  1031.   cmp    ax,4Fh
  1032.   jnz    @@noVESA
  1033.   BKADR    vesa
  1034.   mov    [vga512],1
  1035.   mov    [vga1024],1
  1036. ; jmp    @@fini                 ;*** uncomment to use VESA only
  1037.  
  1038.     @@noVESA:
  1039.   mov    si,1
  1040.   mov    ax,0C000h
  1041.   mov    es,ax
  1042.   cmp    [word ptr es:40h],'13'        ; ATI Signiture on the Video BIOS
  1043.   jnz    @@noATI
  1044.   BKADR    ativga
  1045.   cli
  1046.   mov    dx,1CEh
  1047.   mov    al,0BBh
  1048.   out    dx,al
  1049.   inc    dl
  1050.   in    al,dx
  1051.   sti
  1052.   and    al,20h
  1053.   jz    @@no512
  1054.   mov    [vga512],1
  1055.     @@no512:
  1056.   jmp    @@fini
  1057.  
  1058.     @@noATI:
  1059.   mov    ax,7000h            ; Test for Everex
  1060.   xor    bx,bx
  1061.   cld
  1062.   int    10h
  1063.   cmp    al,70h
  1064.   jnz    @@noEverex
  1065.   BKADR    everex
  1066.   and    ch,11000000b        ; how much memory on board?
  1067.   jz    @@skp
  1068.   mov    [vga512],1
  1069.      @@skp:            ; fall through for Everex boards using Trident or Tseng4000
  1070.  
  1071.     @@noEverex:
  1072.   mov    ax,0BF03h            ; Test for Compaq
  1073.   xor    bx,bx
  1074.   mov    cx,bx
  1075.   int    10h
  1076.   cmp    ax,0BF03h
  1077.   jnz    @@noCompaq
  1078.   test    cl,40h                ; is 640x480x256 available?
  1079.   jz    @@noCompaq
  1080.   BKADR    compaq
  1081.   mov    [vga512],1
  1082.   jmp    @@fini
  1083.  
  1084.     @@noCompaq:
  1085.   mov    dx,3C4h                ; Test for NCR 77C22E
  1086.   mov    ax,0FF05h
  1087.   call    _isport2
  1088.   jnz    @@noNCR
  1089.   mov    ax,5                   ; Disable extended registers
  1090.   out    dx,ax
  1091.   mov    ax,0FF10h        ; Try to write to extended register 10
  1092.   call    _isport2        ; If it writes then not NCR
  1093.   jz    @@noNCR
  1094.   mov    ax,105h            ; Enable extended registers
  1095.   out    dx,ax
  1096.   mov    ax,0FF10h
  1097.   call    _isport2
  1098.   jnz    @@noNCR            ; If it does NOT write then not NCR
  1099.   BKADR    ncr
  1100.   mov    [vga512],1
  1101.   jmp    @@fini
  1102.  
  1103.     @@noNCR:
  1104.   mov    dx,3C4h                ;Test for Trident
  1105.   mov    al,0Bh
  1106.   out    dx,al
  1107.   inc    dl
  1108.   in    al,dx
  1109.   cmp    al,06h
  1110.   ja    @@noTrident
  1111.   cmp    al,2
  1112.   jb    @@noTrident
  1113.   BKADR    trident
  1114.   cmp    al,3
  1115.   jb    @@no89
  1116.   mov    [t8900],1
  1117.   mov    dx,3D5h
  1118.   mov    al,1Fh
  1119.   out    dx,al
  1120.   inc    dx
  1121.   in    al,dx
  1122.   and    al,3
  1123.   cmp    al,1
  1124.   jb    @@notmem
  1125.   mov    [vga512],1
  1126.   je    @@notmem
  1127.   mov    [vga1024],1
  1128.     @@notmem:
  1129.   jmp    @@fini
  1130.  
  1131.     @@no89:
  1132.   mov    [vga512],1
  1133.   jmp    @@fini
  1134.  
  1135.     @@noTrident:
  1136.   mov    ax,6F00h            ; Test for Video 7
  1137.   xor    bx,bx
  1138.   cld
  1139.   int    10h
  1140.   cmp    bx,'V7'
  1141.   jnz    @@noVideo7
  1142.   BKADR    video7
  1143.   mov    ax,6F07h
  1144.   cld
  1145.   int    10h
  1146.   and    ah,7Fh
  1147.   cmp    ah,1
  1148.   jbe    @@skp2
  1149.   mov    [vga512],1
  1150.     @@skp2:
  1151.   cmp    ah,3
  1152.   jbe    @@skp3
  1153.   mov    [vga1024],1
  1154.     @@skp3:
  1155.   jmp    @@fini
  1156.  
  1157.     @@noVideo7:
  1158.   mov    dx,3D4h                ; Test for GENOA GVGA
  1159.   mov    ax,032Eh        ; check for Herchi Register
  1160.   call    _isport2
  1161.   jnz    @@noGenoa
  1162.   mov    dx,3C4h            ; check for memory segment register
  1163.   mov    ax,3F06h
  1164.   call    _isport2
  1165.   jnz    @@noGenoa
  1166.   BKADR    genoa
  1167.   mov    [vga512],1
  1168.   jmp    @@fini
  1169.  
  1170.     @@noGenoa:
  1171.   call    _cirrus                ; Test for Cirrus
  1172.   cmp    [cirrus],0
  1173.   je    @@noCirrus
  1174.   jmp    @@fini
  1175.  
  1176.     @@noCirrus:
  1177.   mov    dx,3CEh                ; Test for Paradise
  1178.   mov    al,9            ; check Bank switch register
  1179.   out    dx,al
  1180.   inc    dx
  1181.   in    al,dx
  1182.   dec    dx
  1183.   or    al,al
  1184.   jnz    @@noParadise
  1185.  
  1186.   mov    ax,50Fh            ; turn off write protect on VGA registers
  1187.   out    dx,ax
  1188.   mov    dx,OFFSET _pdrsub
  1189.   mov    cx,1
  1190.   call    _chkbk
  1191.   jc    @@noParadise        ; if bank 0 and 1 same not paradise
  1192.   BKADR    paradise
  1193.   mov    dx,3CEh
  1194.   mov    al,0Bh            ; 512k detect from Bob Berry
  1195.   out    dx,al
  1196.   inc    dx
  1197.   in    al,dx
  1198.   test    al,80h            ; if top bit set then 512k
  1199.   jz    @@nop512
  1200.   mov    [vga512],1
  1201.     @@nop512:
  1202.   jmp    @@fini
  1203.  
  1204.     @@noParadise:
  1205.   mov    ax,5F00h            ; Test for Chips & Tech
  1206.   xor    bx,bx
  1207.   cld
  1208.   int    10h
  1209.   cmp    al,5Fh
  1210.   jnz    @@noChipsTech
  1211.   BKADR    chipstech
  1212.   cmp    bh,1
  1213.   jb    @@skp4
  1214.   mov    [vga512],1
  1215.     @@skp4:
  1216.   jmp    @@fini
  1217.  
  1218.     @@noChipsTech:
  1219.   xor    ch,ch                ; check for Tseng 4000 series
  1220.   mov    dx,3D4h
  1221.   mov    ax,0F33h
  1222.   call    _isport2
  1223.   jnz    @@noTseng4
  1224.   mov    ch,1
  1225.  
  1226.   mov    dx,3BFh            ; Enable access to extended registers
  1227.   mov    al,3
  1228.   out    dx,al
  1229.   mov    dx,3D8h
  1230.   mov    al,0A0h
  1231.   out    dx,al
  1232.   jmp    short @@yes4
  1233.  
  1234.     @@noTseng4:
  1235.   mov    dx,3D4h            ; Test for Tseng 3000 or 4000
  1236.   mov    ax,1F25h        ; is the Overflow High register there?
  1237.   call    _isport2
  1238.   jnz    @@noTseng
  1239.   mov    al,03Fh            ; bottom six bits only
  1240.   jmp    short @@yes3
  1241.     @@yes4:
  1242.   mov    al,0FFh
  1243.     @@yes3:
  1244.   mov    dx,3CDh            ; test bank switch register
  1245.   call    _isport1
  1246.   jnz    @@noTseng
  1247.   BKADR    tseng
  1248.   cmp    ch,0
  1249.   jnz    @@t4mem
  1250.   mov    [vga512],1
  1251.   jmp    @@fini
  1252.  
  1253.     @@t4mem:
  1254.   mov    dx,3D4h            ; Tseng 4000 memory detect 1meg
  1255.   mov    al,37h
  1256.   out    dx,al
  1257.   inc    dx
  1258.   in    al,dx
  1259.   test    al,1000b        ; if using 64kx4 RAMs then no more than 256k
  1260.   jz    @@nomem
  1261.   and    al,3
  1262.   cmp    al,1            ; if 8 bit wide bus then only two 256kx4 RAMs
  1263.   jbe    @@nomem
  1264.   mov    [vga512],1
  1265.   cmp    al,2            ; if 16 bit wide bus then four 256kx4 RAMs
  1266.   je    @@nomem
  1267.   mov    [vga1024],1        ; full meg with eight 256kx4 RAMs
  1268.     @@nomem:
  1269.   BKADR    tseng4
  1270.   jmp    @@fini
  1271.  
  1272.     @@noTseng:
  1273.   mov    dx,3CEh                ;Test for Above A or B chipsets
  1274.   mov    ax,200Fh
  1275.   out    dx,ax
  1276.   inc    dx
  1277.   NOJMP
  1278.   in    al,dx
  1279.   cmp    al,21h
  1280.   jz    @@verb
  1281.   cmp    al,20h
  1282.   jnz    @@noAbove
  1283.   BKADR    aheada
  1284.   mov    [vga512],1
  1285.   jmp    short @@fini
  1286.  
  1287.     @@verb:
  1288.   BKADR    aheadb
  1289.   mov    [vga512],1
  1290.   jmp    short @@fini
  1291.  
  1292.     @@noAbove:
  1293.   mov    dx,3DEh                ; Test for Oak Technology
  1294.   mov    ax,0FF11h        ; look for bank switch register
  1295.   call    _isport2
  1296.   jnz    @@noOak
  1297.   BKADR    oaktech
  1298.   mov    al,0Dh
  1299.   out    dx,al
  1300.   inc    dx
  1301.   NOJMP
  1302.   in    al,dx
  1303.   test    al,80h
  1304.   jz    @@noOak
  1305.   mov    [vga512],1
  1306.   jmp    short    @@fini
  1307.  
  1308.     @@noOak:
  1309.   xor    si,si
  1310.  
  1311.     @@fini:
  1312.   mov    ax,si
  1313.   mov    [retval],ax
  1314.   pop    di si
  1315.   ret
  1316. ENDP
  1317.  
  1318. PROC    _cirrus    NEAR
  1319.   mov    dx,3d4h        ; assume 3dx addressing
  1320.   mov    al,0ch        ; screen a start address hi
  1321.   out    dx,al        ; select index
  1322.   inc    dx        ; point to data
  1323.   mov    ah,al        ; save index in ah
  1324.   in    al,dx        ; get screen a start address hi
  1325.   xchg    ah,al        ; swap index and data
  1326.   push    ax        ; save old value
  1327.   push    dx        ; save crtc address
  1328.   xor    al,al        ; clear crc
  1329.   out    dx,al        ; and out to the crtc
  1330.  
  1331.   mov    al,1fh        ; Eagle ID register
  1332.   dec    dx        ; back    to index
  1333.   out    dx,al        ; select index
  1334.   inc    dx        ; point to data
  1335.   in    al,dx        ; read the id register
  1336.   mov    bh,al        ; and save it in bh
  1337.  
  1338.   mov    cl,4        ; nibble swap rotate count
  1339.   mov    dx,3c4h        ; sequencer/extensions
  1340.   mov    bl,6        ; extensions enable register
  1341.  
  1342.   ror    bh,cl        ; compute extensions disable value
  1343.   mov    ax,bx        ; extensions disable
  1344.   out    dx,ax        ; disable extensions
  1345.   inc    dx        ; point to data
  1346.   in    al,dx        ; read enable flag
  1347.   or    al,al        ; disabled ?
  1348.   jnz   @@Exit        ; nope, not an cirrus
  1349.  
  1350.   ror    bh,cl        ; compute extensions enable value
  1351.   dec    dx        ; point to index
  1352.   mov    ax,bx        ; extensions enable
  1353.   out    dx,ax        ; enable extensions
  1354.   inc    dx        ; point to data
  1355.   in    al,dx        ; read enable flag
  1356.   cmp    al,1        ; enabled ?
  1357.   jne    @@Exit        ; nope, not an cirrus
  1358.   mov    [cirrus],1
  1359.   mov    [bankadr],OFFSET _nobank
  1360.  
  1361.     @@Exit:
  1362.   pop    dx        ; restore crtc address
  1363.   dec    dx        ; point to index
  1364.   pop    ax        ; recover crc index and data
  1365.   out    dx,ax        ; restore crc value
  1366.   ret
  1367. ENDP
  1368.  
  1369. PROC    _chkbk    NEAR            ; bank switch check routine
  1370.   mov    di,0B800h
  1371.   mov    es,di
  1372.   xor    di,di
  1373.   mov    bx,1234h
  1374.   call    _gochk
  1375.   jnz    @@badchk
  1376.   mov    bx,4321h
  1377.   call    _gochk
  1378.   jnz    @@badchk
  1379.   clc
  1380.   ret
  1381.     @@badchk:
  1382.   stc
  1383.   ret
  1384. ENDP
  1385.  
  1386. PROC    _gochk    NEAR
  1387.   push    si
  1388.   mov    si,bx
  1389.  
  1390.   mov    al,cl
  1391.   call    dx
  1392.   xchg    bl,[es:di]
  1393.   mov    al,ch
  1394.   call    dx
  1395.   xchg    bh,[es:di]
  1396.  
  1397.   xchg    si,bx
  1398.  
  1399.   mov    al,cl
  1400.   call    dx
  1401.   xor    bl,[es:di]
  1402.   mov    al,ch
  1403.   call    dx
  1404.   xor    bh,[es:di]
  1405.  
  1406.   xchg    si,bx
  1407.  
  1408.   mov    al,ch
  1409.   call    dx
  1410.   mov    [es:di],bh
  1411.   mov    al,cl
  1412.   call    dx
  1413.   mov    [es:di],bl
  1414.  
  1415.   xor    al,al
  1416.   call    dx
  1417.   or    si,si
  1418.   pop    si
  1419.   ret
  1420. ENDP
  1421.  
  1422. PROC    _pdrsub    NEAR            ; Paradise
  1423.   push    dx
  1424.   mov    ah,al
  1425.   mov    dx,3CEh
  1426.   mov    al,9
  1427.   out    dx,ax
  1428.   pop    dx
  1429.   ret
  1430. ENDP
  1431.  
  1432. PROC    _isport2    NEAR
  1433.   push    bx
  1434.   mov    bx,ax
  1435.   out    dx,al
  1436.   mov    ah,al
  1437.   inc    dx
  1438.   in    al,dx
  1439.   dec    dx
  1440.   xchg    al,ah
  1441.   push    ax
  1442.   mov    ax,bx
  1443.   out    dx,ax
  1444.   out    dx,al
  1445.   mov    ah,al
  1446.   inc    dx
  1447.   in    al,dx
  1448.   dec    dx
  1449.   and    al,bh
  1450.   cmp    al,bh
  1451.   jnz    @@noport
  1452.   mov    al,ah
  1453.   mov    ah,0
  1454.   out    dx,ax
  1455.   out    dx,al
  1456.   mov    ah,al
  1457.   inc    dx
  1458.   in    al,dx
  1459.   dec    dx
  1460.   and    al,bh
  1461.   cmp    al,0
  1462.     @@noport:
  1463.   pop    ax
  1464.   out    dx,ax
  1465.   pop    bx
  1466.   ret
  1467. ENDP
  1468.  
  1469. PROC    _isport1    NEAR
  1470.   mov    ah,al
  1471.   in    al,dx
  1472.   push    ax
  1473.   mov    al,ah
  1474.   out    dx,al
  1475.   in    al,dx
  1476.   and    al,ah
  1477.   cmp    al,ah
  1478.   jnz    @@noport
  1479.   mov    al,0
  1480.   out    dx,al
  1481.   in    al,dx
  1482.   and    al,ah
  1483.   cmp    al,0
  1484.     @@noport:
  1485.   pop    ax
  1486.   out    dx,al
  1487.   ret
  1488. ENDP
  1489.  
  1490. PROC    setMode    NEAR        ; Set 640x480x256
  1491.   cmp    [compaq],0
  1492.   jz    @@noCompaq
  1493.   mov    ax,2Eh
  1494.   jmp    @@godo
  1495.     @@noCompaq:
  1496.   cmp    [genoa],0
  1497.   jz    @@noGenoa
  1498.   mov    ax,5Ch
  1499.   jmp    @@godo
  1500.     @@noGenoa:
  1501.   cmp    [ncr],0
  1502.   jz    @@noNCR
  1503.   mov    ax,5Fh
  1504.   jmp    @@godo
  1505.     @@noNCR:
  1506.   cmp    [oaktech],0
  1507.   jz    @@noOak
  1508.   mov    ax,53h
  1509.   jmp    @@godo
  1510.     @@noOak:
  1511.   cmp    [aheada],0
  1512.   jnz    @@
  1513.   cmp    [aheadb],0
  1514.   jz    @@noAbove
  1515.     @@:
  1516.   mov    ax,61h
  1517.   jmp    short @@godo
  1518.     @@noAbove:
  1519.   cmp    [everex],0
  1520.   jz    @@noEverex
  1521.   mov    ax,70h
  1522.   mov    bl,30h
  1523.   jmp    short @@godo
  1524.     @@noEverex:
  1525.   cmp    [ativga],0
  1526.   jz    @@noATI
  1527.   mov    ax,62h
  1528.   jmp    short @@godo
  1529.     @@noATI:
  1530.   cmp    [trident],0
  1531.   jz    @@noTrident
  1532.   mov    ax,5Dh
  1533.   jmp    short @@godo
  1534.     @@noTrident:
  1535.   cmp    [video7],0
  1536.   jz    @@noVideo7
  1537.   mov    ax,6F05h
  1538.   mov    bl,67h
  1539.   jmp    short @@godo
  1540.     @@noVideo7:
  1541.   cmp    [chipstech],0
  1542.   jz    @@noChipsTech
  1543.   mov    ax,79h
  1544.   jmp    short @@godo
  1545.     @@noChipsTech:
  1546.   cmp    [paradise],0
  1547.   jz    @@noParadise
  1548.   mov    ax,5Fh
  1549.   jmp    short @@godo
  1550.     @@noParadise:
  1551.   cmp    [tseng],0
  1552.   jz    @@noTseng
  1553.   mov    ax,2Eh
  1554.   jmp    short    @@godo
  1555.       @@noTseng:
  1556.   cmp    [vesa],0
  1557.   jz    @@noVESA
  1558.   mov    ax,4F02h
  1559.   mov    bx,101h
  1560.     @@godo:
  1561.   int    10h
  1562.  
  1563.   mov    [curBank],-1
  1564.   mov    ax,SCREEN_WIDE
  1565.   cmp    [compaq],0
  1566.   jz    @@noKludge
  1567.   mov    ax,1024
  1568.     @@noKludge:
  1569.   mov    [screenWide],ax
  1570.   mov    ax,1
  1571.   ret
  1572.  
  1573.     @@noVESA:
  1574.   xor    ax,ax
  1575.   ret
  1576. ENDP
  1577.  
  1578.     ENDS
  1579.  
  1580. END