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_engine.h"
30 #include "wps_internals.h"
35 bool debug_wps
= true;
36 int wps_verbose_level
= 0;
40 const struct settings_list
*settings
;
41 const int nb_settings
= 0;
43 /* static endianness conversion */
44 #define SWAP_16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \
45 ((unsigned short)(x) << 8)))
47 #define SWAP_32(x) ((typeof(x))(unsigned long)( ((unsigned long)(x) >> 24) | \
48 (((unsigned long)(x) & 0xff0000ul) >> 8) | \
49 (((unsigned long)(x) & 0xff00ul) << 8) | \
50 ((unsigned long)(x) << 24)))
53 unsigned short letoh16(unsigned short x
)
55 unsigned short n
= 0x1234;
56 unsigned char* ch
= (unsigned char*)&n
;
69 unsigned short letoh32(unsigned short x
)
71 unsigned short n
= 0x1234;
72 unsigned char* ch
= (unsigned char*)&n
;
85 unsigned int htole32(unsigned int x
)
87 unsigned short n
= 0x1234;
88 unsigned char* ch
= (unsigned char*)&n
;
100 int read_line(int fd
, char* buffer
, int buffer_size
)
107 while (count
< buffer_size
)
111 if (1 != read(fd
, &c
, 1))
125 buffer
[MIN(count
, buffer_size
- 1)] = 0;
127 return errno
? -1 : num_read
;
130 bool load_wps_backdrop(const char* filename
)
135 bool load_remote_wps_backdrop(const char* filename
)
140 int recalc_dimension(struct dim
*dst
, struct dim
*src
)
146 int playback_claim_aa_slot(struct dim
*dim
)
151 void playback_release_aa_slot(int slot
)
157 int resize_on_load(struct bitmap
*bm
, bool dither
,
158 struct dim
*src
, struct rowset
*tmp_row
,
159 unsigned char *buf
, unsigned int len
,
160 const struct custom_format
*cformat
,
161 IF_PIX_FMT(int format_index
,)
162 struct img_part
* (*store_part
)(void *args
),
168 int audio_status(void)
173 struct mp3entry
* audio_current_track(void)
178 void audio_stop(void)
182 void audio_play(long offset
)
186 static char pluginbuf
[PLUGIN_BUFFER_SIZE
];
188 static unsigned dummy_func2(void)
193 void* plugin_get_buffer(size_t *buffer_size
)
195 *buffer_size
= PLUGIN_BUFFER_SIZE
;
199 struct user_settings global_settings
= {
201 #ifdef HAVE_LCD_COLOR
202 .bg_color
= LCD_DEFAULT_BG
,
203 .fg_color
= LCD_DEFAULT_FG
,
207 int getwidth(void) { return LCD_WIDTH
; }
208 int getheight(void) { return LCD_HEIGHT
; }
209 #ifdef HAVE_REMOTE_LCD
210 int remote_getwidth(void) { return LCD_REMOTE_WIDTH
; }
211 int remote_getheight(void) { return LCD_REMOTE_HEIGHT
; }
214 struct screen screens
[NB_SCREENS
] =
217 .screen_type
=SCREEN_MAIN
,
219 .lcdheight
=LCD_HEIGHT
,
221 #ifdef HAVE_LCD_COLOR
226 .getwidth
= getwidth
,
227 .getheight
= getheight
,
229 .get_foreground
=dummy_func2
,
230 .get_background
=dummy_func2
,
232 .backdrop_load
=backdrop_load
,
234 #ifdef HAVE_REMOTE_LCD
236 .screen_type
=SCREEN_REMOTE
,
237 .lcdwidth
=LCD_REMOTE_WIDTH
,
238 .lcdheight
=LCD_REMOTE_HEIGHT
,
239 .depth
=LCD_REMOTE_DEPTH
,
240 .is_color
=false,/* No color remotes yet */
241 .getwidth
=remote_getwidth
,
242 .getheight
=remote_getheight
,
243 #if LCD_REMOTE_DEPTH > 1
244 .get_foreground
=dummy_func2
,
245 .get_background
=dummy_func2
,
247 .backdrop_load
=backdrop_load
,
252 #ifdef HAVE_LCD_BITMAP
253 void screen_clear_area(struct screen
* display
, int xstart
, int ystart
,
254 int width
, int height
)
256 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
257 display
->fillrect(xstart
, ystart
, width
, height
);
258 display
->set_drawmode(DRMODE_SOLID
);
262 /* From skin_display.c */
263 void skin_data_init(struct wps_data
*wps_data
)
265 #ifdef HAVE_LCD_BITMAP
266 wps_data
->wps_sb_tag
= false;
267 wps_data
->show_sb_on_wps
= false;
268 wps_data
->peak_meter_enabled
= false;
269 wps_data
->images
= NULL
;
270 wps_data
->progressbars
= NULL
;
272 #else /* HAVE_LCD_CHARCELLS */
274 for (i
= 0; i
< 8; i
++)
276 wps_data
->wps_progress_pat
[i
] = 0;
278 wps_data
->full_line_progressbar
= false;
280 wps_data
->button_time_volume
= 0;
281 wps_data
->wps_loaded
= false;
284 #ifdef HAVE_LCD_BITMAP
285 struct gui_img
* find_image(char label
, struct wps_data
*data
)
287 struct skin_token_list
*list
= data
->images
;
290 struct gui_img
*img
= (struct gui_img
*)list
->token
->value
.data
;
291 if (img
->label
== label
)
299 struct skin_viewport
* find_viewport(char label
, struct wps_data
*data
)
301 struct skin_token_list
*list
= data
->viewports
;
304 struct skin_viewport
*vp
= (struct skin_viewport
*)list
->token
->value
.data
;
305 if (vp
->label
== label
)
312 int main(int argc
, char **argv
)
318 #ifdef HAVE_REMOTE_LCD
319 struct screen
* wps_screen
= &screens
[SCREEN_MAIN
];
322 /* No arguments -> print the help text
323 * Also print the help text upon -h or --help */
325 strcmp(argv
[1],"-h") == 0 ||
326 strcmp(argv
[1],"--help") == 0 )
328 printf("Usage: checkwps [OPTIONS] filename.wps [filename2.wps]...\n");
329 printf("\nOPTIONS:\n");
330 printf("\t-v\t\tverbose\n");
331 printf("\t-vv\t\tmore verbose\n");
332 printf("\t-vvv\t\tvery verbose\n");
333 printf("\t-h,\t--help\tshow this message\n");
337 if (argv
[1][0] == '-') {
340 while (argv
[1][i
] && argv
[1][i
] == 'v') {
348 /* Go through every wps that was thrown at us, error out at the first
350 while (argv
[filearg
]) {
351 printf("Checking %s...\n", argv
[filearg
]);
352 #ifdef HAVE_REMOTE_LCD
353 if(strcmp(&argv
[filearg
][strlen(argv
[filearg
])-4], "rwps") == 0)
355 wps_screen
= &screens
[SCREEN_REMOTE
];
356 wps
.remote_wps
= true;
360 wps_screen
= &screens
[SCREEN_MAIN
];
361 wps
.remote_wps
= false;
365 res
= skin_data_load(&wps
, argv
[filearg
], true);
368 printf("WPS parsing failure\n");
372 printf("WPS parsed OK\n\n");