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_buffer.h"
30 #include "skin_debug.h"
31 #include "skin_engine.h"
32 #include "wps_internals.h"
38 bool debug_wps
= true;
39 int wps_verbose_level
= 0;
43 const struct settings_list
*settings
;
44 const int nb_settings
= 0;
46 /* static endianness conversion */
47 #define SWAP_16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \
48 ((unsigned short)(x) << 8)))
50 #define SWAP_32(x) ((typeof(x))(unsigned long)( ((unsigned long)(x) >> 24) | \
51 (((unsigned long)(x) & 0xff0000ul) >> 8) | \
52 (((unsigned long)(x) & 0xff00ul) << 8) | \
53 ((unsigned long)(x) << 24)))
56 unsigned short letoh16(unsigned short x
)
58 unsigned short n
= 0x1234;
59 unsigned char* ch
= (unsigned char*)&n
;
72 unsigned short letoh32(unsigned short x
)
74 unsigned short n
= 0x1234;
75 unsigned char* ch
= (unsigned char*)&n
;
88 unsigned int htole32(unsigned int x
)
90 unsigned short n
= 0x1234;
91 unsigned char* ch
= (unsigned char*)&n
;
103 int recalc_dimension(struct dim
*dst
, struct dim
*src
)
109 int playback_claim_aa_slot(struct dim
*dim
)
114 void playback_release_aa_slot(int slot
)
120 int resize_on_load(struct bitmap
*bm
, bool dither
,
121 struct dim
*src
, struct rowset
*tmp_row
,
122 unsigned char *buf
, unsigned int len
,
123 const struct custom_format
*cformat
,
124 IF_PIX_FMT(int format_index
,)
125 struct img_part
* (*store_part
)(void *args
),
131 static char pluginbuf
[PLUGIN_BUFFER_SIZE
];
133 static unsigned dummy_func2(void)
138 void* plugin_get_buffer(size_t *buffer_size
)
140 *buffer_size
= PLUGIN_BUFFER_SIZE
;
144 struct user_settings global_settings
= {
145 .statusbar
= STATUSBAR_TOP
,
146 #ifdef HAVE_LCD_COLOR
147 .bg_color
= LCD_DEFAULT_BG
,
148 .fg_color
= LCD_DEFAULT_FG
,
152 int getwidth(void) { return LCD_WIDTH
; }
153 int getheight(void) { return LCD_HEIGHT
; }
154 #ifdef HAVE_REMOTE_LCD
155 int remote_getwidth(void) { return LCD_REMOTE_WIDTH
; }
156 int remote_getheight(void) { return LCD_REMOTE_HEIGHT
; }
159 static inline bool backdrop_load(const char *filename
, char* backdrop_buffer
)
161 (void)filename
; (void)backdrop_buffer
; return true;
164 struct screen screens
[NB_SCREENS
] =
167 .screen_type
=SCREEN_MAIN
,
169 .lcdheight
=LCD_HEIGHT
,
171 #ifdef HAVE_LCD_COLOR
176 .getwidth
= getwidth
,
177 .getheight
= getheight
,
179 .get_foreground
=dummy_func2
,
180 .get_background
=dummy_func2
,
181 .backdrop_load
=backdrop_load
,
184 #ifdef HAVE_REMOTE_LCD
186 .screen_type
=SCREEN_REMOTE
,
187 .lcdwidth
=LCD_REMOTE_WIDTH
,
188 .lcdheight
=LCD_REMOTE_HEIGHT
,
189 .depth
=LCD_REMOTE_DEPTH
,
190 .is_color
=false,/* No color remotes yet */
191 .getwidth
=remote_getwidth
,
192 .getheight
=remote_getheight
,
193 #if LCD_REMOTE_DEPTH > 1
194 .get_foreground
=dummy_func2
,
195 .get_background
=dummy_func2
,
196 .backdrop_load
=backdrop_load
,
202 #ifdef HAVE_LCD_BITMAP
203 void screen_clear_area(struct screen
* display
, int xstart
, int ystart
,
204 int width
, int height
)
206 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
207 display
->fillrect(xstart
, ystart
, width
, height
);
208 display
->set_drawmode(DRMODE_SOLID
);
213 bool radio_hardware_present(void)
219 #ifdef HAVE_LCD_BITMAP
220 static int loaded_fonts
= 0;
221 int font_load(struct font
* pf
, const char *path
)
223 int id
= SYSTEMFONTCOUNT
+ loaded_fonts
;
228 void font_unload(int font_id
)
234 int main(int argc
, char **argv
)
239 struct wps_data wps
={0};
240 enum screen_type screen
= SCREEN_MAIN
;
241 struct screen
* wps_screen
;
245 /* No arguments -> print the help text
246 * Also print the help text upon -h or --help */
248 strcmp(argv
[1],"-h") == 0 ||
249 strcmp(argv
[1],"--help") == 0 )
251 printf("Usage: checkwps [OPTIONS] filename.wps [filename2.wps]...\n");
252 printf("\nOPTIONS:\n");
253 printf("\t-v\t\tverbose\n");
254 printf("\t-vv\t\tmore verbose\n");
255 printf("\t-vvv\t\tvery verbose\n");
256 printf("\t-h,\t--help\tshow this message\n");
260 if (argv
[1][0] == '-') {
263 while (argv
[1][i
] && argv
[1][i
] == 'v') {
268 buffer
= malloc(SKIN_BUFFER_SIZE
);
271 printf("mallloc fail!\n");
275 skin_buffer_init(buffer
, SKIN_BUFFER_SIZE
);
276 #ifdef HAVE_LCD_BITMAP
280 /* Go through every skin that was thrown at us, error out at the first
282 while (argv
[filearg
]) {
283 printf("Checking %s...\n", argv
[filearg
]);
284 #ifdef HAVE_REMOTE_LCD
285 if((strcmp(&argv
[filearg
][strlen(argv
[filearg
])-4], "rwps") == 0) ||
286 (strcmp(&argv
[filearg
][strlen(argv
[filearg
])-4], "rsbs") == 0) ||
287 (strcmp(&argv
[filearg
][strlen(argv
[filearg
])-4], "rfms") == 0))
288 screen
= SCREEN_REMOTE
;
290 screen
= SCREEN_MAIN
;
292 wps_screen
= &screens
[screen
];
294 res
= skin_data_load(screen
, &wps
, argv
[filearg
], true);
297 printf("WPS parsing failure\n");
298 skin_error_format_message();
302 printf("WPS parsed OK\n\n");
303 if (wps_verbose_level
>2)
304 skin_debug_tree(wps
.tree
);