home *** CD-ROM | disk | FTP | other *** search
/ The Party 1994: Try This At Home / disk_image.bin / source / vexsrc / colors2.asm < prev    next >
Assembly Source File  |  1995-03-29  |  3KB  |  183 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. ;// palette set and interpolate functions
  22.  
  23. .model large, c
  24. .386
  25. locals
  26.  
  27. .code
  28.  
  29. public GetColors
  30. public SetColors
  31. public SetColorsBlack
  32. public SetColor
  33. public MakeFadeStep
  34. public InterpolCols
  35.  
  36. MakeFadeStep proc uses ds si di, cols:dword, colss:dword, colsd:dword, n:word, s:word
  37.   cld
  38.   lds si,colsd
  39.   lfs bx,colss
  40.   sub bx,si
  41.   les di,cols
  42.   mov cx,n
  43.   shl cx,1
  44.   add n,cx
  45.   jz @@end
  46.   mov dx,s
  47.   mov dh,128
  48.   sub dh,dl
  49.  
  50. @@lp:
  51.     mov al,fs:[bx+si]
  52.     mul dh
  53.     mov cx,ax
  54.     lodsb
  55.     mul dl
  56.     add ax,cx
  57.     shr ax,7
  58.     stosb
  59.   dec n
  60.   jne @@lp
  61. @@end:
  62.   ret
  63. endp
  64.  
  65. InterpolCols proc uses si di, cols:dword, n:word, crs:word, cgs:word, cbs:word, crd:word, cgd:word, cbd:word
  66.   cld
  67.   les di,cols
  68.   mov cx,n
  69.   jcxz @@end
  70.   mov ax,32768
  71.   xor dx,dx
  72.   div cx
  73.   mov cx,ax
  74.   xor bx,bx
  75.   mov dx,128
  76.  
  77. @@lp:
  78.     mov al,byte ptr crs
  79.     mul dl
  80.     mov si,ax
  81.     mov al,byte ptr crd
  82.     mul dh
  83.     add ax,si
  84.     shr ax,7
  85.     stosb
  86.     mov al,byte ptr cgs
  87.     mul dl
  88.     mov si,ax
  89.     mov al,byte ptr cgd
  90.     mul dh
  91.     add ax,si
  92.     shr ax,7
  93.     stosb
  94.     mov al,byte ptr cbs
  95.     mul dl
  96.     mov si,ax
  97.     mov al,byte ptr cbd
  98.     mul dh
  99.     add ax,si
  100.     shr ax,7
  101.     stosb
  102.  
  103.     add bx,cx
  104.     mov dh,bh
  105.     mov dl,128
  106.     sub dl,dh
  107.   dec n
  108.   jne @@lp
  109. @@end:
  110.   ret
  111. endp
  112.  
  113. GetColors proc uses di, cols:dword, c0:word, n:word
  114.   cld
  115.   les di,cols
  116.   mov cx,n
  117.   shl cx,1
  118.   add cx,n
  119.   mov dx,3C7h
  120.   mov al,byte ptr c0
  121.   out dx,al
  122.   add dx,2
  123.   jcxz @@end
  124. @@lp:
  125.     in al,dx
  126.     shl al,2
  127.     stosb
  128.   loop @@lp
  129. @@end:
  130.   ret
  131. endp
  132.  
  133. SetColors proc uses ds si, cols:dword, c0:word, n:word
  134.   cld
  135.   lds si,cols
  136.   mov cx,n
  137.   shl cx,1
  138.   add cx,n
  139.   mov dx,3C8h
  140.   mov al,byte ptr c0
  141.   out dx,al
  142.   inc dx
  143.   jcxz @@end
  144. @@lp:
  145.     lodsb
  146.     shr al,2
  147.     out dx,al
  148.   loop @@lp
  149. @@end:
  150.   ret
  151. endp
  152.  
  153. SetColorsBlack proc
  154.   mov cx,300h
  155.   mov dx,3C8h
  156.   xor al,al
  157.   out dx,al
  158.   inc dx
  159. @@sc:
  160.   out dx,al
  161.   loop @@sc
  162.   ret
  163. endp
  164.  
  165. SetColor proc n:word, r:word, g:word, b:word
  166.   mov dx,3C8h
  167.   mov ax,n
  168.   out dx,al
  169.   inc dx
  170.   mov al,byte ptr r
  171.   shr al,2
  172.   out dx,al
  173.   mov al,byte ptr g
  174.   shr al,2
  175.   out dx,al
  176.   mov al,byte ptr b
  177.   shr al,2
  178.   out dx,al
  179.   ret
  180. endp
  181.  
  182. end
  183.