1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2008 by 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 ****************************************************************************/
29 #include "skin_buffer.h"
30 #include "skin_debug.h"
31 #include "skin_engine.h"
32 #include "wps_internals.h"
38 bool debug_wps
= true;
39 int wps_verbose_level
= 0;
44 const struct settings_list
*settings
;
45 const int nb_settings
= 0;
47 /* static endianness conversion */
48 #define SWAP_16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \
49 ((unsigned short)(x) << 8)))
51 #define SWAP_32(x) ((typeof(x))(unsigned long)( ((unsigned long)(x) >> 24) | \
52 (((unsigned long)(x) & 0xff0000ul) >> 8) | \
53 (((unsigned long)(x) & 0xff00ul) << 8) | \
54 ((unsigned long)(x) << 24)))
57 unsigned short letoh16(unsigned short x
)
59 unsigned short n
= 0x1234;
60 unsigned char* ch
= (unsigned char*)&n
;
73 unsigned short letoh32(unsigned short x
)
75 unsigned short n
= 0x1234;
76 unsigned char* ch
= (unsigned char*)&n
;
89 unsigned int htole32(unsigned int x
)
91 unsigned short n
= 0x1234;
92 unsigned char* ch
= (unsigned char*)&n
;
104 int recalc_dimension(struct dim
*dst
, struct dim
*src
)
110 int playback_claim_aa_slot(struct dim
*dim
)
115 void playback_release_aa_slot(int slot
)
121 int resize_on_load(struct bitmap
*bm
, bool dither
,
122 struct dim
*src
, struct rowset
*tmp_row
,
123 unsigned char *buf
, unsigned int len
,
124 const struct custom_format
*cformat
,
125 IF_PIX_FMT(int format_index
,)
126 struct img_part
* (*store_part
)(void *args
),
132 static char pluginbuf
[PLUGIN_BUFFER_SIZE
];
134 static unsigned dummy_func2(void)
139 void* plugin_get_buffer(size_t *buffer_size
)
141 *buffer_size
= PLUGIN_BUFFER_SIZE
;
145 struct user_settings global_settings
= {
146 .statusbar
= STATUSBAR_TOP
,
147 #ifdef HAVE_LCD_COLOR
148 .bg_color
= LCD_DEFAULT_BG
,
149 .fg_color
= LCD_DEFAULT_FG
,
153 struct system_status global_status
;
155 int getwidth(void) { return LCD_WIDTH
; }
156 int getheight(void) { return LCD_HEIGHT
; }
157 int getuifont(void) { return 0; }
158 #ifdef HAVE_REMOTE_LCD
159 int remote_getwidth(void) { return LCD_REMOTE_WIDTH
; }
160 int remote_getheight(void) { return LCD_REMOTE_HEIGHT
; }
163 static inline bool backdrop_load(const char *filename
, char* backdrop_buffer
)
165 (void)filename
; (void)backdrop_buffer
; return true;
168 struct screen screens
[NB_SCREENS
] =
171 .screen_type
=SCREEN_MAIN
,
173 .lcdheight
=LCD_HEIGHT
,
175 #ifdef HAVE_LCD_COLOR
180 .getwidth
= getwidth
,
181 .getheight
= getheight
,
182 #ifdef HAVE_LCD_BITMAP
183 .getuifont
= getuifont
,
186 .get_foreground
=dummy_func2
,
187 .get_background
=dummy_func2
,
188 .backdrop_load
=backdrop_load
,
191 #ifdef HAVE_REMOTE_LCD
193 .screen_type
=SCREEN_REMOTE
,
194 .lcdwidth
=LCD_REMOTE_WIDTH
,
195 .lcdheight
=LCD_REMOTE_HEIGHT
,
196 .depth
=LCD_REMOTE_DEPTH
,
197 .getuifont
= getuifont
,
198 .is_color
=false,/* No color remotes yet */
199 .getwidth
=remote_getwidth
,
200 .getheight
=remote_getheight
,
201 #if LCD_REMOTE_DEPTH > 1
202 .get_foreground
=dummy_func2
,
203 .get_background
=dummy_func2
,
204 .backdrop_load
=backdrop_load
,
210 #ifdef HAVE_LCD_BITMAP
211 void screen_clear_area(struct screen
* display
, int xstart
, int ystart
,
212 int width
, int height
)
214 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
215 display
->fillrect(xstart
, ystart
, width
, height
);
216 display
->set_drawmode(DRMODE_SOLID
);
221 bool radio_hardware_present(void)
227 #ifdef HAVE_LCD_BITMAP
228 static int loaded_fonts
= 0;
229 static struct font _font
;
230 int font_load(const char *path
)
232 int id
= 2 + loaded_fonts
;
237 void font_unload(int font_id
)
242 struct font
* font_get(int font
)
248 /* This is no longer defined in ROCKBOX builds so just use a huge value */
249 #define SKIN_BUFFER_SIZE (200*1024)
251 int main(int argc
, char **argv
)
256 struct wps_data wps
={0};
257 enum screen_type screen
= SCREEN_MAIN
;
258 struct screen
* wps_screen
;
260 /* No arguments -> print the help text
261 * Also print the help text upon -h or --help */
263 strcmp(argv
[1],"-h") == 0 ||
264 strcmp(argv
[1],"--help") == 0 )
266 printf("Usage: checkwps [OPTIONS] filename.wps [filename2.wps]...\n");
267 printf("\nOPTIONS:\n");
268 printf("\t-v\t\tverbose\n");
269 printf("\t-vv\t\tmore verbose\n");
270 printf("\t-vvv\t\tvery verbose\n");
271 printf("\t-h,\t--help\tshow this message\n");
275 if (argv
[1][0] == '-') {
278 while (argv
[1][i
] && argv
[1][i
] == 'v') {
283 skin_buffer
= malloc(SKIN_BUFFER_SIZE
);
286 printf("mallloc fail!\n");
290 skin_buffer_init(skin_buffer
, SKIN_BUFFER_SIZE
);
292 /* Go through every skin that was thrown at us, error out at the first
294 while (argv
[filearg
]) {
295 const char* name
= argv
[filearg
++];
296 char *ext
= strrchr(name
, '.');
297 printf("Checking %s...\n", name
);
300 printf("Invalid extension\n");
304 if (!strcmp(ext
, "rwps") || !strcmp(ext
, "rsbs") || !strcmp(ext
, "rfms"))
306 #ifdef HAVE_REMOTE_LCD
307 screen
= SCREEN_REMOTE
;
309 /* skip rwps etc. if not supported on this target (not an error) */
313 else if (!strcmp(ext
, "wps") || !strcmp(ext
, "sbs") || !strcmp(ext
, "fms"))
315 screen
= SCREEN_MAIN
;
319 printf("Invalid extension\n");
322 wps_screen
= &screens
[screen
];
324 res
= skin_data_load(screen
, &wps
, name
, true);
327 printf("WPS parsing failure\n");
328 skin_error_format_message();
332 printf("WPS parsed OK\n\n");
333 if (wps_verbose_level
>2)
334 skin_debug_tree(SKINOFFSETTOPTR(skin_buffer
, wps
.tree
));