58 if (width div 4096 >= 2) or (height div 2048 >= 2) then cMaxZoomLevel:= 0.5; |
58 if (width div 4096 >= 2) or (height div 2048 >= 2) then cMaxZoomLevel:= 0.5; |
59 cMinMaxZoomLevelDelta:= cMaxZoomLevel - cMinZoomLevel |
59 cMinMaxZoomLevelDelta:= cMaxZoomLevel - cMinZoomLevel |
60 end; |
60 end; |
61 end; |
61 end; |
62 |
62 |
63 procedure ColorizeLand(Surface: PSDL_Surface); |
63 |
|
64 procedure DrawBorderFromImage(Surface: PSDL_Surface); |
64 var tmpsurf: PSDL_Surface; |
65 var tmpsurf: PSDL_Surface; |
65 r, rr: TSDL_Rect; |
66 r, rr: TSDL_Rect; |
66 x, yd, yu: LongInt; |
67 x, yd, yu: LongInt; |
67 begin |
68 begin |
68 tmpsurf:= LoadDataImage(ptCurrTheme, 'LandTex', ifCritical or ifIgnoreCaps); |
|
69 r.y:= 0; |
|
70 while r.y < LAND_HEIGHT do |
|
71 begin |
|
72 r.x:= 0; |
|
73 while r.x < LAND_WIDTH do |
|
74 begin |
|
75 SDL_UpperBlit(tmpsurf, nil, Surface, @r); |
|
76 inc(r.x, tmpsurf^.w) |
|
77 end; |
|
78 inc(r.y, tmpsurf^.h) |
|
79 end; |
|
80 SDL_FreeSurface(tmpsurf); |
|
81 |
|
82 // freed in freeModule() below |
|
83 LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifTransparent); |
|
84 if (LandBackSurface <> nil) and GrayScale then Surface2GrayScale(LandBackSurface); |
|
85 |
|
86 tmpsurf:= LoadDataImage(ptCurrTheme, 'Border', ifCritical or ifIgnoreCaps or ifTransparent); |
69 tmpsurf:= LoadDataImage(ptCurrTheme, 'Border', ifCritical or ifIgnoreCaps or ifTransparent); |
87 for x:= 0 to LAND_WIDTH - 1 do |
70 for x:= 0 to LAND_WIDTH - 1 do |
88 begin |
71 begin |
89 yd:= LAND_HEIGHT - 1; |
72 yd:= LAND_HEIGHT - 1; |
90 repeat |
73 repeat |
125 until yd < 0; |
108 until yd < 0; |
126 end; |
109 end; |
127 SDL_FreeSurface(tmpsurf); |
110 SDL_FreeSurface(tmpsurf); |
128 end; |
111 end; |
129 |
112 |
|
113 |
|
114 procedure DrawShoppaBorder; |
|
115 var x, y, s, i: Longword; |
|
116 c1, c2, c: Longword; |
|
117 begin |
|
118 c1:= AMask; |
|
119 c2:= AMask or RMask or GMask; |
|
120 |
|
121 // vertical |
|
122 s:= LAND_HEIGHT; |
|
123 |
|
124 for x:= 0 to LAND_WIDTH - 1 do |
|
125 for y:= 0 to LAND_HEIGHT - 1 do |
|
126 if LandPixels[y, x] = 0 then |
|
127 if s < y then |
|
128 begin |
|
129 for i:= max(s, y - 8) to y - 1 do |
|
130 begin |
|
131 if ((x + i) and 16) = 0 then c:= c1 else c:= c2; |
|
132 |
|
133 if (cReducedQuality and rqBlurryLand) = 0 then |
|
134 LandPixels[i, x]:= c |
|
135 else |
|
136 LandPixels[i div 2, x div 2]:= c |
|
137 end; |
|
138 s:= LAND_HEIGHT |
|
139 end |
|
140 else |
|
141 else |
|
142 begin |
|
143 if s > y then s:= y; |
|
144 if s + 8 > y then |
|
145 begin |
|
146 if ((x + y) and 16) = 0 then c:= c1 else c:= c2; |
|
147 |
|
148 if (cReducedQuality and rqBlurryLand) = 0 then |
|
149 LandPixels[y, x]:= c |
|
150 else |
|
151 LandPixels[y div 2, x div 2]:= c |
|
152 end; |
|
153 end; |
|
154 |
|
155 // horizontal |
|
156 s:= LAND_WIDTH; |
|
157 |
|
158 for y:= 0 to LAND_HEIGHT - 1 do |
|
159 for x:= 0 to LAND_WIDTH - 1 do |
|
160 if LandPixels[y, x] = 0 then |
|
161 if s < x then |
|
162 begin |
|
163 for i:= max(s, x - 8) to x - 1 do |
|
164 begin |
|
165 if ((y + i) and 16) = 0 then c:= c1 else c:= c2; |
|
166 |
|
167 if (cReducedQuality and rqBlurryLand) = 0 then |
|
168 LandPixels[y, i]:= c |
|
169 else |
|
170 LandPixels[y div 2, i div 2]:= c |
|
171 end; |
|
172 s:= LAND_WIDTH |
|
173 end |
|
174 else |
|
175 else |
|
176 begin |
|
177 if s > x then s:= x; |
|
178 if s + 8 > x then |
|
179 begin |
|
180 if ((x + y) and 16) = 0 then c:= c1 else c:= c2; |
|
181 |
|
182 if (cReducedQuality and rqBlurryLand) = 0 then |
|
183 LandPixels[y, x]:= c |
|
184 else |
|
185 LandPixels[y div 2, x div 2]:= c |
|
186 end; |
|
187 end |
|
188 end; |
|
189 |
|
190 procedure ColorizeLand(Surface: PSDL_Surface); |
|
191 var tmpsurf: PSDL_Surface; |
|
192 r: TSDL_Rect; |
|
193 begin |
|
194 tmpsurf:= LoadDataImage(ptCurrTheme, 'LandTex', ifCritical or ifIgnoreCaps); |
|
195 r.y:= 0; |
|
196 while r.y < LAND_HEIGHT do |
|
197 begin |
|
198 r.x:= 0; |
|
199 while r.x < LAND_WIDTH do |
|
200 begin |
|
201 SDL_UpperBlit(tmpsurf, nil, Surface, @r); |
|
202 inc(r.x, tmpsurf^.w) |
|
203 end; |
|
204 inc(r.y, tmpsurf^.h) |
|
205 end; |
|
206 SDL_FreeSurface(tmpsurf); |
|
207 |
|
208 // freed in freeModule() below |
|
209 LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifTransparent); |
|
210 if (LandBackSurface <> nil) and GrayScale then Surface2GrayScale(LandBackSurface); |
|
211 end; |
|
212 |
130 procedure SetPoints(var Template: TEdgeTemplate; var pa: TPixAr; fps: PPointArray); |
213 procedure SetPoints(var Template: TEdgeTemplate; var pa: TPixAr; fps: PPointArray); |
131 var i: LongInt; |
214 var i: LongInt; |
132 begin |
215 begin |
133 with Template do |
216 with Template do |
134 begin |
217 begin |
343 |
426 |
344 tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, LAND_WIDTH, LAND_HEIGHT, 32, RMask, GMask, BMask, 0); |
427 tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, LAND_WIDTH, LAND_HEIGHT, 32, RMask, GMask, BMask, 0); |
345 |
428 |
346 TryDo(tmpsurf <> nil, 'Error creating pre-land surface', true); |
429 TryDo(tmpsurf <> nil, 'Error creating pre-land surface', true); |
347 ColorizeLand(tmpsurf); |
430 ColorizeLand(tmpsurf); |
|
431 if gameFlags and gfShoppaBorder = 0 then DrawBorderFromImage(tmpsurf); |
348 AddOnLandObjects(tmpsurf); |
432 AddOnLandObjects(tmpsurf); |
349 |
433 |
350 LandSurface2LandPixels(tmpsurf); |
434 LandSurface2LandPixels(tmpsurf); |
351 SDL_FreeSurface(tmpsurf); |
435 SDL_FreeSurface(tmpsurf); |
|
436 |
|
437 if gameFlags and gfShoppaBorder <> 0 then DrawShoppaBorder; |
|
438 |
352 for x:= leftX+2 to rightX-2 do |
439 for x:= leftX+2 to rightX-2 do |
353 for y:= topY+2 to LAND_HEIGHT-3 do |
440 for y:= topY+2 to LAND_HEIGHT-3 do |
354 if (Land[y, x] = 0) and |
441 if (Land[y, x] = 0) and |
355 (((Land[y, x-1] = lfBasic) and ((Land[y+1,x] = lfBasic)) or (Land[y-1,x] = lfBasic)) or |
442 (((Land[y, x-1] = lfBasic) and ((Land[y+1,x] = lfBasic)) or (Land[y-1,x] = lfBasic)) or |
356 ((Land[y, x+1] = lfBasic) and ((Land[y-1,x] = lfBasic) or (Land[y+1,x] = lfBasic)))) then |
443 ((Land[y, x+1] = lfBasic) and ((Land[y-1,x] = lfBasic) or (Land[y+1,x] = lfBasic)))) then |