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"
36 bool debug_wps
= true;
37 int wps_verbose_level
= 0;
41 const struct settings_list
*settings
;
42 const int nb_settings
= 0;
44 /* static endianness conversion */
45 #define SWAP_16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \
46 ((unsigned short)(x) << 8)))
48 #define SWAP_32(x) ((typeof(x))(unsigned long)( ((unsigned long)(x) >> 24) | \
49 (((unsigned long)(x) & 0xff0000ul) >> 8) | \
50 (((unsigned long)(x) & 0xff00ul) << 8) | \
51 ((unsigned long)(x) << 24)))
54 unsigned short letoh16(unsigned short x
)
56 unsigned short n
= 0x1234;
57 unsigned char* ch
= (unsigned char*)&n
;
70 unsigned short letoh32(unsigned short x
)
72 unsigned short n
= 0x1234;
73 unsigned char* ch
= (unsigned char*)&n
;
86 unsigned int htole32(unsigned int x
)
88 unsigned short n
= 0x1234;
89 unsigned char* ch
= (unsigned char*)&n
;
101 int read_line(int fd
, char* buffer
, int buffer_size
)
108 while (count
< buffer_size
)
112 if (1 != read(fd
, &c
, 1))
126 buffer
[MIN(count
, buffer_size
- 1)] = 0;
128 return errno
? -1 : num_read
;
131 int recalc_dimension(struct dim
*dst
, struct dim
*src
)
137 int playback_claim_aa_slot(struct dim
*dim
)
142 void playback_release_aa_slot(int slot
)
148 int resize_on_load(struct bitmap
*bm
, bool dither
,
149 struct dim
*src
, struct rowset
*tmp_row
,
150 unsigned char *buf
, unsigned int len
,
151 const struct custom_format
*cformat
,
152 IF_PIX_FMT(int format_index
,)
153 struct img_part
* (*store_part
)(void *args
),
159 static char pluginbuf
[PLUGIN_BUFFER_SIZE
];
161 static unsigned dummy_func2(void)
166 void* plugin_get_buffer(size_t *buffer_size
)
168 *buffer_size
= PLUGIN_BUFFER_SIZE
;
172 struct user_settings global_settings
= {
173 .statusbar
= STATUSBAR_TOP
,
174 #ifdef HAVE_LCD_COLOR
175 .bg_color
= LCD_DEFAULT_BG
,
176 .fg_color
= LCD_DEFAULT_FG
,
180 int getwidth(void) { return LCD_WIDTH
; }
181 int getheight(void) { return LCD_HEIGHT
; }
182 #ifdef HAVE_REMOTE_LCD
183 int remote_getwidth(void) { return LCD_REMOTE_WIDTH
; }
184 int remote_getheight(void) { return LCD_REMOTE_HEIGHT
; }
187 static inline bool backdrop_load(const char *filename
, char* backdrop_buffer
)
189 (void)filename
; (void)backdrop_buffer
; return true;
192 struct screen screens
[NB_SCREENS
] =
195 .screen_type
=SCREEN_MAIN
,
197 .lcdheight
=LCD_HEIGHT
,
199 #ifdef HAVE_LCD_COLOR
204 .getwidth
= getwidth
,
205 .getheight
= getheight
,
207 .get_foreground
=dummy_func2
,
208 .get_background
=dummy_func2
,
209 .backdrop_load
=backdrop_load
,
212 #ifdef HAVE_REMOTE_LCD
214 .screen_type
=SCREEN_REMOTE
,
215 .lcdwidth
=LCD_REMOTE_WIDTH
,
216 .lcdheight
=LCD_REMOTE_HEIGHT
,
217 .depth
=LCD_REMOTE_DEPTH
,
218 .is_color
=false,/* No color remotes yet */
219 .getwidth
=remote_getwidth
,
220 .getheight
=remote_getheight
,
221 #if LCD_REMOTE_DEPTH > 1
222 .get_foreground
=dummy_func2
,
223 .get_background
=dummy_func2
,
224 .backdrop_load
=backdrop_load
,
230 #ifdef HAVE_LCD_BITMAP
231 void screen_clear_area(struct screen
* display
, int xstart
, int ystart
,
232 int width
, int height
)
234 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
235 display
->fillrect(xstart
, ystart
, width
, height
);
236 display
->set_drawmode(DRMODE_SOLID
);
240 #ifdef HAVE_LCD_BITMAP
241 static int loaded_fonts
= 0;
242 int font_load(struct font
* pf
, const char *path
)
244 int id
= SYSTEMFONTCOUNT
+ loaded_fonts
;
249 void font_unload(int font_id
)
255 int main(int argc
, char **argv
)
261 enum screen_type screen
= SCREEN_MAIN
;
262 struct screen
* wps_screen
;
264 /* No arguments -> print the help text
265 * Also print the help text upon -h or --help */
267 strcmp(argv
[1],"-h") == 0 ||
268 strcmp(argv
[1],"--help") == 0 )
270 printf("Usage: checkwps [OPTIONS] filename.wps [filename2.wps]...\n");
271 printf("\nOPTIONS:\n");
272 printf("\t-v\t\tverbose\n");
273 printf("\t-vv\t\tmore verbose\n");
274 printf("\t-vvv\t\tvery verbose\n");
275 printf("\t-h,\t--help\tshow this message\n");
279 if (argv
[1][0] == '-') {
282 while (argv
[1][i
] && argv
[1][i
] == 'v') {
289 #ifdef HAVE_LCD_BITMAP
293 /* Go through every wps that was thrown at us, error out at the first
295 while (argv
[filearg
]) {
296 printf("Checking %s...\n", argv
[filearg
]);
297 #ifdef HAVE_REMOTE_LCD
298 if((strcmp(&argv
[filearg
][strlen(argv
[filearg
])-4], "rwps") == 0) ||
299 (strcmp(&argv
[filearg
][strlen(argv
[filearg
])-4], "rsbs") == 0))
300 screen
= SCREEN_REMOTE
;
302 screen
= SCREEN_MAIN
;
304 wps_screen
= &screens
[screen
];
306 res
= skin_data_load(screen
, &wps
, argv
[filearg
], true);
309 printf("WPS parsing failure\n");
313 printf("WPS parsed OK\n\n");