Update Beast installation instructions to use beastpatcher and remove instructions...
[kugel-rb.git] / apps / gui / backdrop.c
blobc95fda9022fb883d27ccd9049334c617b6cfe7e9
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2006 Dave Chapman
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include <stdio.h>
23 #include "config.h"
24 #include "lcd.h"
25 #ifdef HAVE_REMOTE_LCD
26 #include "lcd-remote.h"
27 #endif
28 #include "backdrop.h"
30 #if LCD_DEPTH >= 8
31 static fb_data main_backdrop[LCD_HEIGHT][LCD_WIDTH] __attribute__ ((aligned (16)));
32 static fb_data wps_backdrop[LCD_HEIGHT][LCD_WIDTH] __attribute__ ((aligned (16)));
33 #elif LCD_DEPTH == 2
34 static fb_data main_backdrop[LCD_FBHEIGHT][LCD_FBWIDTH];
35 static fb_data wps_backdrop[LCD_FBHEIGHT][LCD_FBWIDTH];
36 #endif
38 #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
39 static fb_remote_data remote_wps_backdrop[LCD_REMOTE_FBHEIGHT][LCD_REMOTE_FBWIDTH];
40 static bool remote_wps_backdrop_valid = false;
41 #endif
43 static bool main_backdrop_valid = false;
44 static bool wps_backdrop_valid = false;
46 /* load a backdrop into a buffer */
47 static bool load_backdrop(const char* filename, fb_data* backdrop_buffer)
49 struct bitmap bm;
50 int ret;
52 /* load the image */
53 bm.data=(char*)backdrop_buffer;
54 ret = read_bmp_file(filename, &bm, sizeof(main_backdrop),
55 FORMAT_NATIVE | FORMAT_DITHER, NULL);
57 if ((ret > 0) && (bm.width == LCD_WIDTH) && (bm.height == LCD_HEIGHT))
59 return true;
61 else
63 return false;
67 bool load_main_backdrop(const char* filename)
69 main_backdrop_valid = load_backdrop(filename, &main_backdrop[0][0]);
70 return main_backdrop_valid;
73 bool load_wps_backdrop(const char* filename)
75 wps_backdrop_valid = load_backdrop(filename, &wps_backdrop[0][0]);
76 return wps_backdrop_valid;
79 void unload_main_backdrop(void)
81 main_backdrop_valid = false;
84 void unload_wps_backdrop(void)
86 wps_backdrop_valid = false;
89 void show_main_backdrop(void)
91 lcd_set_backdrop(main_backdrop_valid ? &main_backdrop[0][0] : NULL);
94 void show_wps_backdrop(void)
96 /* if no wps backdrop, fall back to main backdrop */
97 if(wps_backdrop_valid)
99 lcd_set_backdrop(&wps_backdrop[0][0]);
101 else
103 show_main_backdrop();
107 #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
109 static bool load_remote_backdrop(const char* filename, fb_remote_data* backdrop_buffer)
111 struct bitmap bm;
112 int ret;
114 /* load the image */
115 bm.data=(char*)backdrop_buffer;
116 ret = read_bmp_file(filename, &bm, sizeof(main_backdrop),
117 FORMAT_NATIVE | FORMAT_DITHER | FORMAT_REMOTE, NULL);
119 if ((ret > 0) && (bm.width == LCD_REMOTE_WIDTH) && (bm.height == LCD_REMOTE_HEIGHT))
121 return true;
123 else
125 return false;
129 bool load_remote_wps_backdrop(const char* filename)
131 remote_wps_backdrop_valid = load_remote_backdrop(filename, &remote_wps_backdrop[0][0]);
132 return remote_wps_backdrop_valid;
135 void unload_remote_wps_backdrop(void)
137 remote_wps_backdrop_valid = false;
140 void show_remote_wps_backdrop(void)
142 /* if no wps backdrop, fall back to main backdrop */
143 if(remote_wps_backdrop_valid)
145 lcd_remote_set_backdrop(&remote_wps_backdrop[0][0]);
147 else
149 show_remote_main_backdrop();
153 void show_remote_main_backdrop(void)
155 lcd_remote_set_backdrop(NULL);
157 #endif