store the image label instead of a number so debug output is actually useful when %xd is used witout a coresponding %xl

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22404 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2009-08-18 07:17:51 +00:00
parent 36ca4967e0
commit dab7e16176
4 changed files with 16 additions and 22 deletions

View file

@ -478,13 +478,13 @@ static bool evaluate_conditional(struct gui_wps *gwps, int *token_index)
return true;
}
#ifdef HAVE_LCD_BITMAP
struct gui_img* find_image(int n, struct wps_data *data)
struct gui_img* find_image(char label, struct wps_data *data)
{
struct skin_token_list *list = data->images;
while (list)
{
struct gui_img *img = (struct gui_img *)list->token->value.data;
if (img->id == n)
if (img->label == label)
return img;
list = list->next;
}
@ -555,7 +555,7 @@ static bool get_line(struct gui_wps *gwps,
#ifdef HAVE_LCD_BITMAP
case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY:
{
int n = data->tokens[i].value.i & 0xFF;
char n = data->tokens[i].value.i & 0xFF;
int subimage = data->tokens[i].value.i >> 8;
struct gui_img *img = find_image(n, data);

View file

@ -482,19 +482,17 @@ static int parse_image_display(const char *wps_bufptr,
struct wps_token *token,
struct wps_data *wps_data)
{
int n = get_image_id(wps_bufptr[0]);
char label = wps_bufptr[0];
int subimage;
struct gui_img *img;;
if (n == -1)
/* sanity check */
img = find_image(label, wps_data);
if (!img)
{
/* invalid picture display tag */
token->value.i = label; /* do debug works */
return WPS_ERROR_INVALID_PARAM;
}
/* sanity check */
img = find_image(n, wps_data);
if (!img)
return WPS_ERROR_INVALID_PARAM;
if ((subimage = get_image_id(wps_bufptr[1])) != -1)
{
@ -502,10 +500,10 @@ static int parse_image_display(const char *wps_bufptr,
return WPS_ERROR_INVALID_PARAM;
/* Store sub-image number to display in high bits */
token->value.i = n | (subimage << 8);
token->value.i = label | (subimage << 8);
return 2; /* We have consumed 2 bytes */
} else {
token->value.i = n;
token->value.i = label;
return 1; /* We have consumed 1 byte */
}
}
@ -514,7 +512,6 @@ static int parse_image_load(const char *wps_bufptr,
struct wps_token *token,
struct wps_data *wps_data)
{
int n;
const char *ptr = wps_bufptr;
const char *pos;
const char* filename;
@ -540,11 +537,8 @@ static int parse_image_load(const char *wps_bufptr,
if (*ptr != '|')
return WPS_ERROR_INVALID_PARAM;
/* get the image ID */
n = get_image_id(*id);
/* check the image number and load state */
if(n < 0 || find_image(n, wps_data))
if(find_image(*id, wps_data))
{
/* Invalid image ID */
return WPS_ERROR_INVALID_PARAM;
@ -554,7 +548,7 @@ static int parse_image_load(const char *wps_bufptr,
return WPS_ERROR_INVALID_PARAM;
/* save a pointer to the filename */
img->bm.data = (char*)filename;
img->id = n;
img->label = *id;
img->x = x;
img->y = y;
img->num_subimages = 1;

View file

@ -113,8 +113,8 @@ static char *get_token_desc(struct wps_token *token, struct wps_data *data,
break;
case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY:
snprintf(buf, bufsize, "display preloaded image %d",
token->value.i);
snprintf(buf, bufsize, "display preloaded image '%c'",
token->value.i&0xFF);
break;
case WPS_TOKEN_IMAGE_DISPLAY:

View file

@ -77,7 +77,7 @@
#ifdef HAVE_LCD_BITMAP
struct gui_img {
short int id;
char label;
struct bitmap bm;
struct viewport* vp; /* The viewport to display this image in */
short int x; /* x-pos */
@ -346,7 +346,7 @@ const char *get_token_value(struct gui_wps *gwps,
struct gui_img* find_image(int n, struct wps_data *data);
struct gui_img* find_image(char label, struct wps_data *data);
struct skin_viewport* find_viewport(char label, struct wps_data *data);
#endif