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 int recalc_dimension(struct dim
*dst
, struct dim
*src
)
136 int playback_claim_aa_slot(struct dim
*dim
)
141 void playback_release_aa_slot(int slot
)
147 int resize_on_load(struct bitmap
*bm
, bool dither
,
148 struct dim
*src
, struct rowset
*tmp_row
,
149 unsigned char *buf
, unsigned int len
,
150 const struct custom_format
*cformat
,
151 IF_PIX_FMT(int format_index
,)
152 struct img_part
* (*store_part
)(void *args
),
158 static char pluginbuf
[PLUGIN_BUFFER_SIZE
];
160 static unsigned dummy_func2(void)
165 void* plugin_get_buffer(size_t *buffer_size
)
167 *buffer_size
= PLUGIN_BUFFER_SIZE
;
171 struct user_settings global_settings
= {
173 #ifdef HAVE_LCD_COLOR
174 .bg_color
= LCD_DEFAULT_BG
,
175 .fg_color
= LCD_DEFAULT_FG
,
179 int getwidth(void) { return LCD_WIDTH
; }
180 int getheight(void) { return LCD_HEIGHT
; }
181 #ifdef HAVE_REMOTE_LCD
182 int remote_getwidth(void) { return LCD_REMOTE_WIDTH
; }
183 int remote_getheight(void) { return LCD_REMOTE_HEIGHT
; }
186 struct screen screens
[NB_SCREENS
] =
189 .screen_type
=SCREEN_MAIN
,
191 .lcdheight
=LCD_HEIGHT
,
193 #ifdef HAVE_LCD_COLOR
198 .getwidth
= getwidth
,
199 .getheight
= getheight
,
201 .get_foreground
=dummy_func2
,
202 .get_background
=dummy_func2
,
204 .backdrop_load
=backdrop_load
,
206 #ifdef HAVE_REMOTE_LCD
208 .screen_type
=SCREEN_REMOTE
,
209 .lcdwidth
=LCD_REMOTE_WIDTH
,
210 .lcdheight
=LCD_REMOTE_HEIGHT
,
211 .depth
=LCD_REMOTE_DEPTH
,
212 .is_color
=false,/* No color remotes yet */
213 .getwidth
=remote_getwidth
,
214 .getheight
=remote_getheight
,
215 #if LCD_REMOTE_DEPTH > 1
216 .get_foreground
=dummy_func2
,
217 .get_background
=dummy_func2
,
219 .backdrop_load
=backdrop_load
,
224 #ifdef HAVE_LCD_BITMAP
225 void screen_clear_area(struct screen
* display
, int xstart
, int ystart
,
226 int width
, int height
)
228 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
229 display
->fillrect(xstart
, ystart
, width
, height
);
230 display
->set_drawmode(DRMODE_SOLID
);
234 int main(int argc
, char **argv
)
240 enum screen_type screen
= SCREEN_MAIN
;
241 struct screen
* wps_screen
;
243 /* No arguments -> print the help text
244 * Also print the help text upon -h or --help */
246 strcmp(argv
[1],"-h") == 0 ||
247 strcmp(argv
[1],"--help") == 0 )
249 printf("Usage: checkwps [OPTIONS] filename.wps [filename2.wps]...\n");
250 printf("\nOPTIONS:\n");
251 printf("\t-v\t\tverbose\n");
252 printf("\t-vv\t\tmore verbose\n");
253 printf("\t-vvv\t\tvery verbose\n");
254 printf("\t-h,\t--help\tshow this message\n");
258 if (argv
[1][0] == '-') {
261 while (argv
[1][i
] && argv
[1][i
] == 'v') {
269 /* Go through every wps that was thrown at us, error out at the first
271 while (argv
[filearg
]) {
272 printf("Checking %s...\n", argv
[filearg
]);
273 #ifdef HAVE_REMOTE_LCD
274 if(strcmp(&argv
[filearg
][strlen(argv
[filearg
])-4], "rwps") == 0)
275 screen
= SCREEN_REMOTE
;
277 wps_screen
= &screens
[screen
];
279 res
= skin_data_load(screen
, &wps
, argv
[filearg
], true);
282 printf("WPS parsing failure\n");
286 printf("WPS parsed OK\n\n");