home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / comm / ykh121.zip / YKHSRC.ZIP / GFXLIB.ASM < prev    next >
Assembly Source File  |  1993-04-18  |  16KB  |  870 lines

  1. ;       3C4h index  2  (r/W): Sequencer: Map Mask Register
  2. ;         bit 0  Enable writes to plane 0 if set
  3. ;             1  Enable writes to plane 1 if set
  4. ;             2  Enable writes to plane 2 if set
  5. ;             3  Enable writes to plane 3 if set
  6. ;
  7. ;       3CEh index  4  (r/W): Graphics: Read Map Select Register
  8. ;       bit 0-1  Number of the plane read Mode 0 will read from.
  9.  
  10. .286c
  11.  
  12. INT_10H MACRO
  13.   PUSH BP
  14.   INT 10H
  15.   POP BP
  16. ENDM
  17.  
  18. INT_10HP MACRO
  19.   PUSH AX
  20.   PUSH BX
  21.   PUSH CX
  22.   PUSH DX
  23.   PUSH BP
  24.   PUSH DS
  25.   PUSH ES
  26.   PUSH SI
  27.   PUSH DI
  28.   INT 10H
  29.   POP DI
  30.   POP SI
  31.   POP ES
  32.   POP DS
  33.   POP BP
  34.   POP DX
  35.   POP CX
  36.   POP BX
  37.   POP AX
  38. ENDM
  39.  
  40.  
  41. VIDEOSEG EQU 0A000H
  42.  
  43. MAP_MASK  EQU 3c4h
  44. READ_MAP  EQU 3ceh
  45. MISC_OUT  EQU 3c2h
  46. CRTC_IDX  EQU 3d4h
  47.  
  48. ADAPTER_CGA EQU 0
  49. ADAPTER_EGA EQU 1
  50. ADAPTER_VGA EQU 2
  51.  
  52. GFXLIB_ERROR_OPEN EQU 1 ;file not found
  53. GFXLIB_ERROR_READ EQU 2 ;unexpected end of file
  54. GFXLIB_ERROR_CARD EQU 3 ;inadequate video card
  55. GFXLIB_ERROR_MODE EQU 4 ;unable to set requested mode
  56.  
  57. GFXLIB_TEXT    segment byte public 'CODE'
  58. GFXLIB_TEXT    ends
  59. DGROUP    group    _DATA,_BSS
  60.     assume    cs:GFXLIB_TEXT,ds:DGROUP
  61. _DATA    segment word public 'DATA'
  62. _DATA    ends
  63. _BSS    segment word public 'BSS'
  64. _BSS    ends
  65. GFXLIB_TEXT    segment byte public 'CODE'
  66.    ;
  67.  
  68. LAST_62: ;db (32*62) dup(0)
  69.  
  70. asciiseg  dw ?
  71. asciioffs dw ?
  72.  
  73. oldmode db ?
  74. adapter db ?
  75.  
  76.  
  77. ;
  78. ;int far GFX_deinit();
  79. ;
  80. _gfx_deinit proc far
  81.             xor ah,ah
  82.             mov al,cs:oldmode
  83.             INT_10HP
  84.             ret
  85. _gfx_deinit endp
  86.  
  87.  
  88.  
  89. ;
  90. ;int far GFX_init(unsigned scanlines,unsigned fg,unsigned bg,char far* filename);
  91. ;
  92. _gfx_init proc far
  93.           push bp
  94.           mov bp,sp
  95.  
  96.           push ds
  97.           push si
  98.           push es
  99.           push di
  100. ;
  101. ; beginning of video detect code
  102. ;
  103.           mov ax,1200h  ;detect presence of EGA/VGA
  104.           mov bl,10h    ;
  105.           INT_10H       ;
  106.           cmp bl,10h    ;
  107.           jne @@egg     ;
  108.  
  109.           mov ax,GFXLIB_ERROR_CARD
  110.           jmp @@end
  111.  
  112. @@egg:    mov cs:adapter,ADAPTER_EGA ;detect presence of VGA
  113.           mov ax,1a00h               ;
  114.           INT_10H                    ;
  115.           cmp bl,7                   ;
  116.           jb @@toast                 ;
  117.  
  118.           mov cs:adapter,ADAPTER_VGA
  119. @@toast:
  120. ;
  121. ; end of video detect code
  122. ;
  123.  
  124.  
  125. ;
  126. ; beginning of video init code
  127. ;
  128.           mov ax,0f00h
  129.           INT_10H
  130.           mov cs:oldmode,al
  131.  
  132.           cmp word ptr [bp+6],200
  133.           ja @@ega
  134.  
  135.           mov ax,0eh
  136.           jmp @@vid
  137.  
  138. @@ega:    cmp word ptr [bp+6],350
  139.           ja @@vga
  140.  
  141.           mov ax,10h
  142.           jmp @@vid
  143.  
  144. @@vga:    cmp cs:adapter,ADAPTER_VGA
  145.           jnb @@okvga
  146.  
  147.           mov ax,GFXLIB_ERROR_MODE
  148.           jmp @@end
  149.  
  150. @@okvga:  mov ax,12h
  151.  
  152. @@vid:    INT_10HP
  153.           cmp cs:adapter,ADAPTER_VGA
  154.           jb @@no400
  155.           cmp word ptr [bp+6],400
  156.           ja @@no400
  157.           cmp word ptr [bp+6],350
  158.           jna @@no400
  159. ;
  160. ; forces VGA into 640x400 mode
  161. ;
  162.           SC_INDEX       EQU 003C4h
  163.           SC_DATA        EQU 003C5h
  164.           CRTC_INDEX     EQU 003D4h
  165.           CRTC_DATA      EQU 003D5h
  166.           MISC_OUTPUT    EQU 003C2h
  167.           MISC_OUTPUT_IN EQU 003CCh
  168.           SCREEN_SEG     EQU 0A000h
  169.  
  170.           MOV DX,SC_INDEX    ;
  171.           MOV AX,0100H       ;SYNCHRONOUS RESET WHILE SWITCHING CLOCKS
  172.           OUT DX,AX          ;
  173. ;
  174. ;------------------------------------------------------
  175.           MOV DX,MISC_OUTPUT ;
  176.           MOV AL,063H        ;SELECT 400 LINE MODE
  177.           OUT DX,AL          ;
  178. ;------------------------------------------------------
  179. ;
  180.           MOV DX,SC_INDEX    ;UNDO RESET
  181.           MOV AX,0300H       ;
  182.           OUT DX,AX          ;
  183.  
  184.           mov dx,CRTC_INDEX  ;
  185.           mov ax,02716h      ;
  186.           out dx,ax          ;
  187.           mov ax,0b815h      ;
  188.           out dx,ax          ;
  189.  
  190. @@no400:
  191.           mov ax,1000h   ;
  192.           xor bl,bl      ;
  193.           mov cx,8       ;
  194.           mov dl,[bp+8 ] ;
  195.           mov dh,[bp+10] ;
  196.  
  197. @@pal:    mov bh,dh    ;set palette entry to background color
  198.           INT_10HP     ;
  199.           inc bl       ;
  200.           mov bh,dl    ;set palette entry to foreground col
  201.           INT_10HP     ;
  202.           inc bl       ;
  203.           loop @@pal   ;repeat 8 times, for a total of 16 entries
  204.  
  205.  
  206.           mov bh,6                   ;get 16 point font if VGA,
  207.           cmp cs:adapter,ADAPTER_VGA ;
  208.           je @@getfont               ;
  209.           mov bh,2                   ;14 point font if EGA
  210. @@getfont:
  211.           mov ax,1130h         ;get location of ASCII font
  212.           push bp              ;
  213.           push ds
  214.           int 10h              ;
  215.           mov cs:asciiseg,es   ;
  216.           mov cs:asciioffs,bp  ;
  217.           pop ds
  218.           pop bp               ;
  219.  
  220. ;
  221. ; end of video init code
  222. ;
  223.           jmp @@win
  224.           lds dx,[bp+12] ;DS:DX now points to filename
  225.  
  226.           mov ax,3d00h   ;DOS open file function
  227.           int 21h        ;
  228.  
  229.           jnc @@open
  230.  
  231.           call _gfx_deinit
  232.           mov ax,GFXLIB_ERROR_OPEN ;file not found.
  233.           jmp @@end                ;return with error code
  234.  
  235. @@open:   mov bx,ax        ;handle must be in BX for DOS file functions
  236.           mov dx,VIDEOSEG  ;
  237.           mov ds,dx        ;DS:DX will soon point to video memory
  238.  
  239.           mov bp,0202H        ;store video plane picker in BP
  240.  
  241. @@loop:   mov dx,MAP_MASK   ;
  242.           mov ax,bp         ;
  243.           out dx,ax         ;pick a video plane for writing
  244.  
  245. @@read:   mov ax,3f00h     ;read 32768 bytes into first half
  246.           mov cx,32768     ;of video plane
  247.           xor dx,dx        ;
  248.           int 21h          ;DOS read file function
  249.  
  250.           cmp cx,ax        ;if 32768 bytes were read, go read more
  251.           je @@half        ;
  252.  
  253.           mov ax,3e00h          ;unexpected end of file.
  254.           int 21h               ;DOS close file function
  255.  
  256.           call _gfx_deinit
  257.           mov ax,GFXLIB_ERROR_READ ;
  258.           jmp @@end             ;return with error code
  259.  
  260. @@half:   mov ax,3f00h     ;read 32768 bytes into second half
  261.           mov cx,32768     ;of video plane
  262.           mov dx,cx        ;
  263.           int 21h          ;DOS read file function
  264.  
  265.           cmp cx,ax        ;if 32768 bytes were read, go read more
  266.           je @@done        ;if there was an error, close the file and exit
  267.  
  268.           mov ax,3e00h          ;unexpected end of file.
  269.           int 21h               ;DOS close file function
  270.           call _gfx_deinit
  271.           mov ax,GFXLIB_ERROR_READ ;
  272.           jmp @@end             ;return with error code
  273.  
  274. @@done:   mov ax,bp             ;rotate plane picker to select next plane
  275.           shl ah,1              ;if we have already read three,
  276.           mov bp,ax             ;
  277.           test ah,0f0h          ;
  278.           jnz @@final           ;go read the last chunk of data
  279.  
  280.           jmp @@loop            ;jump back to read another plane
  281.  
  282. @@final:  mov dx,MAP_MASK ;select plane zero for writing
  283.           mov ax,0102H    ;
  284.           out dx,ax       ;
  285.  
  286.           mov ax,3f00h     ;load all remaining kanji but 62 just below the
  287.           mov cx,27136     ;480th line of the 640x480 video page
  288.           mov dx,(80*480)  ;
  289.           int 21h          ;DOS read file function
  290.  
  291.           cmp cx,ax
  292.           jne @@jclose
  293.  
  294.           mov ax,3f00h     ;load final 62 kanji
  295.           mov cx,(32*62)   ;into code segment
  296.           lea dx,LAST_62   ;(weird!)
  297.           push cs          ;
  298.           pop ds           ;
  299.           int 21h          ;
  300.  
  301. @@jclose: mov dx,ax        ;did we get all the kanji we asked for?
  302.           mov ax,3e00h     ;wait until we close the file to decide.
  303.           int 21h          ;DOS close file function
  304.           cmp dx,cx        ;if all kanji were read, we have won.
  305.           je @@win         ;
  306.  
  307.           call _gfx_deinit
  308.           mov ax,GFXLIB_ERROR_READ ;unexpected end of file.
  309.           jmp @@end                ;return with error code
  310.  
  311. @@win:    mov dx,READ_MAP   ;pick a plane for reading
  312.           mov ax,0004H      ;
  313.           out dx,ax         ;
  314.  
  315.           mov dx,MAP_MASK   ;pick plane zero for writing
  316.           mov ax,0102h      ;
  317.           out dx,ax         ;
  318.           xor ax,ax         ;return with 0
  319.  
  320. @@end:    pop di
  321.           pop es
  322.           pop si
  323.           pop ds
  324.           pop bp
  325.           ret
  326. _gfx_init endp
  327.  
  328.  
  329. ;
  330. ; void far GFX_put(unsigned GFX,unsigned scanline, unsigned column)
  331. ;
  332. _gfx_put proc far
  333.          push bp
  334.          mov bp,sp
  335.  
  336.          push ds
  337.          push si
  338.          push es
  339.          push di
  340.  
  341.          mov ax,80*16        ;
  342.          mul word ptr [bp+8] ;multiply scanline by bytes/scanline
  343.          mov di,ax           ;
  344.          add di,[bp+10]      ;add column to obtain video offset
  345.          add di,3200
  346.  
  347.          mov ax,di       ;forbid attempts to overwrite GFX table
  348.          add ax,(80*15+1);
  349.          cmp ax,(80*480) ;
  350.          jna @@adjust    ;
  351.          jmp @@putend    ;
  352.  
  353. @@adjust:mov ax,VIDEOSEG ;set up segments
  354.          mov ds,ax       ;
  355.          mov es,ax       ;
  356.  
  357.          mov si,[bp+6]  ;load GFX code into SI
  358.          mov ax,si
  359.          mov cl,3
  360.          shr ah,cl
  361.          mov cl,5
  362.          shl si,cl
  363.  
  364.          ;SI = ((GFX*32)%65536) ;GFX "offset"
  365.          ;AH = GFX/2048         ;GFX "segment"
  366.  
  367.          inc ah
  368.          and ah,3
  369.          jnz @@putit
  370.  
  371.          add si,(80*480)
  372.          cmp si,(80*480)
  373.          jae @@putit
  374.          add si,OFFSET LAST_62
  375.          push cs
  376.          pop ds
  377.  
  378. @@putit: mov dx,READ_MAP   ;pick a plane for reading
  379.          mov al,04H        ;
  380.          out dx,ax         ;
  381.  
  382.          mov dx,MAP_MASK   ;pick plane zero for writing
  383.          mov ax,0102H      ;
  384.          out dx,ax         ;
  385.  
  386.          mov ax,78
  387.          mov cx,16
  388.  
  389. @@putit2:movsw         ;copy lines to video memory
  390.          add di,ax     ;
  391.          loop @@putit2
  392.  
  393. @@putend:mov dx,READ_MAP   ;pick a plane for reading
  394.          mov ax,0004H      ;
  395.          out dx,ax         ;
  396.  
  397.          mov dx,MAP_MASK   ;pick plane zero for writing
  398.          mov ax,0102h      ;
  399.          out dx,ax         ;
  400.  
  401.          pop di
  402.          pop es
  403.          pop si
  404.          pop ds
  405.          pop bp
  406.          ret
  407. _gfx_put endp
  408.  
  409.  
  410. ;
  411. ; void far ascii_put(unsigned ascii,unsigned scanline, unsigned column)
  412. ;
  413. _gfx_ascii_put proc far
  414.          push bp
  415.          mov bp,sp
  416.  
  417.          push ds
  418.          push si
  419.          push es
  420.          push di
  421.  
  422.          mov ax,80*16        ;
  423.          mul word ptr [bp+8] ;multiply scanline by bytes/scanline
  424.          mov di,ax           ;
  425.          add di,[bp+10]      ;add column to obtain video offset
  426.          add di,3200
  427.  
  428.          mov ax,di       ;forbid attempts to overwrite GFX table
  429.          add ax,(80*15)  ;
  430.          cmp ax,(80*480) ;
  431.          jna @@asciifoo    ;
  432.          jmp @@asciiend    ;
  433.  
  434. @@asciifoo:mov ax,VIDEOSEG
  435.          mov es,ax
  436.          mov ds,cs:asciiseg
  437.          mov si,[bp+6]     ;SI = ascii character code
  438.  
  439.          mov bx,79
  440.          cmp cs:adapter,ADAPTER_VGA
  441.          je @@funfun
  442.          call ascii14
  443.          jmp @@asciiend
  444. @@funfun:call ascii16
  445.  
  446. @@asciiend:pop di
  447.          pop es
  448.          pop si
  449.          pop ds
  450.          pop bp
  451.          ret
  452. _gfx_ascii_put endp
  453.  
  454.  
  455. ascii14 proc near
  456.         mov ax,14
  457.         mul si
  458.         mov si,ax
  459.         add si,cs:asciioffs
  460.  
  461.         mov cx,14
  462.  
  463.         xor al,al
  464.         stosb
  465.         add di,bx
  466. @@jujube:
  467.         movsb
  468.         add di,bx
  469.         loop @@jujube
  470.  
  471.         stosb
  472.  
  473.         ret
  474. ascii14 endp
  475.  
  476.  
  477. ascii16 proc near
  478.         mov cl,4
  479.         shl si,cl
  480.         add si,cs:asciioffs
  481.  
  482.         mov cx,16
  483. @@twojube:
  484.         movsb
  485.         add di,bx
  486.         loop @@twojube
  487.         ret
  488. ascii16 endp
  489.  
  490.  
  491. ;
  492. ; void far GFX_clear(unsigned scanline, unsigned column,
  493. ;                    unsigned scanlines, unsigned columns);
  494. ;
  495. _gfx_clear proc far
  496.            push bp
  497.            mov bp,sp
  498.  
  499.            push es
  500.            push di
  501.  
  502.            mov di,VIDEOSEG
  503.            mov es,di
  504.            mov ax,[bp+6]
  505.            mov di,80*16
  506.            mul di
  507.            mov di,ax
  508.            add di,[bp+8]
  509.            add di,3200
  510.            xor al,al
  511.  
  512.            shl word ptr [bp+10],4
  513.  
  514. @@clr:       mov cx,[bp+12]
  515. rep        stosb
  516.            sub di,[bp+12]
  517.            add di,80
  518.            dec word ptr [bp+10]
  519.            jnz @@clr
  520.  
  521.            pop di
  522.            pop es
  523.            pop bp
  524.            ret
  525. _gfx_clear endp
  526.  
  527.  
  528. ;
  529. ; void far GFX_set(unsigned scanline, unsigned column,
  530. ;                  unsigned scanlines, unsigned columns);
  531. ;
  532. _gfx_set proc far
  533.          push bp
  534.          mov bp,sp
  535.  
  536.          push es
  537.          push di
  538.  
  539.          mov di,VIDEOSEG
  540.          mov es,di
  541.          mov ax,[bp+6]
  542.          mov di,80*16
  543.          mul di
  544.          mov di,ax
  545.          add di,[bp+8]
  546.          add di,3200
  547.          mov al,0FFH
  548.  
  549.          shl word ptr [bp+10],4
  550.  
  551.          jmp @@clr
  552.          ;
  553.          ; NO RET
  554.          ;
  555. _gfx_set endp
  556.  
  557.  
  558. ;
  559. ; void far GFX_xor(unsigned scanline, unsigned column,
  560. ;                  unsigned scanlines, unsigned columns);
  561. ;
  562. _gfx_xor proc far
  563.          push bp
  564.          mov bp,sp
  565.  
  566.          push es
  567.          push di
  568.  
  569.          mov di,VIDEOSEG
  570.          mov es,di
  571.          mov ax,[bp+6]
  572.          mov di,80*16
  573.          mul di
  574.          mov di,ax
  575.          add di,[bp+8]
  576.          add di,3200
  577.          xor al,al
  578.  
  579.          shl word ptr [bp+10],4
  580.  
  581. @@clx:     mov cx,[bp+12]
  582.  
  583. @@cly:   not byte ptr es:[di]
  584.          inc di
  585.          loop @@cly
  586.  
  587.          sub di,[bp+12]
  588.          add di,80
  589.          dec word ptr [bp+10]
  590.          jnz @@clx
  591.  
  592.          pop di
  593.          pop es
  594.          pop bp
  595.          ret
  596. _gfx_xor endp
  597.  
  598.  
  599. ;
  600. ; void far GFX_gray(unsigned scanline, unsigned column,
  601. ;                   unsigned scanlines, unsigned columns);
  602. ;
  603. _gfx_gray proc far
  604.          push bp
  605.          mov bp,sp
  606.  
  607.          push es
  608.          push di
  609.  
  610.          mov di,VIDEOSEG
  611.          mov es,di
  612.          mov ax,[bp+6]
  613.          mov di,80*16
  614.          mul di
  615.          mov di,ax
  616.          add di,[bp+8]
  617.          add di,3200
  618.          xor al,al
  619.          mov bl,55H
  620.  
  621.          shl word ptr [bp+10],4
  622.  
  623. @@gra:     mov cx,[bp+12]
  624. @@grb:   and es:[di],bl
  625.          inc di
  626.          loop @@grb
  627.  
  628.          sub di,[bp+12]
  629.          add di,80
  630.          not bl
  631.          dec word ptr [bp+10]
  632.          jnz @@gra
  633.  
  634.          pop di
  635.          pop es
  636.          pop bp
  637.          ret
  638. _gfx_gray endp
  639.  
  640.  
  641. ;
  642. ; void far GFX_bold8(unsigned scanline, unsigned column,
  643. ;                    unsigned scanlines, unsigned columns);
  644. ;
  645. _gfx_bold8 proc far
  646.          push bp
  647.          mov bp,sp
  648.  
  649.          push es
  650.          push di
  651.  
  652.          mov di,VIDEOSEG
  653.          mov es,di
  654.          mov ax,[bp+6]
  655.          mov di,80*16
  656.          mul di
  657.          mov di,ax
  658.          add di,[bp+8]
  659.          add di,3200
  660.  
  661.          shl word ptr [bp+10],4
  662.  
  663. @@bgra:     mov cx,[bp+12]
  664. @@bgrb:  mov al,es:[di]
  665.          shr al,1
  666.          or es:[di],al
  667.          inc di
  668.          loop @@bgrb
  669.  
  670.          sub di,[bp+12]
  671.          add di,80
  672.          dec word ptr [bp+10]
  673.          jnz @@bgra
  674.  
  675.          pop di
  676.          pop es
  677.          pop bp
  678.          ret
  679. _gfx_bold8 endp
  680.  
  681.  
  682. ;
  683. ; void far GFX_underline(unsigned scanline, unsigned column,
  684. ;                        unsigned scanlines, unsigned columns);
  685. ;
  686. _gfx_underline proc far
  687.          push bp
  688.          mov bp,sp
  689.  
  690.          push es
  691.          push di
  692.  
  693.          mov di,VIDEOSEG
  694.          mov es,di
  695.          mov ax,[bp+6]
  696.          mov di,80*16
  697.          mul di
  698.          mov di,ax
  699.          add di,[bp+8]
  700.          add di,3200
  701.  
  702.          add di,80*15
  703.          mov al,0FFH
  704.  
  705. @@ugra:     mov cx,[bp+12]
  706.          rep stosb
  707.          sub di,[bp+12]
  708.          add di,80*16
  709.  
  710.          dec word ptr [bp+10]
  711.          jnz @@ugra
  712.  
  713.          pop di
  714.          pop es
  715.          pop bp
  716.          ret
  717. _gfx_underline endp
  718.  
  719.  
  720. ;
  721. ; void far GFX_fcopy(unsigned srcy,   unsigned srcx,
  722. ;                    unsigned desty,  unsigned destx,
  723. ;                    unsigned height, unsigned width  );
  724. ;
  725. _gfx_fcopy proc far
  726.          push bp
  727.          mov bp,sp
  728.  
  729.          push ds  ;save data and extra segments
  730.          push si  ;
  731.          push es  ;
  732.          push di  ;
  733.  
  734.          mov di,VIDEOSEG ;set up segments for video transfer
  735.          mov es,di       ;
  736.          mov ds,di       ;
  737.  
  738.          mov ax,[bp+6]  ;set up source register
  739.          mov si,80*16   ;
  740.          mul si         ;
  741.          mov si,ax      ;
  742.          add si,[bp+8]  ;
  743.          add si,3200
  744.  
  745.          mov ax,[bp+10] ;set up destination register
  746.          mov di,80*16   ;
  747.          mul di         ;
  748.          mov di,ax      ;
  749.          add di,[bp+12] ;
  750.          add di,3200
  751.  
  752.          shl word ptr [bp+14],4
  753.  
  754.          mov bx,80
  755.          mov dx,[bp+16]
  756.          sub bx,dx
  757.          js @@copend
  758.          cld
  759. @@cop1:
  760.          mov cx,dx
  761.          shr cx,1
  762.          jz @@cop2
  763. rep      movsw
  764. @@cop2:     jnc @@cop3
  765.          movsb
  766. @@cop3:
  767.  
  768.          add si,bx
  769.          add di,bx
  770.          dec word ptr [bp+14]
  771.          jnz @@cop1
  772.  
  773. @@copend:
  774.          pop di
  775.          pop es
  776.          pop si
  777.          pop ds
  778.          pop bp
  779.          ret
  780. _gfx_fcopy endp
  781.  
  782.  
  783. ;
  784. ; void far GFX_bcopy(unsigned srcy,   unsigned srcx,
  785. ;                    unsigned desty,  unsigned destx,
  786. ;                    unsigned height, unsigned width  );
  787. ;
  788. _gfx_bcopy proc far
  789.          push bp
  790.          mov bp,sp
  791.  
  792.          push ds  ;save data and extra segments
  793.          push si  ;
  794.          push es  ;
  795.          push di  ;
  796.  
  797.          mov di,VIDEOSEG ;set up segments for video transfer
  798.          mov es,di       ;
  799.          mov ds,di       ;
  800.  
  801.          mov ax,[bp+6]  ;set up source register
  802.          mov si,80*16   ;
  803.          mul si         ;
  804.          mov si,ax      ;
  805.          add si,[bp+8]  ;
  806.          add si,3200
  807.  
  808.          mov ax,[bp+10] ;set up destination register
  809.          mov di,80*16   ;
  810.          mul di         ;
  811.          mov di,ax      ;
  812.          add di,[bp+12] ;
  813.          add di,3200
  814.  
  815.          mov ax,80*16
  816.          mul word ptr [bp+14]
  817.          sub ax,80
  818.          add ax,[bp+16]
  819.          dec ax
  820.  
  821.          shl word ptr [bp+14],4
  822.  
  823.          add si,ax
  824.          add di,ax
  825.  
  826.          mov bx,80
  827.          mov dx,[bp+16]
  828.          sub bx,dx
  829.  
  830.          std
  831. @@bcop1:
  832.          mov cx,dx
  833. rep         movsb
  834.  
  835.          sub si,bx
  836.          sub di,bx
  837.          dec word ptr [bp+14]
  838.          jnz @@bcop1
  839.  
  840.          cld
  841.          pop di
  842.          pop es
  843.          pop si
  844.          pop ds
  845.          pop bp
  846.          ret
  847. _gfx_bcopy endp
  848.  
  849.  
  850.  
  851.    ;
  852. GFXLIB_TEXT    ends
  853.  
  854.     public    _gfx_init
  855.     public    _gfx_deinit
  856.     public  _gfx_put
  857.     public  _gfx_ascii_put
  858.     public  _gfx_clear
  859.     public  _gfx_set
  860.     public  _gfx_xor
  861.     public  _gfx_gray
  862.     public  _gfx_bold8
  863.     public  _gfx_underline
  864.     public  _gfx_fcopy
  865.     public  _gfx_bcopy
  866.     end
  867.  
  868.  
  869.  
  870.