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
)
144 int playback_claim_aa_slot(struct dim
*dim
)
149 void playback_release_aa_slot(int slot
)
155 int resize_on_load(struct bitmap
*bm
, bool dither
,
156 struct dim
*src
, struct rowset
*tmp_row
,
157 unsigned char *buf
, unsigned int len
,
158 const struct custom_format
*cformat
,
159 IF_PIX_FMT(int format_index
,)
160 struct img_part
* (*store_part
)(void *args
),
166 int audio_status(void)
171 struct mp3entry
* audio_current_track(void)
176 void audio_stop(void)
180 void audio_play(long offset
)
184 static char pluginbuf
[PLUGIN_BUFFER_SIZE
];
186 static unsigned dummy_func2(void)
191 void* plugin_get_buffer(size_t *buffer_size
)
193 *buffer_size
= PLUGIN_BUFFER_SIZE
;
197 struct user_settings global_settings
= {
199 #ifdef HAVE_LCD_COLOR
200 .bg_color
= LCD_DEFAULT_BG
,
201 .fg_color
= LCD_DEFAULT_FG
,
205 int getwidth(void) { return LCD_WIDTH
; }
206 int getheight(void) { return LCD_HEIGHT
; }
207 #ifdef HAVE_REMOTE_LCD
208 int remote_getwidth(void) { return LCD_REMOTE_WIDTH
; }
209 int remote_getheight(void) { return LCD_REMOTE_HEIGHT
; }
212 struct screen screens
[NB_SCREENS
] =
215 .screen_type
=SCREEN_MAIN
,
217 .lcdheight
=LCD_HEIGHT
,
219 #ifdef HAVE_LCD_COLOR
224 .getwidth
= getwidth
,
225 .getheight
= getheight
,
227 .get_foreground
=dummy_func2
,
228 .get_background
=dummy_func2
,
230 .backdrop_load
=backdrop_load
,
232 #ifdef HAVE_REMOTE_LCD
234 .screen_type
=SCREEN_REMOTE
,
235 .lcdwidth
=LCD_REMOTE_WIDTH
,
236 .lcdheight
=LCD_REMOTE_HEIGHT
,
237 .depth
=LCD_REMOTE_DEPTH
,
238 .is_color
=false,/* No color remotes yet */
239 .getwidth
=remote_getwidth
,
240 .getheight
=remote_getheight
,
241 #if LCD_REMOTE_DEPTH > 1
242 .get_foreground
=dummy_func2
,
243 .get_background
=dummy_func2
,
245 .backdrop_load
=backdrop_load
,
250 #ifdef HAVE_LCD_BITMAP
251 void screen_clear_area(struct screen
* display
, int xstart
, int ystart
,
252 int width
, int height
)
254 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
255 display
->fillrect(xstart
, ystart
, width
, height
);
256 display
->set_drawmode(DRMODE_SOLID
);
260 /* From skin_display.c */
261 void skin_data_init(struct wps_data
*wps_data
)
263 #ifdef HAVE_LCD_BITMAP
264 wps_data
->wps_sb_tag
= false;
265 wps_data
->show_sb_on_wps
= false;
266 wps_data
->peak_meter_enabled
= false;
267 wps_data
->images
= NULL
;
268 wps_data
->progressbars
= NULL
;
270 #else /* HAVE_LCD_CHARCELLS */
272 for (i
= 0; i
< 8; i
++)
274 wps_data
->wps_progress_pat
[i
] = 0;
276 wps_data
->full_line_progressbar
= false;
278 wps_data
->button_time_volume
= 0;
279 wps_data
->wps_loaded
= false;
282 #ifdef HAVE_LCD_BITMAP
283 struct gui_img
* find_image(char label
, struct wps_data
*data
)
285 struct skin_token_list
*list
= data
->images
;
288 struct gui_img
*img
= (struct gui_img
*)list
->token
->value
.data
;
289 if (img
->label
== label
)
297 struct skin_viewport
* find_viewport(char label
, struct wps_data
*data
)
299 struct skin_token_list
*list
= data
->viewports
;
302 struct skin_viewport
*vp
= (struct skin_viewport
*)list
->token
->value
.data
;
303 if (vp
->label
== label
)
310 int main(int argc
, char **argv
)
316 struct screen
* wps_screen
= &screens
[SCREEN_MAIN
];
318 /* No arguments -> print the help text
319 * Also print the help text upon -h or --help */
321 strcmp(argv
[1],"-h") == 0 ||
322 strcmp(argv
[1],"--help") == 0 )
324 printf("Usage: checkwps [OPTIONS] filename.wps [filename2.wps]...\n");
325 printf("\nOPTIONS:\n");
326 printf("\t-v\t\tverbose\n");
327 printf("\t-vv\t\tmore verbose\n");
328 printf("\t-vvv\t\tvery verbose\n");
329 printf("\t-h,\t--help\tshow this message\n");
333 if (argv
[1][0] == '-') {
336 while (argv
[1][i
] && argv
[1][i
] == 'v') {
344 /* Go through every wps that was thrown at us, error out at the first
346 while (argv
[filearg
]) {
347 printf("Checking %s...\n", argv
[filearg
]);
348 #ifdef HAVE_REMOTE_LCD
349 if(strcmp(&argv
[filearg
][strlen(argv
[filearg
])-4], "rwps") == 0)
351 wps_screen
= &screens
[SCREEN_REMOTE
];
352 wps
.remote_wps
= true;
356 wps_screen
= &screens
[SCREEN_MAIN
];
357 wps
.remote_wps
= false;
361 res
= skin_data_load(&wps
, argv
[filearg
], true);
364 printf("WPS parsing failure\n");
368 printf("WPS parsed OK\n\n");