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 recalc_dimension(struct dim
*dst
, struct dim
*src
)
107 int playback_claim_aa_slot(struct dim
*dim
)
112 void playback_release_aa_slot(int slot
)
118 int resize_on_load(struct bitmap
*bm
, bool dither
,
119 struct dim
*src
, struct rowset
*tmp_row
,
120 unsigned char *buf
, unsigned int len
,
121 const struct custom_format
*cformat
,
122 IF_PIX_FMT(int format_index
,)
123 struct img_part
* (*store_part
)(void *args
),
129 static char pluginbuf
[PLUGIN_BUFFER_SIZE
];
131 static unsigned dummy_func2(void)
136 void* plugin_get_buffer(size_t *buffer_size
)
138 *buffer_size
= PLUGIN_BUFFER_SIZE
;
142 struct user_settings global_settings
= {
143 .statusbar
= STATUSBAR_TOP
,
144 #ifdef HAVE_LCD_COLOR
145 .bg_color
= LCD_DEFAULT_BG
,
146 .fg_color
= LCD_DEFAULT_FG
,
150 int getwidth(void) { return LCD_WIDTH
; }
151 int getheight(void) { return LCD_HEIGHT
; }
152 #ifdef HAVE_REMOTE_LCD
153 int remote_getwidth(void) { return LCD_REMOTE_WIDTH
; }
154 int remote_getheight(void) { return LCD_REMOTE_HEIGHT
; }
157 static inline bool backdrop_load(const char *filename
, char* backdrop_buffer
)
159 (void)filename
; (void)backdrop_buffer
; return true;
162 struct screen screens
[NB_SCREENS
] =
165 .screen_type
=SCREEN_MAIN
,
167 .lcdheight
=LCD_HEIGHT
,
169 #ifdef HAVE_LCD_COLOR
174 .getwidth
= getwidth
,
175 .getheight
= getheight
,
177 .get_foreground
=dummy_func2
,
178 .get_background
=dummy_func2
,
179 .backdrop_load
=backdrop_load
,
182 #ifdef HAVE_REMOTE_LCD
184 .screen_type
=SCREEN_REMOTE
,
185 .lcdwidth
=LCD_REMOTE_WIDTH
,
186 .lcdheight
=LCD_REMOTE_HEIGHT
,
187 .depth
=LCD_REMOTE_DEPTH
,
188 .is_color
=false,/* No color remotes yet */
189 .getwidth
=remote_getwidth
,
190 .getheight
=remote_getheight
,
191 #if LCD_REMOTE_DEPTH > 1
192 .get_foreground
=dummy_func2
,
193 .get_background
=dummy_func2
,
194 .backdrop_load
=backdrop_load
,
200 #ifdef HAVE_LCD_BITMAP
201 void screen_clear_area(struct screen
* display
, int xstart
, int ystart
,
202 int width
, int height
)
204 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
205 display
->fillrect(xstart
, ystart
, width
, height
);
206 display
->set_drawmode(DRMODE_SOLID
);
210 #ifdef HAVE_LCD_BITMAP
211 static int loaded_fonts
= 0;
212 int font_load(struct font
* pf
, const char *path
)
214 int id
= SYSTEMFONTCOUNT
+ loaded_fonts
;
219 void font_unload(int font_id
)
225 int main(int argc
, char **argv
)
231 enum screen_type screen
= SCREEN_MAIN
;
232 struct screen
* wps_screen
;
234 /* No arguments -> print the help text
235 * Also print the help text upon -h or --help */
237 strcmp(argv
[1],"-h") == 0 ||
238 strcmp(argv
[1],"--help") == 0 )
240 printf("Usage: checkwps [OPTIONS] filename.wps [filename2.wps]...\n");
241 printf("\nOPTIONS:\n");
242 printf("\t-v\t\tverbose\n");
243 printf("\t-vv\t\tmore verbose\n");
244 printf("\t-vvv\t\tvery verbose\n");
245 printf("\t-h,\t--help\tshow this message\n");
249 if (argv
[1][0] == '-') {
252 while (argv
[1][i
] && argv
[1][i
] == 'v') {
259 #ifdef HAVE_LCD_BITMAP
263 /* Go through every wps that was thrown at us, error out at the first
265 while (argv
[filearg
]) {
266 printf("Checking %s...\n", argv
[filearg
]);
267 #ifdef HAVE_REMOTE_LCD
268 if((strcmp(&argv
[filearg
][strlen(argv
[filearg
])-4], "rwps") == 0) ||
269 (strcmp(&argv
[filearg
][strlen(argv
[filearg
])-4], "rsbs") == 0))
270 screen
= SCREEN_REMOTE
;
272 screen
= SCREEN_MAIN
;
274 wps_screen
= &screens
[screen
];
276 res
= skin_data_load(screen
, &wps
, argv
[filearg
], true);
279 printf("WPS parsing failure\n");
283 printf("WPS parsed OK\n\n");