home *** CD-ROM | disk | FTP | other *** search
/ PC Underground / UNDERGROUND.ISO / graphic / fade.asm < prev    next >
Assembly Source File  |  1995-07-28  |  2KB  |  75 lines

  1. data segment public
  2.   extrn colors:word
  3. data ends
  4.  
  5. code segment public
  6. assume cs:code,ds:data
  7. public fade_set,fade_ResetPic
  8.  
  9.  
  10. col db 0                        ;code segment pendant to colors
  11.  
  12.  
  13. fade_set proc pascal near source:dword, start:word, y:word, height:word
  14.   mov ax,colors                 ;colors entered in code segment variable col
  15.   mov col,al
  16.    push ds
  17.   mov ax,word ptr source + 2    ;source pointer to ds:si
  18.   mov ds,ax
  19.   mov si,word ptr source
  20.  
  21.   mov ax,320                    ;start address within the source image
  22.   mul start
  23.   add si,ax
  24.  
  25.   mov ax,0a000h                 ;destination pointer 0a000:0 to es:di
  26.   mov es,ax
  27.   mov ax,320                    ;start address within the destination image
  28.   mul y
  29.   mov di,ax
  30.  
  31.   mov ax,320                    ;convert height to number bytes
  32.   imul height
  33.   mov cx,ax
  34.  
  35. lp:                             ;main loop
  36.   lodsb                         ;destination value in al
  37.   mul col                       ;calculate new color value
  38.   add al,es:[di]                ;add current value
  39.   add al,col
  40.   stosb                         ;and write back
  41.  
  42.   dec cx                        ;all pixels copied ?
  43.   jne lp
  44.  
  45.   pop ds
  46.   ret
  47. fade_set endp
  48.  
  49. fade_ResetPic proc pascal far y:word, height:word
  50.   mov ax,0a000h                 ;VGA address 0a000:0 to es:di
  51.   mov es,ax
  52.  
  53.   mov ax,320                    ;take row y into consideration
  54.   mul y
  55.   mov di,ax
  56.  
  57.   mov ax,320                    ;calculate number bytes to be processed
  58.   mul height
  59.   mov cx,ax
  60. res_lp:
  61.   mov al,es:[di]                ;get value
  62.   xor ah,ah                     ;clear ah during division !
  63.   div byte ptr colors           ;calculate block number
  64.   dec al                        ;remove reset block
  65.   stosb                         ;write back
  66.  
  67.   dec cx                        ;all pixels finished ?
  68.   jne res_lp                    ;no, then continue
  69.  
  70.   ret
  71. fade_ResetPic endp
  72.  
  73. code ends
  74. end
  75.