80 begin |
80 begin |
81 LandPixels[pixelY, pixelX]:= LandBackPixel(landX, landY); |
81 LandPixels[pixelY, pixelX]:= LandBackPixel(landX, landY); |
82 inc(drawPixelBG); |
82 inc(drawPixelBG); |
83 end |
83 end |
84 else if ((Land[landY, landX] and lfObject) <> 0) or (((LandPixels[pixelY, pixelX] and AMask) shr AShift) < 255) then |
84 else if ((Land[landY, landX] and lfObject) <> 0) or (((LandPixels[pixelY, pixelX] and AMask) shr AShift) < 255) then |
85 LandPixels[pixelY, pixelX]:= LandPixels[pixelY, pixelX] and (not AMASK) |
85 LandPixels[pixelY, pixelX]:= ExplosionBorderColorNoA |
86 end; |
86 end; |
87 end; |
87 end; |
88 |
88 |
89 procedure drawPixelEBC(landX, landY, pixelX, pixelY: Longint); inline; |
89 procedure drawPixelEBC(landX, landY, pixelX, pixelY: Longint); inline; |
90 begin |
90 begin |
197 nullPixel: |
197 nullPixel: |
198 for i:= fromPix to toPix do |
198 for i:= fromPix to toPix do |
199 begin |
199 begin |
200 calculatePixelsCoordinates(i, y, px, py); |
200 calculatePixelsCoordinates(i, y, px, py); |
201 if ((Land[y, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[y, i] > 255)) then |
201 if ((Land[y, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[y, i] > 255)) then |
202 LandPixels[py, px]:= LandPixels[py, px] and (not AMASK); |
202 LandPixels[py, px]:= ExplosionBorderColorNoA; |
203 end; |
203 end; |
204 icePixel: |
204 icePixel: |
205 for i:= fromPix to toPix do |
205 for i:= fromPix to toPix do |
206 begin |
206 begin |
207 calculatePixelsCoordinates(i, y, px, py); |
207 calculatePixelsCoordinates(i, y, px, py); |
918 end; |
918 end; |
919 end; |
919 end; |
920 Despeckle:= false |
920 Despeckle:= false |
921 end; |
921 end; |
922 |
922 |
|
923 // a bit of AA for explosions |
923 procedure Smooth(X, Y: LongInt); |
924 procedure Smooth(X, Y: LongInt); |
|
925 var c, r, g, b, a, i: integer; |
|
926 nx, ny: LongInt; |
|
927 pixel: LongWord; |
|
928 begin |
|
929 |
|
930 // only AA inwards |
|
931 if (Land[Y, X] and lfDamaged) = 0 then |
|
932 exit; |
|
933 |
|
934 // check location |
|
935 if (Y <= LongInt(topY) + 1) or (Y >= LAND_HEIGHT-2) |
|
936 or (X <= LongInt(leftX) + 1) or (X >= LongInt(rightX) - 1) then |
|
937 exit; |
|
938 |
|
939 // counter for neighbor pixels that are not known to be undamaged |
|
940 c:= 8; |
|
941 |
|
942 // accumalating rgba value of relevant pixels here |
|
943 r:= 0; |
|
944 g:= 0; |
|
945 b:= 0; |
|
946 a:= 0; |
|
947 |
|
948 // iterate over all neighbor pixels (also itself, will be skipped anyway) |
|
949 for nx:= X-1 to X+1 do |
|
950 for ny:= Y-1 to Y+1 do |
|
951 // only consider undamaged neighbors (also leads to skipping itself) |
|
952 if (Land[ny, nx] and lfDamaged) = 0 then |
|
953 begin |
|
954 pixel:= LandPixels[ny, nx]; |
|
955 inc(r, (pixel and RMask) shr RShift); |
|
956 inc(g, (pixel and GMask) shr GShift); |
|
957 inc(b, (pixel and BMask) shr BShift); |
|
958 inc(a, (pixel and AMask) shr AShift); |
|
959 dec(c); |
|
960 end; |
|
961 |
|
962 // nothing do to if all neighbors damaged |
|
963 if c < 1 then |
|
964 exit; |
|
965 |
|
966 // use explosion color for damaged pixels |
|
967 for i:= 1 to c do |
|
968 begin |
|
969 inc(r, ExplosionBorderColorR); |
|
970 inc(g, ExplosionBorderColorG); |
|
971 inc(b, ExplosionBorderColorB); |
|
972 inc(a, 255); |
|
973 end; |
|
974 |
|
975 // set resulting color value based on average of all neighbors |
|
976 r:= r div 8; |
|
977 g:= g div 8; |
|
978 b:= b div 8; |
|
979 a:= a div 8; |
|
980 LandPixels[y,x]:= (r shl RShift) or (g shl GShift) or (b shl BShift) or (a shl AShift); |
|
981 |
|
982 end; |
|
983 |
|
984 procedure Smooth_oldImpl(X, Y: LongInt); |
924 begin |
985 begin |
925 // a bit of AA for explosions |
986 // a bit of AA for explosions |
926 if (Land[Y, X] = 0) and (Y > LongInt(topY) + 1) and |
987 if (Land[Y, X] = 0) and (Y > LongInt(topY) + 1) and |
927 (Y < LAND_HEIGHT-2) and (X > LongInt(leftX) + 1) and (X < LongInt(rightX) - 1) then |
988 (Y < LAND_HEIGHT-2) and (X > LongInt(leftX) + 1) and (X < LongInt(rightX) - 1) then |
928 begin |
989 begin |
937 LandPixels[y,x]:= |
998 LandPixels[y,x]:= |
938 (((((LandPixels[y,x] and RMask shr RShift) div 2)+((ExplosionBorderColor and RMask) shr RShift) div 2) and $FF) shl RShift) or |
999 (((((LandPixels[y,x] and RMask shr RShift) div 2)+((ExplosionBorderColor and RMask) shr RShift) div 2) and $FF) shl RShift) or |
939 (((((LandPixels[y,x] and GMask shr GShift) div 2)+((ExplosionBorderColor and GMask) shr GShift) div 2) and $FF) shl GShift) or |
1000 (((((LandPixels[y,x] and GMask shr GShift) div 2)+((ExplosionBorderColor and GMask) shr GShift) div 2) and $FF) shl GShift) or |
940 (((((LandPixels[y,x] and BMask shr BShift) div 2)+((ExplosionBorderColor and BMask) shr BShift) div 2) and $FF) shl BShift) or ($FF shl AShift) |
1001 (((((LandPixels[y,x] and BMask shr BShift) div 2)+((ExplosionBorderColor and BMask) shr BShift) div 2) and $FF) shl BShift) or ($FF shl AShift) |
941 end; |
1002 end; |
|
1003 { |
942 if (Land[y, x-1] = lfObject) then |
1004 if (Land[y, x-1] = lfObject) then |
943 Land[y,x]:= lfObject |
1005 Land[y,x]:= lfObject |
944 else if (Land[y, x+1] = lfObject) then |
1006 else if (Land[y, x+1] = lfObject) then |
945 Land[y,x]:= lfObject |
1007 Land[y,x]:= lfObject |
946 else |
1008 else |
947 Land[y,x]:= lfBasic; |
1009 Land[y,x]:= lfBasic; |
|
1010 } |
948 end |
1011 end |
949 else if ((((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0)) |
1012 else if ((((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0)) |
950 or (((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0)) |
1013 or (((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0)) |
951 or (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0)) |
1014 or (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0)) |
952 or (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0)) |
1015 or (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0)) |
963 LandPixels[y,x]:= |
1026 LandPixels[y,x]:= |
964 (((((LandPixels[y,x] and RMask shr RShift) * 3 div 4)+((ExplosionBorderColor and RMask) shr RShift) div 4) and $FF) shl RShift) or |
1027 (((((LandPixels[y,x] and RMask shr RShift) * 3 div 4)+((ExplosionBorderColor and RMask) shr RShift) div 4) and $FF) shl RShift) or |
965 (((((LandPixels[y,x] and GMask shr GShift) * 3 div 4)+((ExplosionBorderColor and GMask) shr GShift) div 4) and $FF) shl GShift) or |
1028 (((((LandPixels[y,x] and GMask shr GShift) * 3 div 4)+((ExplosionBorderColor and GMask) shr GShift) div 4) and $FF) shl GShift) or |
966 (((((LandPixels[y,x] and BMask shr BShift) * 3 div 4)+((ExplosionBorderColor and BMask) shr BShift) div 4) and $FF) shl BShift) or ($FF shl AShift) |
1029 (((((LandPixels[y,x] and BMask shr BShift) * 3 div 4)+((ExplosionBorderColor and BMask) shr BShift) div 4) and $FF) shl BShift) or ($FF shl AShift) |
967 end; |
1030 end; |
|
1031 { |
968 if (Land[y, x-1] = lfObject) then |
1032 if (Land[y, x-1] = lfObject) then |
969 Land[y, x]:= lfObject |
1033 Land[y, x]:= lfObject |
970 else if (Land[y, x+1] = lfObject) then |
1034 else if (Land[y, x+1] = lfObject) then |
971 Land[y, x]:= lfObject |
1035 Land[y, x]:= lfObject |
972 else if (Land[y+1, x] = lfObject) then |
1036 else if (Land[y+1, x] = lfObject) then |
973 Land[y, x]:= lfObject |
1037 Land[y, x]:= lfObject |
974 else if (Land[y-1, x] = lfObject) then |
1038 else if (Land[y-1, x] = lfObject) then |
975 Land[y, x]:= lfObject |
1039 Land[y, x]:= lfObject |
976 else Land[y,x]:= lfBasic |
1040 else Land[y,x]:= lfBasic |
|
1041 } |
977 end |
1042 end |
978 end |
1043 end |
979 else if ((cReducedQuality and rqBlurryLand) = 0) and ((LandPixels[Y, X] and AMask) = AMask) |
1044 else if ((cReducedQuality and rqBlurryLand) = 0) and ((LandPixels[Y, X] and AMask) = AMask) |
980 and (Land[Y, X] and (lfDamaged or lfBasic) = lfBasic) |
1045 and (Land[Y, X] and (lfDamaged or lfBasic) = lfBasic) |
981 and (Y > LongInt(topY) + 1) and (Y < LAND_HEIGHT-2) and (X > LongInt(leftX) + 1) and (X < LongInt(rightX) - 1) then |
1046 and (Y > LongInt(topY) + 1) and (Y < LAND_HEIGHT-2) and (X > LongInt(leftX) + 1) and (X < LongInt(rightX) - 1) then |
1058 end; |
1123 end; |
1059 end; |
1124 end; |
1060 end; |
1125 end; |
1061 end; |
1126 end; |
1062 |
1127 |
1063 for y:= 0 to LAND_HEIGHT div 32 - 1 do |
1128 // smooth explosion borders (except if land is blurry) |
1064 for x:= 0 to LAND_WIDTH div 32 - 1 do |
1129 if (cReducedQuality and rqBlurryLand) = 0 then |
1065 if LandDirty[y, x] <> 0 then |
1130 for y:= 0 to LAND_HEIGHT div 32 - 1 do |
1066 begin |
1131 for x:= 0 to LAND_WIDTH div 32 - 1 do |
1067 ty:= y * 32; |
1132 if LandDirty[y, x] <> 0 then |
1068 tx:= x * 32; |
1133 begin |
1069 for yy:= ty to ty + 31 do |
1134 ty:= y * 32; |
1070 for xx:= tx to tx + 31 do |
1135 tx:= x * 32; |
1071 Smooth(xx,yy) |
1136 for yy:= ty to ty + 31 do |
1072 end; |
1137 for xx:= tx to tx + 31 do |
|
1138 Smooth(xx,yy) |
|
1139 end; |
1073 |
1140 |
1074 for y:= 0 to LAND_HEIGHT div 32 - 1 do |
1141 for y:= 0 to LAND_HEIGHT div 32 - 1 do |
1075 for x:= 0 to LAND_WIDTH div 32 - 1 do |
1142 for x:= 0 to LAND_WIDTH div 32 - 1 do |
1076 if LandDirty[y, x] <> 0 then |
1143 if LandDirty[y, x] <> 0 then |
1077 begin |
1144 begin |