Mercurial > hg > dmlib
comparison tools/ppl.c @ 1323:2260ed90ab6b
Remove dmgfx and move the functions used to PPL and Auval.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 22 Aug 2017 00:51:45 +0300 |
parents | 13c274d22a29 |
children | 59e9ad13b50e |
comparison
equal
deleted
inserted
replaced
1322:c2000337ac3f | 1323:2260ed90ab6b |
---|---|
173 | 173 |
174 return TRUE; | 174 return TRUE; |
175 } | 175 } |
176 | 176 |
177 | 177 |
178 void dmFillRect(SDL_Surface *screen, int x0, int y0, int x1, int y1, Uint32 col) | |
179 { | |
180 SDL_Rect rc; | |
181 rc.x = x0; | |
182 rc.y = y0; | |
183 rc.w = x1 - x0 + 1; | |
184 rc.h = y1 - y0 + 1; | |
185 SDL_FillRect(screen, &rc, col); | |
186 } | |
187 | |
188 | |
189 void dmDrawHLine(SDL_Surface *screen, int x0, int x1, int yc, const Uint32 col) | |
190 { | |
191 const int bpp = screen->format->BytesPerPixel, | |
192 cx0 = screen->clip_rect.x, cy0 = screen->clip_rect.y, | |
193 cx1 = screen->clip_rect.x + screen->clip_rect.w - 1, | |
194 cy1 = screen->clip_rect.y + screen->clip_rect.h - 1; | |
195 | |
196 DM_SWAP(int, x0, x1); | |
197 if (yc < cy0|| yc > cy1 || x1 < cx0 || x0 > cx1) return; | |
198 if (x0 < cx0) x0 = cx0; | |
199 if (x1 > cx1) x1 = cx1; | |
200 | |
201 int x = x1 - x0 + 1; | |
202 Uint8 *pix = ((Uint8 *) screen->pixels) + yc * screen->pitch + (x0 * bpp); | |
203 switch (screen->format->BitsPerPixel) | |
204 { | |
205 case 8: | |
206 while (x--) | |
207 *pix++ = col; | |
208 break; | |
209 | |
210 case 32: | |
211 { | |
212 Uint32 *p = (Uint32 *) pix; | |
213 while (x--) | |
214 *p++ = col; | |
215 } | |
216 break; | |
217 } | |
218 } | |
219 | |
220 | |
221 void dmDrawVLine(SDL_Surface *screen, int y0, int y1, int xc, const Uint32 col) | |
222 { | |
223 const int bpp = screen->format->BytesPerPixel, | |
224 pitch = screen->pitch / bpp, | |
225 cx0 = screen->clip_rect.x, cy0 = screen->clip_rect.y, | |
226 cx1 = screen->clip_rect.x + screen->clip_rect.w - 1, | |
227 cy1 = screen->clip_rect.y + screen->clip_rect.h - 1; | |
228 | |
229 DM_SWAP(int, y0, y1); | |
230 if (xc < cx0 || xc > cx1 || y1 < cy0 || y0 > cy1) return; | |
231 if (y0 < cy0) y0 = cy0; | |
232 if (y1 > cy1) y1 = cy1; | |
233 | |
234 int y = y1 - y0 + 1; | |
235 Uint8 *pix = ((Uint8 *) screen->pixels) + y0 * screen->pitch + (xc * bpp); | |
236 switch (screen->format->BitsPerPixel) | |
237 { | |
238 case 8: | |
239 while (y--) | |
240 { | |
241 *pix = col; | |
242 pix += pitch; | |
243 } | |
244 break; | |
245 | |
246 case 32: | |
247 { | |
248 Uint32 *p = (Uint32 *) pix; | |
249 while (y--) | |
250 { | |
251 *p = col; | |
252 p += pitch; | |
253 } | |
254 } | |
255 break; | |
256 } | |
257 } | |
258 | |
259 | |
260 void dmDrawBox3D(SDL_Surface *screen, int x0, int y0, int x1, int y1, Uint32 ucol, Uint32 dcol) | |
261 { | |
262 dmDrawHLine(screen, x0 , x1 - 1, y0, ucol); | |
263 dmDrawHLine(screen, x0 + 1, x1 , y1, dcol); | |
264 | |
265 dmDrawVLine(screen, y0 , y1 - 1, x0, ucol); | |
266 dmDrawVLine(screen, y0 + 1, y1 , x1, dcol); | |
267 } | |
268 | |
269 | |
270 void dmFillBox3D(SDL_Surface *screen, int x0, int y0, int x1, int y1, Uint32 bgcol, Uint32 ucol, Uint32 dcol) | |
271 { | |
272 SDL_Rect rc; | |
273 | |
274 rc.x = x0 + 1; | |
275 rc.y = y0 + 1; | |
276 rc.w = x1 - x0 - 1; | |
277 rc.h = y1 - y0 - 1; | |
278 SDL_FillRect(screen, &rc, bgcol); | |
279 | |
280 dmDrawBox3D(screen, x0, y0, x1, y1, ucol, dcol); | |
281 } | |
282 | |
283 | |
178 void dmDrawBMTextConstQ(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt) | 284 void dmDrawBMTextConstQ(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt) |
179 { | 285 { |
180 const char *ptr = fmt; | 286 const char *ptr = fmt; |
181 DMUnscaledBlitFunc blit = NULL; | 287 DMUnscaledBlitFunc blit = NULL; |
182 | 288 |