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 "wps_internals.h"
33 bool debug_wps
= true;
34 int wps_verbose_level
= 0;
38 const struct settings_list
*settings
;
39 const int nb_settings
= 0;
41 /* static endianness conversion */
42 #define SWAP_16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \
43 ((unsigned short)(x) << 8)))
45 #define SWAP_32(x) ((typeof(x))(unsigned long)( ((unsigned long)(x) >> 24) | \
46 (((unsigned long)(x) & 0xff0000ul) >> 8) | \
47 (((unsigned long)(x) & 0xff00ul) << 8) | \
48 ((unsigned long)(x) << 24)))
51 unsigned short letoh16(unsigned short x
)
53 unsigned short n
= 0x1234;
54 unsigned char* ch
= (unsigned char*)&n
;
67 unsigned short letoh32(unsigned short x
)
69 unsigned short n
= 0x1234;
70 unsigned char* ch
= (unsigned char*)&n
;
83 unsigned int htole32(unsigned int x
)
85 unsigned short n
= 0x1234;
86 unsigned char* ch
= (unsigned char*)&n
;
98 int read_line(int fd
, char* buffer
, int buffer_size
)
105 while (count
< buffer_size
)
109 if (1 != read(fd
, &c
, 1))
123 buffer
[MIN(count
, buffer_size
- 1)] = 0;
125 return errno
? -1 : num_read
;
128 bool load_wps_backdrop(const char* filename
)
133 bool load_remote_wps_backdrop(const char* filename
)
138 int recalc_dimension(struct dim
*dst
, struct dim
*src
)
143 int resize_on_load(struct bitmap
*bm
, bool dither
,
144 struct dim
*src
, struct rowset
*tmp_row
,
145 unsigned char *buf
, unsigned int len
,
146 const struct custom_format
*cformat
,
147 IF_PIX_FMT(int format_index
,)
148 struct img_part
* (*store_part
)(void *args
),
154 int audio_status(void)
159 struct mp3entry
* audio_current_track(void)
164 void audio_stop(void)
168 void audio_play(long offset
)
172 static char pluginbuf
[PLUGIN_BUFFER_SIZE
];
174 static unsigned dummy_func2(void)
179 void* plugin_get_buffer(size_t *buffer_size
)
181 *buffer_size
= PLUGIN_BUFFER_SIZE
;
185 struct user_settings global_settings
= {
187 #ifdef HAVE_LCD_COLOR
188 .bg_color
= LCD_DEFAULT_BG
,
189 .fg_color
= LCD_DEFAULT_FG
,
193 int getwidth(void) { return LCD_WIDTH
; }
194 int getheight(void) { return LCD_HEIGHT
; }
195 #ifdef HAVE_REMOTE_LCD
196 int remote_getwidth(void) { return LCD_REMOTE_WIDTH
; }
197 int remote_getheight(void) { return LCD_REMOTE_HEIGHT
; }
200 struct screen screens
[NB_SCREENS
] =
203 .screen_type
=SCREEN_MAIN
,
205 .lcdheight
=LCD_HEIGHT
,
207 #ifdef HAVE_LCD_COLOR
212 .getwidth
= getwidth
,
213 .getheight
= getheight
,
215 .get_foreground
=dummy_func2
,
216 .get_background
=dummy_func2
,
218 .backdrop_load
=backdrop_load
,
220 #ifdef HAVE_REMOTE_LCD
222 .screen_type
=SCREEN_REMOTE
,
223 .lcdwidth
=LCD_REMOTE_WIDTH
,
224 .lcdheight
=LCD_REMOTE_HEIGHT
,
225 .depth
=LCD_REMOTE_DEPTH
,
226 .is_color
=false,/* No color remotes yet */
227 .getwidth
=remote_getwidth
,
228 .getheight
=remote_getheight
,
229 #if LCD_REMOTE_DEPTH > 1
230 .get_foreground
=dummy_func2
,
231 .get_background
=dummy_func2
,
233 .backdrop_load
=backdrop_load
,
238 #ifdef HAVE_LCD_BITMAP
239 void screen_clear_area(struct screen
* display
, int xstart
, int ystart
,
240 int width
, int height
)
242 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
243 display
->fillrect(xstart
, ystart
, width
, height
);
244 display
->set_drawmode(DRMODE_SOLID
);
248 /* From skin_display.c */
249 void skin_data_init(struct wps_data
*wps_data
)
251 #ifdef HAVE_LCD_BITMAP
252 wps_data
->wps_sb_tag
= false;
253 wps_data
->show_sb_on_wps
= false;
254 wps_data
->peak_meter_enabled
= false;
255 wps_data
->images
= NULL
;
256 wps_data
->progressbars
= NULL
;
258 #else /* HAVE_LCD_CHARCELLS */
260 for (i
= 0; i
< 8; i
++)
262 wps_data
->wps_progress_pat
[i
] = 0;
264 wps_data
->full_line_progressbar
= false;
266 wps_data
->button_time_volume
= 0;
267 wps_data
->wps_loaded
= false;
270 #ifdef HAVE_LCD_BITMAP
271 struct gui_img
* find_image(char label
, struct wps_data
*data
)
273 struct skin_token_list
*list
= data
->images
;
276 struct gui_img
*img
= (struct gui_img
*)list
->token
->value
.data
;
277 if (img
->label
== label
)
285 struct skin_viewport
* find_viewport(char label
, struct wps_data
*data
)
287 struct skin_token_list
*list
= data
->viewports
;
290 struct skin_viewport
*vp
= (struct skin_viewport
*)list
->token
->value
.data
;
291 if (vp
->label
== label
)
298 int main(int argc
, char **argv
)
304 struct screen
* wps_screen
= &screens
[SCREEN_MAIN
];
306 /* No arguments -> print the help text
307 * Also print the help text upon -h or --help */
309 strcmp(argv
[1],"-h") == 0 ||
310 strcmp(argv
[1],"--help") == 0 )
312 printf("Usage: checkwps [OPTIONS] filename.wps [filename2.wps]...\n");
313 printf("\nOPTIONS:\n");
314 printf("\t-v\t\tverbose\n");
315 printf("\t-vv\t\tmore verbose\n");
316 printf("\t-vvv\t\tvery verbose\n");
317 printf("\t-h,\t--help\tshow this message\n");
321 if (argv
[1][0] == '-') {
324 while (argv
[1][i
] && argv
[1][i
] == 'v') {
332 /* Go through every wps that was thrown at us, error out at the first
334 while (argv
[filearg
]) {
335 printf("Checking %s...\n", argv
[filearg
]);
336 #ifdef HAVE_REMOTE_LCD
337 if(strcmp(&argv
[filearg
][strlen(argv
[filearg
])-4], "rwps") == 0)
339 wps_screen
= &screens
[SCREEN_REMOTE
];
340 wps
.remote_wps
= true;
344 wps_screen
= &screens
[SCREEN_MAIN
];
345 wps
.remote_wps
= false;
349 res
= skin_data_load(&wps
, wps_screen
, argv
[filearg
], true);
352 printf("WPS parsing failure\n");
356 printf("WPS parsed OK\n\n");