1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 Dan Everton
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
25 void sdl_update_rect(SDL_Surface
*surface
, int x_start
, int y_start
, int width
,
26 int height
, int max_x
, int max_y
,
27 unsigned long (*getpixel
)(int, int))
33 ymax
= y_start
+ height
;
34 xmax
= x_start
+ width
;
41 SDL_LockSurface(surface
);
43 dest
.w
= display_zoom
;
44 dest
.h
= display_zoom
;
46 for (x
= x_start
; x
< xmax
; x
++) {
47 dest
.x
= x
* display_zoom
;
49 for (y
= y_start
; y
< ymax
; y
++) {
50 dest
.y
= y
* display_zoom
;
52 SDL_FillRect(surface
, &dest
, (Uint32
)getpixel(x
, y
));
56 SDL_UnlockSurface(surface
);
59 void sdl_gui_update(SDL_Surface
*surface
, int x_start
, int y_start
, int width
,
60 int height
, int max_x
, int max_y
, int ui_x
, int ui_y
)
64 ymax
= y_start
+ height
;
65 xmax
= x_start
+ width
;
72 SDL_Rect src
= {x_start
* display_zoom
, y_start
* display_zoom
,
73 xmax
* display_zoom
, ymax
* display_zoom
};
74 SDL_Rect dest
= {(ui_x
+ x_start
) * display_zoom
, (ui_y
+ y_start
) * display_zoom
,
75 xmax
* display_zoom
, ymax
* display_zoom
};
77 SDL_BlitSurface(surface
, &src
, gui_surface
, &dest
);
78 SDL_Flip(gui_surface
);
81 /* set a range of bitmap indices to a gradient from startcolour to endcolour */
82 void sdl_set_gradient(SDL_Surface
*surface
, SDL_Color
*start
, SDL_Color
*end
,
86 SDL_Color palette
[steps
];
88 for (i
= 0; i
< steps
; i
++) {
89 palette
[i
].r
= start
->r
+ (end
->r
- start
->r
) * i
/ (steps
- 1);
90 palette
[i
].g
= start
->g
+ (end
->g
- start
->g
) * i
/ (steps
- 1);
91 palette
[i
].b
= start
->b
+ (end
->b
- start
->b
) * i
/ (steps
- 1);
94 SDL_SetPalette(surface
, SDL_LOGPAL
|SDL_PHYSPAL
, palette
, first
, steps
);