Created
November 24, 2012 07:36
-
-
Save tuttlem/4138799 to your computer and use it in GitHub Desktop.
Smoke - Average
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bloom: | |
mov cx, 63680 ; we average every pixel except the top row | |
mov di, 320 ; we start at the 2nd row | |
next_avg: | |
xor ax, ax ; clear out our accumulator | |
mov al, es:[di] ; get the current pixel | |
add al, es:[di-1] ; add the pixel to the left | |
adc ah, 0 ; adjust for overflow | |
add al, es:[di+1] ; add the pixel to the right | |
adc ah, 0 ; adjust for overflow | |
add al, es:[di-320] ; add the pixel above | |
adc ah, 0 ; adjust for overflow | |
shr ax, 2 ; divide by 4 to get the average | |
cmp al, 0 ; can we dampen? | |
jz no_damp ; jump over if we can't | |
dec al ; dampen the colour by 1 | |
no_damp: | |
mov es:[di-320], al ; put the averaged pixel 1 pixel above | |
inc di ; next pixel | |
dec cx ; keep count of how many we've got left | |
jnz next_avg | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment