home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR2 / DVPG30FS.ZIP / BANKS.ASM next >
Assembly Source File  |  1993-12-03  |  17KB  |  982 lines

  1. ;  modified quite a bit by Eric Praetzel
  2. ;
  3. ; memory tests removed because the code was big enough to cross a bank boundary
  4. ; hi_color flag is not being set yet by tseng or ATI
  5.  
  6.     include  model.h
  7.  
  8. ;
  9. ;  VGAKIT Version 4.1
  10. ;
  11. ;  Copyright 1988,89,90,91 John Bridges
  12. ;  Free for use in commercial, shareware or freeware applications
  13. ;
  14. ;  BANKS.ASM
  15. ;
  16. ;CRTC            EQU    3D4h        ; Port of CRTC registers
  17. ;VGABufferSeg    EQU    0A000h        ; Segment of VGA display memory
  18.  
  19. .data
  20.  
  21. OSEG  equ   DS:      ;segment override for variable access
  22.  
  23. bankadr  dw ?
  24. if @Codesize
  25. bankseg  dw ?
  26. endif
  27.  
  28.     public   curbk
  29.  
  30. curbk dw ?
  31.  
  32.     public   vga512,vga1024
  33.  
  34. vga512   dw ?
  35. vga1024  dw ?
  36.  
  37.     public   cirrus,everex,paradise,tseng,trident,t8900
  38.     public   ativga,aheada,aheadb,oaktech,video7, realtek
  39.     public   chipstech,tseng4,genoa,ncr,compaq,vesa,speedstar
  40.     public vesashift,  ati_extended          ;ati extended reg. location
  41.  
  42. cirrus   dw ?
  43. everex   dw ?
  44. paradise dw ?
  45. tseng    dw ?
  46. trident  dw ?
  47. t8900    dw ?
  48. ativga   dw ?
  49. aheada   dw ?
  50. aheadb   dw ?
  51. oaktech  dw ?
  52. video7   dw ?
  53. chipstech dw   ?
  54. tseng4   dw ?
  55. genoa    dw ?
  56. ncr      dw ?
  57. compaq   dw ?
  58. vesa     dw ?
  59. speedstar dw ?
  60. realtek    dw ?
  61. XGA        dw ?
  62. S3_card    dw ?
  63.  
  64. ati_extended dw ?  ;ati extended reg. location
  65.  
  66. vesashift db 0     ; number of bits to shift bank number left
  67.  
  68. ;
  69. ;
  70. ;
  71.  
  72.     extrn gr_col:word
  73.     extrn gr_row:word
  74.     extrn color_out:word
  75. ;    extrn    curbk:word
  76.     extrn    maxx:word,maxy:word,xwidth:word
  77. ;
  78. ;
  79. ;
  80.  
  81.  
  82. .code
  83.  
  84.     public   newbank
  85.     public   forcevga
  86.  
  87. ;
  88. ;
  89. ;
  90. ;    extrn    newbank:proc
  91.  
  92.     public    point
  93.     public    point_wide    ; write a word to video memory
  94.     public    point_24        ; 24 bit routine using the generic bank-switch drivers
  95.     public    put16Pixel    ; 4 bit (16 color) graphics drawing routine
  96.  
  97. ;
  98. ;
  99. ;
  100.  
  101.  
  102. newbank proc        ;bank number is in AX
  103.     cli
  104.     mov   OSEG[curbk],ax
  105. if @Codesize
  106.     jmp   dword ptr OSEG[bankadr]
  107. else
  108.     jmp   word ptr OSEG[bankadr]
  109. endif
  110.  
  111.  
  112. ;
  113. ; The video card bank switching routines
  114. ;
  115.  
  116. _S3_card:            ; S3 based video cards
  117. ; bank number is in al
  118.     push ax
  119.     push dx
  120.  
  121.     mov    ah, al    ; save bank #
  122.  
  123.     mov    al, 38h    ; set index
  124.     mov    dx, 3d4h
  125.     out    dx, al
  126.  
  127.     mov    al, 48h    ; put data
  128.     mov    dx, 3d5h
  129.     out    dx, al
  130.  
  131.     mov    al, 39h    ; set index
  132.     mov    dx, 3d4h
  133.     out    dx, al
  134.  
  135.     mov    al, 0A0h    ; put data
  136.     mov    dx, 3d5h
  137.     out    dx, al
  138.  
  139.  
  140.     mov    al, 035h    ; set index
  141.     mov    dx, 3d4h
  142.     out    dx, al
  143.  
  144.     mov    al, ah    ; put data
  145.     mov    dx, 3d5h
  146.     out    dx, al
  147.  
  148.     sti
  149.     pop    dx
  150.     pop    ax
  151.     ret
  152.  
  153.  
  154. _speedstar:            ; Diamond Speedstar 24X
  155. ; al holds the bank # (64k banks)
  156.     push    ax
  157.     push    dx
  158.     mov    ah, al
  159.  
  160.     mov    dx, 3c4h        ; this sets up single 64k bank addressing --> yech
  161.     mov    al, 11h
  162.     out    dx, al
  163.  
  164.     in        al, dx
  165.     and    al, 7fh
  166.     out    dx, al
  167.  
  168.     mov    dx, 3ceh
  169.     mov    al, 0bh
  170.     out    dx, al
  171.  
  172.     in        al, dx
  173.     and    al, 0f7h
  174.     out    dx, al
  175.  
  176.  
  177. ;    and    ax, ff00h    ; clear trash in lower byte
  178.     sal    ax, 4        ; ie done 8 bits of shifting already
  179.     and    ax, 0f000h
  180.     or        ax, 09h
  181.     mov    dx, 3ceh
  182.     out    dx, ax
  183.     sti
  184.     pop    dx
  185.     pop    ax
  186.     ret
  187.  
  188. _realtek:    ; setup
  189.     push    dx
  190.     push    ax
  191.     mov    ax, 0fh
  192.     mov    dx, 3ceh
  193.     out    dx, ax
  194.     mov    ax, 04
  195.     out    dx, ax
  196.     out    dx, ax
  197.  
  198.     pop    ax
  199.     mov    dx,3D6h
  200.     out    dx,al                ; Set write bank register
  201.     inc    dx
  202.     out    dx,al                ; Set read bank
  203.     pop    dx
  204.     sti
  205.     ret
  206.  
  207.  
  208. _XGA:                    ; XGA microchannel
  209.  
  210.     ret
  211.  
  212.  
  213. _tseng:           ;Tseng
  214.     push  ax
  215.     push  dx
  216.     and   al,7
  217.     mov   ah,al
  218.     shl   al,1
  219.     shl   al,1
  220.     shl   al,1
  221.     or al,ah
  222.     or al,01000000b
  223.     mov   dx,3cdh
  224.     out   dx,al
  225.     sti
  226.     pop   dx
  227.     pop   ax
  228.     ret
  229.  
  230.  
  231.  
  232. _tseng4:          ;Tseng 4000 series
  233.     push  ax
  234.     push  dx
  235.    mov   ah,al
  236.     mov   dx,3bfh        ;Enable access to extended registers
  237.    mov   al,3
  238.     out   dx,al
  239.     mov   dl,0d8h
  240.     mov   al,0a0h
  241.    out   dx,al
  242.  
  243.     and   ah,15
  244.     mov   al,ah
  245.     shl   al,4
  246.     or al,ah
  247.     mov   dl,0cdh
  248.     out   dx,al
  249.  
  250.     sti
  251.    pop   dx
  252.     pop   ax
  253.    ret
  254.  
  255.  
  256. _trident:         ;Trident
  257.     push  ax
  258.    push  dx
  259.    mov   dx,3ceh     ;set pagesize to 64k
  260.     mov   al,6
  261.     out   dx,al
  262.    inc   dl
  263.     in al,dx
  264.    dec   dl
  265.    or al,4
  266.     mov   ah,al
  267.    mov   al,6
  268.     out   dx,ax
  269.  
  270.     mov   dl,0c4h     ;switch to BPS mode
  271.     mov   al,0bh
  272.    out   dx,al
  273.    inc   dl
  274.     in al,dx
  275.     dec   dl
  276.  
  277.    mov   ah,byte ptr OSEG[curbk]
  278.     xor   ah,2
  279.    mov   dx,3c4h
  280.     mov   al,0eh
  281.    out   dx,ax
  282.     sti
  283.     pop   dx
  284.     pop   ax
  285.     ret
  286.  
  287.  
  288. _video7:       ;Video 7
  289.    push  ax
  290.     push  dx
  291.    push  cx
  292.     and   ax,15
  293.    mov   ch,al
  294.     mov   dx,3c4h
  295.    mov   ax,0ea06h
  296.     out   dx,ax
  297.    mov   ah,ch
  298.    and   ah,1
  299.     mov   al,0f9h
  300.     out   dx,ax
  301.    mov   al,ch
  302.    and   al,1100b
  303.     mov   ah,al
  304.     shr   ah,1
  305.    shr   ah,1
  306.     or ah,al
  307.     mov   al,0f6h
  308.     out   dx,al
  309.    inc   dx
  310.     in al,dx
  311.    dec   dx
  312.     and   al,not 1111b
  313.    or ah,al
  314.    mov   al,0f6h
  315.    out   dx,ax
  316.    mov   ah,ch
  317.     mov   cl,4
  318.     shl   ah,cl
  319.     and   ah,100000b
  320.    mov   dl,0cch
  321.     in al,dx
  322.     mov   dl,0c2h
  323.    and   al,not 100000b
  324.    or al,ah
  325.     out   dx,al
  326.     sti
  327.     pop   cx
  328.     pop   dx
  329.    pop   ax
  330.     ret
  331.  
  332.  
  333. _paradise:        ;Paradise
  334.     push  ax
  335.     push  dx
  336.     mov   dx,3ceh
  337.    mov   ax,50fh     ;turn off write protect on VGA registers
  338.    out   dx,ax
  339.    mov   ah,byte ptr OSEG[curbk]
  340.    shl   ah,1     ;change 64k bank number into 4k bank number
  341.    shl   ah,1
  342.    shl   ah,1
  343.     shl   ah,1
  344.     mov   al,9
  345.     out   dx,ax
  346.    sti
  347.     pop   dx
  348.    pop   ax
  349.    ret
  350.  
  351.  
  352. _chipstech:       ;Chips & Tech
  353.     push  ax
  354.     push  dx
  355.     mov   dx,46e8h ;place chip in setup mode
  356.     mov   ax,1eh
  357.    out   dx,ax
  358.    mov   dx,103h     ;enable extended registers
  359.    mov   ax,0080h
  360.     out   dx,ax
  361.     mov   dx,46e8h ;bring chip out of setup mode
  362.     mov   ax,0eh
  363.    out   dx,ax
  364.    mov   ah,byte ptr OSEG[curbk]
  365.    shl   ah,1     ;change 64k bank number into 16k bank number
  366.    shl   ah,1
  367.    mov   al,10h
  368.     mov   dx,3d6h
  369.    out   dx,ax
  370.     sti
  371.    pop   dx
  372.     pop   ax
  373.     ret
  374.  
  375.  
  376. _ativga:       ;ATI VGA Wonder
  377.    push  ax
  378.     push  dx
  379. ;  mov   dx,1ceh      this line hardcoded a changed value (Eric)
  380.     mov   dx, [ati_extended]
  381.    mov   ah,al
  382.    mov   al,0b2h
  383.    out   dx,al
  384.     inc   dl
  385.    in al,dx
  386.     shl   ah,1
  387.     and   al,0e1h
  388.    or ah,al
  389.     mov   al,0b2h
  390.     dec   dl
  391.     out   dx,ax
  392.    sti
  393.    pop   dx
  394.     pop   ax
  395.    ret
  396.  
  397.  
  398. _everex:       ;Everex
  399.    push  ax
  400.     push  dx
  401.    push  cx
  402.    mov   cl,al
  403.     mov   dx,3c4h
  404.     mov   al,8
  405.    out   dx,al
  406.     inc   dl
  407.    in al,dx
  408.    dec   dl
  409.    shl   al,1
  410.     shr   cl,1
  411.    rcr   al,1
  412.    mov   ah,al
  413.    mov   al,8
  414.    out   dx,ax
  415.     mov   dl,0cch
  416.     in al,dx
  417.     mov   dl,0c2h
  418.     and   al,0dfh
  419.    shr   cl,1
  420.     jc nob2
  421.    or al,20h
  422. nob2: out   dx,al
  423.    sti
  424.    pop   cx
  425.     pop   dx
  426.    pop   ax
  427.     ret
  428.  
  429.  
  430. _aheada:       ;Ahead Systems Ver A
  431.    push  ax
  432.    push  dx
  433.     push  cx
  434.     mov   ch,al
  435.    mov   dx,3ceh     ;Enable extended registers
  436.     mov   ax,200fh
  437.    out   dx,ax
  438.     mov   dl,0cch     ;bit 0
  439.    in al,dx
  440.    mov   dl,0c2h
  441.    and   al,11011111b
  442.     shr   ch,1
  443.     jnc   skpa
  444.     or al,00100000b
  445. skpa: out   dx,al
  446.     mov   dl,0cfh     ;bits 1,2,3
  447.     mov   al,0
  448.    out   dx,al
  449.    inc   dx
  450.     in al,dx
  451.     dec   dx
  452.     and   al,11111000b
  453.     or al,ch
  454.    mov   ah,al
  455.    mov   al,0
  456.     out   dx,ax
  457.    sti
  458.    pop   cx
  459.     pop   dx
  460.     pop   ax
  461.    ret
  462.  
  463.  
  464. _aheadb:       ;Ahead Systems Ver A
  465.    push  ax
  466.    push  dx
  467.    push  cx
  468.    mov   ch,al
  469.    mov   dx,3ceh     ;Enable extended registers
  470.     mov   ax,200fh
  471.     out   dx,ax
  472.     mov   ah,ch
  473.    mov   cl,4
  474.     shl   ah,cl
  475.    or ah,ch
  476.     mov   al,0dh
  477.    out   dx,ax
  478.     sti
  479.     pop   cx
  480.     pop   dx
  481.    pop   ax
  482.     ret
  483.  
  484.  
  485. _oaktech:         ;Oak Technology Inc OTI-067
  486.     push  ax
  487.     push  dx
  488.     and   al,15
  489.     mov   ah,al
  490.     shl   al,1
  491.    shl   al,1
  492.    shl   al,1
  493.    shl   al,1
  494.     or ah,al
  495.    mov   al,11h
  496.     mov   dx,3deh
  497.    out   dx,ax
  498.     sti
  499.     pop   dx
  500.    pop   ax
  501.    ret
  502.  
  503. _genoa:        ;GENOA GVGA
  504.    push  ax
  505.     push  dx
  506.    mov   ah,al
  507.     shl   al,1
  508.    shl   al,1
  509.    shl   al,1
  510.    or ah,al
  511.    mov   al,6
  512.    or ah,40h
  513.     mov   dx,3c4h
  514.    out   dx,ax
  515.     sti
  516.     pop   dx
  517.    pop   ax
  518.     ret
  519.  
  520. _ncr:          ;NCR 77C22E
  521.    push  ax
  522.     push  dx
  523.     shl   al,1     ;change 64k bank number into 16k bank number
  524.     shl   al,1
  525.    mov   ah,al
  526.    mov   al,18h
  527.     mov   dx,3c4h
  528.    out   dx,ax
  529.    mov   ax,19h
  530.     out   dx,ax
  531.    sti
  532.     pop   dx
  533.     pop   ax
  534.    ret
  535.  
  536. _compaq:       ;Compaq
  537.     push  ax
  538.    push  dx
  539.    mov   dx,3ceh
  540.    mov   ax,50fh     ;unlock extended registers
  541.    out   dx,ax
  542.    mov   ah,byte ptr OSEG[curbk]
  543.     shl   ah,1     ;change 64k bank number into 4k bank number
  544.     shl   ah,1
  545.     shl   ah,1
  546.     shl   ah,1
  547.     mov   al,45h
  548.     out   dx,ax
  549.     sti
  550.     pop   dx
  551.     pop   ax
  552.     ret
  553.  
  554. _vesa:            ;Vesa SVGA interface
  555.     push  ax
  556.     push  bx
  557.     push  cx
  558.     push  dx
  559.     mul        [vesashift]            ; Adjust with granularity factor
  560. ; these were the old lines
  561. ;    mov   cl,[vesashift]
  562. ;    shl   ax,cl
  563.     mov   dx,ax
  564. push dx
  565.     xor   bx,bx        ; clear bx (ie set to window A)
  566.     mov   ax,4f05h
  567.     int   10h
  568. pop    dx
  569. mov    bx, 1
  570. mov    ax, 4f05h
  571. int    10h
  572.     pop   dx
  573.     pop   cx
  574.     pop   bx
  575.     pop   ax
  576.     ret
  577.  
  578.  
  579. _cirrus:
  580.     push    ax
  581.     push    dx
  582.  
  583. ; this enabling has been moved to the install routine - is it needed ?????
  584. ;    mov    dx, 3c4h        ; enable extended regs
  585. ;    mov    ax, 6
  586. ;    out    dx, ax
  587. ;    mov    ax, 12h
  588. ;    out    dx, ax
  589.  
  590.     mov    dx, 3ceh
  591.     shl    al, 4            ; convert to 4k bank number
  592.     mov    ah, al
  593.     mov     al, 9
  594.     out    dx, ax
  595.  
  596. ;    mov    dx, 3c4h        ; disable extended regs
  597. ;    mov    ax, 6
  598. ;    out    dx, ax
  599. ;    mov    ax, 0
  600. ;    out    dx, ax
  601.  
  602.     sti
  603.     pop    dx
  604.     pop    ax
  605.     ret
  606.  
  607. _nobank:
  608.     sti
  609.     ret
  610.  
  611. newbank  endp
  612.  
  613.  
  614. ;
  615. ;
  616. ;
  617. bkadr macro func
  618.     mov   [func],1
  619.     mov   [bankadr],offset _&func
  620. if @Codesize
  621.     mov   [bankseg],seg _&func
  622. endif
  623.     endm
  624.  
  625.  
  626.  
  627. ;
  628. ; force the video card bank switching
  629. ;
  630.  
  631. forcevga proc vid_card:word
  632.  
  633.     mov   [bankadr],offset _nobank   ; default for Cirrus???
  634. if @Codesize
  635.     mov   [bankseg],seg _nobank
  636. endif
  637.  
  638.     mov ax, [vid_card]
  639.     cmp   ax, 15
  640.     jnz   no_vesa        ; VESA ?
  641.     bkadr vesa
  642.     mov   [vga512],1
  643.     mov   [vga1024],1
  644.     jmp   finish
  645.  
  646. no_vesa:
  647.     cmp    ax, 16        ; S3 chips ???  like VESA???
  648.     jnz    try_speed
  649.     bkadr S3_card
  650.     jmp    finish
  651.  
  652. try_speed:
  653.     cmp    ax, 17        ; Speedstar 24X
  654.     jnz    try_realtek
  655.     bkadr speedstar
  656.     jmp    finish
  657.  
  658. try_realtek:
  659.     cmp    ax, 18        ; RealTek
  660.     jnz    try_XGA
  661.     bkadr realtek
  662.     jmp finish
  663.  
  664. try_XGA:
  665.     cmp    ax, 18        ; XGA
  666.     jnz    try_ati
  667.     bkadr    XGA
  668.     jmp    finish
  669.  
  670. try_ati:
  671.     cmp   ax, 2         ; ati
  672.     jnz   no_ati
  673.  
  674. ;    mov   [vga1024],1        ; hi_color has 1 meg
  675.     bkadr ativga
  676. ;    mov   [vga512],1     ; forcing 512k - may not exist???
  677.  
  678.     mov   ax, 0c000h     ; find the location of the ATI extended reg
  679.     mov   es, ax
  680.     mov   bx, 10h
  681.     mov   dx, es:[bx] ; fetch the extended reg value
  682.     mov   [ati_extended], dx
  683.  
  684.     jmp   finish
  685.  
  686. no_ati:     ;Test for Everex
  687.     cmp   ax, 4
  688.     jnz   no_ev
  689.     bkadr everex
  690. ;    mov   [vga512],1
  691.     jmp   finish
  692.  
  693. no_ev:         ;Test for Compaq
  694.     cmp   ax, 14
  695.     jnz   no_cp
  696.     bkadr compaq
  697. ;    mov   [vga512],1
  698.     jmp   finish
  699.  
  700. no_cp:            ;Test for NCR 77C22E
  701.     cmp   ax, 7
  702.     jnz   non_cr
  703.     bkadr ncr
  704. ;    mov   [vga512],1
  705.     jmp   finish
  706.  
  707. non_cr:        ;Test for Trident 8800 or 8900
  708.     cmp   ax, 9
  709.     jnz   no_tri
  710.     bkadr trident
  711. ;    mov [vga512], 1        /* trident 8800 */
  712. ;  mov [vga1024], 1        /* trident 8900 */
  713.     jmp   finish
  714.  
  715. no_tri:     ;Test for Video 7
  716.     cmp   ax, 12
  717.     jnz   nov_7
  718.     bkadr video7
  719. ;    mov   [vga1024],1
  720.     jmp   finish
  721.  
  722. nov_7:         ;Test for GENOA GVGA
  723.     cmp   ax, 6
  724.     jnz   no_ci
  725.     bkadr genoa
  726. ;    mov   [vga512],1
  727.     jmp   finish
  728.  
  729. no_ci:         ;Test for Paradise
  730.     cmp   ax, 8
  731.     jnz   no_pd
  732.     bkadr paradise
  733. ;    mov   [vga512],1
  734.     jmp   finish
  735.  
  736. no_pd:      ;Test for Chips & Tech
  737.     cmp   ax, 3
  738.     jnz   no_ct
  739.     bkadr chipstech
  740. ;    mov   [vga512],1
  741.     jmp   finish
  742.  
  743. no_ct:
  744.     cmp   ax, 10        ; check tseng
  745.     jnz    not_tseng
  746.  
  747.     bkadr tseng
  748. ;    mov   [vga512],1
  749.     jmp   finish
  750.  
  751. not_tseng:
  752.     cmp   ax, 11
  753.     jnz   no_ts
  754. ;    mov   [vga1024],1    ;full meg with eight 256kx4 RAMs
  755.     bkadr tseng4
  756.     jmp   finish
  757.  
  758. no_ts:
  759.     cmp   ax, 0        ; ahead a?
  760.     jnz   verb
  761.     bkadr aheada
  762. ;    mov   [vga512],1
  763.     jmp   finish
  764.  
  765. verb:            ; ahead b?
  766.   cmp   ax, 1
  767.   jnz        no_ab
  768.   bkadr aheadb
  769. ;  mov   [vga512],1
  770.   jmp   short finish
  771.  
  772. no_ab:         ;Test for Oak Technology
  773.     cmp   ax, 5
  774.     jnz   no_gn
  775.     bkadr oaktech
  776. ;    mov   [vga512],1
  777.     jmp   finish
  778.  
  779. no_gn:         ;Test for Cirrus
  780.     cmp    ax, 13
  781.     jnz    no_luck
  782.     bkadr cirrus
  783.  
  784.     mov    dx, 3c4h        ; enable extended regs
  785.     mov    ax, 6
  786.     out    dx, ax
  787.     mov    ax, 12h
  788.     out    dx, ax
  789.     jmp finish
  790.  
  791. no_luck:
  792.     ret        ; who knows whats there so just return
  793.  
  794. finish:
  795.     mov    ax, 1        ; always return 1 in retval ie card svga = 1
  796. ;    mov   [retval],ax
  797.     ret
  798. forcevga endp
  799.  
  800. ;
  801. ;
  802. ;
  803.  
  804.  
  805. ; print a word wide point into video memory
  806. ; assume that we are filling from low to high
  807. ; -- if a 3 byte write is going to cross a page boundary then don't do it
  808. point_24    proc    xpos:word,ypos:word,color:dword
  809.     mov    ax, [xpos]
  810.     mov    bx, ax
  811.     shl    ax, 1                ; mult by 3 because of int width not byte
  812.     add    bx, ax
  813.     mov    ax,[ypos]
  814.     mul    [xwidth]            ;X size bytes wide in most cases
  815.     add    bx, ax
  816.     adc    dx,0
  817. ; test bx - if we are going to write on a word boundary then exit
  818.     cmp    bx, 0fffdh
  819.     jnc    problem_exit
  820.     mov    ax,dx
  821.     cmp    ax,[curbk]
  822.     jz    nonewo
  823.     call    newbank            ;switch banks if a new bank entered
  824. nonewo:    mov    ax,0a000h        ;setup screen segment A000
  825.     mov    es,ax
  826.     mov    cx, word ptr [color + 0]    ;get color of pixel to plot - low int
  827.     mov    es:[bx],cx
  828.     add    bx, 2
  829.     mov    cx, word ptr [color + 2]            ; hi byte
  830.     mov    byte ptr es:[bx], cl
  831. problem_exit:
  832.     ret
  833. point_24    endp
  834.  
  835.  
  836. point    proc    xpos:word, ypos:word, color:word
  837.  
  838.     mov    bx,[xpos]
  839.     mov    ax,[ypos]
  840. ;    mov    dx,[maxx]
  841. ;    cmp    bx,0            ; range checking not necessary since it will
  842. ;    jl    nope2                ;  always be within one 64k bank
  843. ;    cmp    bx,dx
  844. ;    jge    nope2
  845. ;    cmp    ax,0
  846. ;    jl    nope2
  847. ;    cmp    ax,[maxy]
  848. ;    jge    nope2
  849.     mul    [xwidth]            ;X size bytes wide in most cases
  850.     add    bx, ax
  851.     adc    dx,0
  852.     mov    ax,dx
  853.     cmp    ax,[curbk]
  854.     jz    nonew
  855.     call    newbank            ;switch banks if a new bank entered
  856. nonew:    mov    ax,0a000h        ;setup screen segment A000
  857.     mov    es,ax
  858.     mov    cl,byte ptr [color]    ;get color of pixel to plot
  859.     mov    es:[bx],cl
  860. nope2:    ret
  861. point    endp
  862.  
  863.  
  864.  
  865. ;
  866. ; print a word wide point into video memory
  867. ;  ASSUME:
  868. ;    - color word is in "color"
  869. ;    - X is in "xpos"
  870. ;    - Y is in "ypos"
  871. ;
  872. point_wide    proc    xpos:word,ypos:word,color:word
  873.  
  874.     mov    bx,[xpos]
  875.     shl    bx, 1                ; mult by 2 because of int width not byte
  876.     mov    ax,[ypos]
  877.     mul    [xwidth]            ;X size bytes wide in most cases
  878.     add    bx, ax
  879.     adc    dx,0
  880.     cmp    dx,[curbk]
  881.     jz        no_new_bank
  882.     mov    ax, dx            ; move bank number to ax
  883.     call    newbank            ;switch banks if a new bank entered
  884. no_new_bank:
  885.     mov    ax,0a000h        ;setup screen segment A000
  886.     mov    es,ax
  887.     mov    cx, [color]    ;get color of pixel to plot
  888.     mov    es:[bx],cx
  889.     ret
  890. point_wide    endp
  891.  
  892.  
  893.  
  894. ;    end
  895.  
  896.  
  897.  
  898. ;----------------------------------------------------------------------------
  899. ; void put16Pixel(int x,int y,int color)
  900. ;----------------------------------------------------------------------------
  901. ; Routine sets the value of a pixel in native VGA graphics modes.
  902. ;
  903. ; Entry:        x        -    X coordinate of pixel to draw
  904. ;                y        -    Y coordinate of pixel to draw
  905. ;                color    -    Color of pixel to draw
  906. ;
  907. ;----------------------------------------------------------------------------
  908.  
  909. put16Pixel proc x:word, y:word, color:word
  910.  
  911. ; this is done automagically by the decleration "proc"
  912. ;        push    bp                    ; Set up stack frame
  913. ;        mov        bp,sp
  914.  
  915. ; Compute the pixel's address in video buffer
  916.         mov        ax,[y]
  917.         mov        bx,[x]
  918.         mul        [xwidth]        ; DX:AX := y * BytesPerLine
  919.  
  920.         mov        cl,bl                ; CL := low-order byte of x
  921.  
  922.         shr        bx,3                ; BX := x/8
  923.         add        bx,ax
  924.         adc        dx,0                ; DX:BX := y*BytesPerLine + x/8
  925.  
  926. ; we are only using page #0 so this is not needed
  927. ;        add        bx,[OriginOffset]    ; DX:BX := byte offset in video buffer
  928. ;        adc        dx,[BankOffset]
  929.  
  930.         cmp        dx,[curbk]
  931.         je        @@NoChange
  932.         mov        ax,dx
  933.         call    newbank
  934.  
  935. @@NoChange:
  936.         mov        ax, 0A000h        ;VGABufferSeg
  937.         mov        es,ax                ; ES:BX := byte address of pixel
  938.  
  939.         mov        ah,1                ; AH := unshifted bit mask
  940.         and        cl,7                ; CL := x & 7
  941.         xor        cl,7                ; CL := # bits to shift left
  942.  
  943. ; set Graphics Controller Bit Mask register
  944.         shl        ah,cl                ; AH := bit mask in proper postion
  945.         mov        dx,3CEh                ; GC address register port
  946.         mov        al,8                ; AL := Bit Mask Register number
  947.         out        dx,ax
  948.  
  949. ; set Graphics Controller Mode register
  950.         mov        ax,0205h            ; AL := Mode register number
  951.                                     ; AH := Write mode 2 (bits 0,1)
  952.                                     ;    Read mode 0 (bit 3)
  953.         out        dx,ax
  954.  
  955. ; set data rotate/Function Select register
  956.         mov        ax,3                ; AL := Data Rotate/Func select reg #
  957.         out        dx,ax
  958.  
  959. ; set the pixel value
  960.         mov        al,[es:bx]            ; latch one byte from each bit plane
  961.         mov        ax,[color]            ; AL := pixel value
  962.         mov        [es:bx],al            ; update all bit planes
  963.  
  964. ; restore default Graphics Controller registers
  965.         mov        ax,0FF08h            ; default bit mask
  966.         out        dx,ax
  967.  
  968.         mov        ax,0005                ; default mode register
  969.         out        dx,ax
  970.  
  971.         mov        ax,0003                ; default function select
  972.         out        dx,ax
  973.  
  974. ;        pop        bp
  975.         ret
  976.  
  977. put16Pixel endp
  978.  
  979.  
  980. end
  981.  
  982.