X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fsdl.c;fp=src%2Fsdl.c;h=3f1930136e0e4c8033766490842bb973cb45f9cf;hb=36357e8399d0a42ac45a1cd096aee24a9008b5f5;hp=d8100125d9f0e5ad92e85d773f936d9bfa8ec24a;hpb=8d46c5298f0fcce7bdb52f3835b2fbbdc403dfe0;p=rocksndiamonds.git diff --git a/src/sdl.c b/src/sdl.c index d8100125..3f193013 100644 --- a/src/sdl.c +++ b/src/sdl.c @@ -15,6 +15,7 @@ #ifdef USE_SDL_LIBRARY #include "main.h" +#include "misc.h" inline void SDLCopyArea(SDL_Surface *src_surface, SDL_Surface *dst_surface, int src_x, int src_y, @@ -54,4 +55,27 @@ inline void SDLFillRectangle(SDL_Surface *surface, int x, int y, SDL_MapRGB(surface->format, color_r, color_g, color_b)); } +inline void SDLDrawSimpleLine(SDL_Surface *surface, int from_x, int from_y, + int to_x, int to_y, unsigned int color) +{ + SDL_Rect rect; + unsigned int color_r = (color >> 2) && 0xff; + unsigned int color_g = (color >> 1) && 0xff; + unsigned int color_b = (color >> 0) && 0xff; + + if (from_x > to_x) + swap_numbers(&from_x, &to_x); + + if (from_y > to_y) + swap_numbers(&from_y, &to_y); + + rect.x = from_x; + rect.y = from_y; + rect.w = (to_x - from_x + 1); + rect.h = (to_y - from_y + 1); + + SDL_FillRect(surface, &rect, + SDL_MapRGB(surface->format, color_r, color_g, color_b)); +} + #endif /* USE_SDL_LIBRARY */