rnd-20000718-1-src
[rocksndiamonds.git] / src / sdl.c
1 /***********************************************************
2 *  Rocks'n'Diamonds -- McDuffin Strikes Back!              *
3 *----------------------------------------------------------*
4 *  ©1995 Artsoft Development                               *
5 *        Holger Schemel                                    *
6 *        33659 Bielefeld-Senne                             *
7 *        Telefon: (0521) 493245                            *
8 *        eMail: aeglos@valinor.owl.de                      *
9 *               aeglos@uni-paderborn.de                    *
10 *               q99492@pbhrzx.uni-paderborn.de             *
11 *----------------------------------------------------------*
12 *  sdl.c                                                   *
13 ***********************************************************/
14
15 #ifdef USE_SDL_LIBRARY
16
17 #include "main.h"
18
19 inline void SDLCopyArea(SDL_Surface *src_surface, SDL_Surface *dst_surface,
20                         int src_x, int src_y,
21                         int width, int height,
22                         int dst_x, int dst_y)
23 {
24   SDL_Rect src_rect, dst_rect;
25
26   src_rect.x = src_x;
27   src_rect.y = src_y;
28   src_rect.w = width;
29   src_rect.h = height;
30
31   dst_rect.x = dst_x;
32   dst_rect.y = dst_y;
33   dst_rect.w = width;
34   dst_rect.h = height;
35
36   SDL_BlitSurface(src_surface, &src_rect, dst_surface, &dst_rect);
37   SDL_UpdateRect(dst_surface, dst_x, dst_y, width, height);
38 }
39
40 inline void SDLFillRectangle(SDL_Surface *surface, int x, int y,
41                              int width, int height, unsigned int color)
42 {
43   SDL_Rect rect;
44   unsigned int color_r = (color >> 2) && 0xff;
45   unsigned int color_g = (color >> 1) && 0xff;
46   unsigned int color_b = (color >> 0) && 0xff;
47
48   rect.x = x;
49   rect.y = y;
50   rect.w = width;
51   rect.h = height;
52
53   SDL_FillRect(surface, &rect,
54                SDL_MapRGB(surface->format, color_r, color_g, color_b));
55 }
56
57 #endif /* USE_SDL_LIBRARY */