home *** CD-ROM | disk | FTP | other *** search
/ The Party 1994: Try This At Home / disk_image.bin / source / vexsrc / polyfilx.asm < prev    next >
Assembly Source File  |  1995-03-29  |  3KB  |  216 lines

  1. comment #
  2. /*****************************************************************************
  3.                                   ATTENTION!
  4.                            this source is VOTEWARE,
  5.               you may only use it to the conditions listed below:
  6.  
  7.   -You may modify it, or use parts of it in your own source as long as
  8.     this header stays on top of all files containing this source.
  9.   -You must give proper credit to the author, Niklas Beisert / pascal.
  10.   -You may not use it in commercial productions without the written
  11.     permission of the author.
  12.   -AND MOST IMPORTANT: you have to buy an Assembly '94 CD-ROM
  13.     by Sound Solutions (if you don't have it already) and vote for VEX-InTrO
  14.     in the PC-64k-Intro-Compo! (if you have already sent your voting card,
  15.     buy another one and fill it out CORRECTLY!!!)
  16. *****************************************************************************/
  17. #
  18.  
  19.  
  20.  
  21. ;// fills one line for the polygon routine.
  22. ;// for x mode and horizontally
  23. ;//  xfillliner reads before it writes => or-put
  24.  
  25. .model large,c
  26. .386
  27. locals
  28.  
  29. .data
  30.  
  31. extrn poly_width:word
  32. extrn poly_scrseg:word
  33. extrn poly_col:byte
  34. extrn poly_x:word
  35. extrn poly_y:word
  36. extrn poly_len:word
  37.  
  38. .code
  39.  
  40. public xfillline
  41. public xfillliner
  42.  
  43. blockbeg macro exp
  44. blocksize=(1 shl exp)
  45.   xchg ax,dx
  46.   mov ax,cx
  47.   and ax,blocksize-1
  48.   sub ax,blocksize
  49.   neg ax
  50.   sub di,ax
  51.   mov ah,(@@blockend-@@block) shr exp
  52.   mul ah
  53.   add ax,offset @@block
  54.   xchg ax,dx
  55.   shr cx,exp
  56.   inc cx
  57.   jmp dx
  58. @@block:
  59. dioffs=0
  60. endm
  61.  
  62. blockend macro
  63. @@blockend:
  64.   add di,dioffs
  65.   dec cx
  66.   jnz @@block
  67. endm
  68.  
  69. xfillline proc uses ds di
  70.   mov ax,poly_y
  71.   mul poly_width
  72.   add ax,poly_x
  73.   adc dx,0
  74.   mov cl,al
  75.   and cl,3
  76.   shrd ax,dx,2
  77.   add ax,poly_scrseg
  78.   mov di,ax
  79.   mov ax,1102h
  80.   rol ah,cl
  81.  
  82.   mov bl,poly_col
  83.   mov cx,poly_len
  84.  
  85.   mov dx,0a000h
  86.   mov es,dx
  87.  
  88.   mov dx,3c4h
  89.  
  90.   cmp cx,4
  91.   jl @@small
  92.   cmp al,11h
  93.   je @@ok3
  94. @@loop1:
  95.     out dx,ax
  96.     mov es:[di],bl
  97.     dec cx
  98.     rol ah,1
  99.     jnc @@loop1
  100.   inc di
  101. @@ok3:
  102.   mov ah,0Fh
  103.   out dx,ax
  104.   push cx
  105.   shr cx,2
  106.   mov bh,bl
  107.   mov ax,bx
  108.   shl eax,16
  109.   mov ax,bx
  110.  
  111.   cmp cx,4
  112.   jl @@small2
  113.  
  114.   test di,3
  115.   jz @@ok4
  116. @@loop2:
  117.     stosb
  118.     dec cx
  119.   test di,3
  120.   jnz @@loop2
  121. @@ok4:
  122.  
  123.   push cx
  124.   shr cx,2
  125.   rep stosd
  126.   pop cx
  127.   and cx,3
  128.  
  129. @@small2:
  130.   rep stosb
  131.  
  132.   pop cx
  133.   and cx,3
  134.   mov dx,3c4h
  135.   mov ax,1102h
  136. @@small:
  137.   jcxz @@done
  138. @@smallloop:
  139.     out dx,ax
  140.     mov es:[di],bl
  141.     rol ah,1
  142.     adc di,0
  143.   loop @@smallloop
  144. @@done:
  145.  
  146.   ret
  147. endp
  148.  
  149. xfillliner proc uses ds di
  150.   mov ax,poly_y
  151.   mul poly_width
  152.   add ax,poly_x
  153.   adc dx,0
  154.   mov cl,al
  155.   and cl,3
  156.   shrd ax,dx,2
  157.   add ax,poly_scrseg
  158.   mov di,ax
  159.   mov ax,1102h
  160.   rol ah,cl
  161.  
  162.   mov cx,poly_len
  163.   mov bl,poly_col
  164.  
  165.   mov dx,0a000h
  166.   mov ds,dx
  167.  
  168.   mov dx,3c4h
  169.  
  170.   cmp cx,4
  171.   jl @@small
  172.   cmp al,11h
  173.   je @@ok3
  174. @@loop1:
  175.     out dx,ax
  176.     mov bh,ds:[di]
  177.     mov ds:[di],bl
  178.     dec cx
  179.     rol ah,1
  180.     jnc @@loop1
  181.   inc di
  182. @@ok3:
  183.   mov ah,0Fh
  184.   out dx,ax
  185.   push cx
  186.   shr cx,2
  187.   mov al,bl
  188.  
  189.   blockbeg 5
  190.     rept blocksize
  191.       db 8ah, 65h, dioffs
  192.       db 88h, 45h, dioffs
  193.       dioffs=dioffs+1
  194.     endm
  195.   blockend
  196.  
  197.   pop cx
  198.   and cx,3
  199.   mov dx,3c4h
  200.   mov ax,1102h
  201. @@small:
  202.   jcxz @@done
  203. @@smallloop:
  204.     out dx,ax
  205.     mov bh,ds:[di]
  206.     mov ds:[di],bl
  207.     rol ah,1
  208.     adc di,0
  209.   loop @@smallloop
  210. @@done:
  211.  
  212.   ret
  213. endp
  214.  
  215. end
  216.