2006-02-03 15:19:58 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Dan Everton
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2006-02-09 21:49:28 +00:00
|
|
|
#include "lcd-sdl.h"
|
2006-02-03 15:19:58 +00:00
|
|
|
#include "uisdl.h"
|
|
|
|
|
2006-02-09 21:49:28 +00:00
|
|
|
int display_zoom = 1;
|
2006-02-03 15:19:58 +00:00
|
|
|
|
2006-02-09 21:49:28 +00:00
|
|
|
void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width,
|
|
|
|
int height, int max_x, int max_y, int ui_x, int ui_y,
|
|
|
|
Uint32 (*getpixel)(int, int))
|
2006-02-03 15:19:58 +00:00
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
int xmax, ymax;
|
2006-02-09 21:49:28 +00:00
|
|
|
SDL_Rect dest;
|
2006-02-03 15:19:58 +00:00
|
|
|
|
|
|
|
ymax = y_start + height;
|
|
|
|
xmax = x_start + width;
|
|
|
|
|
2006-02-09 21:49:28 +00:00
|
|
|
if(xmax > max_x)
|
|
|
|
xmax = max_x;
|
|
|
|
if(ymax >= max_y)
|
|
|
|
ymax = max_y;
|
2006-02-03 15:19:58 +00:00
|
|
|
|
2006-02-09 21:49:28 +00:00
|
|
|
SDL_LockSurface(surface);
|
2006-02-03 15:19:58 +00:00
|
|
|
|
2006-02-09 21:49:28 +00:00
|
|
|
dest.w = display_zoom;
|
|
|
|
dest.h = display_zoom;
|
|
|
|
|
|
|
|
for (x = x_start; x < xmax; x++) {
|
|
|
|
dest.x = x * display_zoom;
|
2006-02-03 15:19:58 +00:00
|
|
|
|
2006-02-09 21:49:28 +00:00
|
|
|
for (y = y_start; y < ymax; y++) {
|
|
|
|
dest.y = y * display_zoom;
|
|
|
|
|
|
|
|
SDL_FillRect(surface, &dest, getpixel(x, y));
|
2006-02-03 15:19:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-09 21:49:28 +00:00
|
|
|
SDL_UnlockSurface(surface);
|
2006-02-03 15:19:58 +00:00
|
|
|
|
2006-02-09 21:49:28 +00:00
|
|
|
SDL_Rect src = {x_start * display_zoom, y_start * display_zoom, xmax * display_zoom, ymax * display_zoom};
|
|
|
|
dest.x = (ui_x + x_start) * display_zoom;
|
|
|
|
dest.y = (ui_y + y_start) * display_zoom;;
|
|
|
|
dest.w = xmax * display_zoom;
|
|
|
|
dest.h = ymax * display_zoom;
|
2006-02-09 11:17:52 +00:00
|
|
|
|
2006-02-09 21:49:28 +00:00
|
|
|
SDL_BlitSurface(surface, &src, gui_surface, &dest);
|
2006-02-03 15:19:58 +00:00
|
|
|
SDL_UpdateRect(gui_surface, dest.x, dest.y, dest.w, dest.h);
|
|
|
|
SDL_Flip(gui_surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set a range of bitmap indices to a gradient from startcolour to endcolour */
|
2006-02-09 21:49:28 +00:00
|
|
|
void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, int steps)
|
2006-02-03 15:19:58 +00:00
|
|
|
{
|
|
|
|
int i;
|
2006-02-09 21:49:28 +00:00
|
|
|
SDL_Color palette[steps];
|
2006-02-03 15:19:58 +00:00
|
|
|
|
2006-02-09 21:49:28 +00:00
|
|
|
for (i = 0; i < steps; i++) {
|
2006-02-16 18:55:36 +00:00
|
|
|
palette[i].r = start->r + (end->r - start->r) * i / (steps - 1);
|
|
|
|
palette[i].g = start->g + (end->g - start->g) * i / (steps - 1);
|
|
|
|
palette[i].b = start->b + (end->b - start->b) * i / (steps - 1);
|
2006-02-03 15:19:58 +00:00
|
|
|
}
|
|
|
|
|
2006-02-09 21:49:28 +00:00
|
|
|
SDL_SetPalette(surface, SDL_LOGPAL|SDL_PHYSPAL, palette, 0, steps);
|
2006-02-03 15:19:58 +00:00
|
|
|
}
|
|
|
|
|