aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/gfx
diff options
context:
space:
mode:
authorLars Persson2009-02-17 07:41:40 +0000
committerLars Persson2009-02-17 07:41:40 +0000
commit4f436e311d5a24f13d35de213e30f28a32d193bc (patch)
treee1aaa5a61e1328c10237cb9090b886c5295cb47a /engines/sci/gfx
parent6f9906d4c189f9381d0bb1bb901c4f7e5768343d (diff)
downloadscummvm-rg350-4f436e311d5a24f13d35de213e30f28a32d193bc.tar.gz
scummvm-rg350-4f436e311d5a24f13d35de213e30f28a32d193bc.tar.bz2
scummvm-rg350-4f436e311d5a24f13d35de213e30f28a32d193bc.zip
Remove functions not used, and thus the dependency on isblank.
svn-id: r38393
Diffstat (limited to 'engines/sci/gfx')
-rw-r--r--engines/sci/gfx/gfx_res_options.cpp422
1 files changed, 0 insertions, 422 deletions
diff --git a/engines/sci/gfx/gfx_res_options.cpp b/engines/sci/gfx/gfx_res_options.cpp
index f6316ca599..409ebdee4d 100644
--- a/engines/sci/gfx/gfx_res_options.cpp
+++ b/engines/sci/gfx/gfx_res_options.cpp
@@ -33,430 +33,8 @@
#include <ctype.h>
-#ifndef isblank
-# define isblank(c) ((c) == ' ' || (c) == '\t')
-#endif
-
/*#define DEBUG*/
-static gfx_res_pattern_list_t*
-pattern_list_insert(gfx_res_pattern_list_t *list, int min, int max) {
- gfx_res_pattern_list_t *retval = (gfx_res_pattern_list_t*)sci_malloc(sizeof(gfx_res_pattern_list_t));
- retval->pattern.min = min;
- retval->pattern.max = max;
- retval->next = list;
-
- return retval;
-}
-
-static int
-pattern_list_len(gfx_res_pattern_list_t *list) {
- int v = 0;
- while (list) {
- ++v;
- list = list->next;
- }
-
- return v;
-}
-
-static void
-pattern_list_flatten(gfx_res_pattern_t *dest, gfx_res_pattern_list_t *list) {
- while (list) {
- *dest++ = list->pattern;
- list = list->next;
- }
-}
-
-static inline void
-pattern_list_free(gfx_res_pattern_list_t *list) {
- if (list)
- pattern_list_free(list->next);
-
- free(list);
-}
-
-
-static inline int
-extract_pattern(gfx_res_pattern_list_t **destp,
- char *src, int offset) {
- char *src_orig = src - offset;
- int final = 0;
- int wildcard = 0;
-
- while (!final) {
- char *end = strchr(src, ',');
- if (end)
- *end = 0;
- else
- final = 1;
-
- while (*src && isblank(*src))
- ++src;
-
- if (*src == '*'
- || *src == '_') {
- wildcard = 1;
- ++src;
- } else if (*src == '.' || isdigit(*src)) {
- char *endp;
- int start = strtol(src, &endp, 0);
-
- if (*src == '.'
- && src[1] == '.') {
- start = GFX_RES_PATTERN_MIN;
- endp = src;
- }
-
- src = endp;
-
- while (*src && isblank(*src))
- ++src;
-
- if (*src) {
- int stop;
- if (*src == '.'
- && src[1] == '.') {
-
- src += 2;
- while (*src && isblank(*src))
- ++src;
-
- if (!*src)
- stop = GFX_RES_PATTERN_MAX;
- else if (!isdigit(*src)) {
- if (end)
- *end = ',';
- goto lexical_error_label;
- }
-
- stop = strtol(src, &endp, 0);
- src = endp;
-
- *destp = pattern_list_insert(*destp,
- start, stop);
-
- } else { /* No ellipsis */
- if (end)
- *end = ',';
- goto lexical_error_label;
- }
- } else /* End of sub-pattern */
- *destp = pattern_list_insert(*destp,
- start, start);
-
- while (*src && isblank(*src))
- ++src;
-
- if (*src) {
- if (end)
- *end = ',';
- goto lexical_error_label;
- }
-
- } else {
- if (end)
- *end = ',';
- sciprintf("[gfx-conf] Unexpected character '%c'\n",
- *src);
- goto lexical_error_label;
- }
-
- if (!final) {
- *end = ',';
- src = end + 1;
- }
- }
-
- if (wildcard) {
- pattern_list_free(*destp);
- *destp = NULL;
- }
-
- return 0;
-
-lexical_error_label:
- sciprintf("[gfx-conf] Lexical error in pattern at offset %d\n",
- src - src_orig);
- return 1;
-}
-
-static int
-extract_mod_rule(char *src, gfx_res_mod_t *rule) {
- char *orig_src = src;
- char *endp;
- float f[3];
- int i;
-
- rule->type = GFX_RES_MULTIPLY_FIXED;
-
- if (isdigit(*src) || *src == '.') {
- f[0] = f[1] = f[2] = strtod(src, &endp);
-
- if (*endp)
- goto mod_error_label;
- } else if (*src == '(') {
- i = 0;
- ++src;
-
- do {
- while (*src && isblank(*src))
- ++src;
- if (!*src || !(isdigit(*src) || *src == '.')) {
- sciprintf("[gfx-conf] Unexpected character '%c'\n",
- *src);
- goto mod_error_label;
- }
- f[i++] = strtod(src, &endp);
-
- src = endp;
-
- while (*src && isblank(*src))
- ++src;
-
- if ((i == 3) && *src != ')') {
- sciprintf("[gfx-conf] Error: Expected ')' at end of modification rule\n");
- goto mod_error_label;
- } else if (i < 3 && !isdigit(*src) && *src != '.' && *src != ',') {
- sciprintf("[gfx-conf] Error: Expected ',' as separator in modification rule, not '%c'\n",
- *src);
- goto mod_error_label;
- }
- ++src;
- } while (i < 3);
-
- if (*src) {
- sciprintf("[gfx-conf] Error: Trailing garbage after modification rule\n");
- goto mod_error_label;
- }
-
- } else
- goto mod_error_label;
-
- for (i = 0; i < 3; i++) {
- int v = (int)(f[i] * 16.0);
- rule->mod.factor[i] = (v > 255) ? 255 : v;
- }
-
- return 0;
-mod_error_label:
- sciprintf("[gfx-conf] Ill-formed modification rule '%s'\n",
- orig_src);
- return 1;
-}
-
-
-extern gfx_pixmap_color_t gfx_sci0_image_colors[][GFX_SCI0_IMAGE_COLORS_NR];
-
-#define PREDEFINED_PALETTES_NR 4
-static int
-extract_assign_rule(char *src, gfx_res_assign_t *rule) {
- /*char *orig_src = src;*/
- struct {
- const char *name;
- int colors_nr;
- gfx_pixmap_color_t *colors;
- } predefined_palettes[PREDEFINED_PALETTES_NR] = {
- {"default", 16, (gfx_pixmap_color_t *) &(gfx_sci0_image_colors[0])},
- {"amiga", 16, (gfx_pixmap_color_t *) &(gfx_sci0_image_colors[1])},
- {"gray", 16, (gfx_pixmap_color_t *) &(gfx_sci0_image_colors[2])},
- {"grey", 16, (gfx_pixmap_color_t *) &(gfx_sci0_image_colors[2])},
- };
- int i;
-
- rule->type = GFX_RES_ASSIGN_TYPE_PALETTE;
-
- for (i = 0; i < PREDEFINED_PALETTES_NR; i++)
- if (!strcmp(src, predefined_palettes[i].name)) {
- rule->assign.palette.colors_nr =
- predefined_palettes[i].colors_nr;
- rule->assign.palette.colors =
- predefined_palettes[i].colors;
- return 0;
- }
-
- sciprintf("[gfx-conf] Unknown palette '%s'\n", src);
- return 1;
- /*
- assign_error_label:
- sciprintf("[gfx-conf] Ill-formed assignment rule '%s'\n",
- orig_src);
- return 1;
- */
-}
-
-#define CLASSES_NR 3
-int
-gfx_update_conf(gfx_options_t *options, char *str) {
- int total_patterns;
- int mod = 0; /* Modifier or assignment rule? */
- char *orig_str = str;
- char *sem_end;
-
- int fields_nr; /* Number of fields a restriction is possible by.
- ** cursors:1, pics:2, views:3. */
- struct {
- const char *class_name;
- int class_id;
- int fields_nr;
- } classes[CLASSES_NR] = {
- {"view", GFX_RESOURCE_TYPE_VIEW, 3},
- {"pic", GFX_RESOURCE_TYPE_PIC, 2},
- {"cursor", GFX_RESOURCE_TYPE_CURSOR, 1},
- };
- gfx_res_conf_t *conf = (gfx_res_conf_t*)sci_malloc(sizeof(gfx_res_conf_t));
- gfx_res_pattern_list_t *patterns = NULL;
- gfx_res_pattern_list_t *loops = NULL;
- gfx_res_pattern_list_t *cels = NULL;
- gfx_res_pattern_list_t **fields[3] = {
- &patterns, &loops, &cels
- };
- int i;
- int fieldcnt;
- const char *pat_name_str;
-
- /* Extract pattern(s) */
- while (*str && isblank(*str))
- ++str;
-
- fields_nr = -1;
- for (i = 0; i < CLASSES_NR; i++) {
- int len = strlen(classes[i].class_name);
-
- if (!strncmp(str, classes[i].class_name, len)) {
- pat_name_str = classes[i].class_name;
- conf->type = classes[i].class_id;
- fields_nr = classes[i].fields_nr;
- str += len;
- break;
- }
- }
-
- if (fields_nr == -1) {
- sciprintf("[gfx-conf] Unexpected pattern class: Expected one of 'view', 'pic', 'cursor'\n");
- goto failure_label;
- }
-
- fieldcnt = 0;
- do {
- while (*str && isblank(*str))
- ++str;
-
- if (!*str)
- goto unexpected_end;
-
- if (*str == '='
- || *str == '*')
- break;
-
- if (*str == '(') {
- char *end = strchr(str, ')');
-
- if (fieldcnt >= fields_nr) {
- sciprintf("[gfx-conf] Error: Patterns of class '%s' may only be"
- " constrained by %d arguments\n",
- pat_name_str, fields_nr);
- goto failure_label;
- }
-
- if (!end) {
- sciprintf("[gfx-conf] Unmatched parentheses at offset %d\n",
- str - orig_str);
- goto failure_label;
- }
- *end = 0;
-
- if (extract_pattern(fields[fieldcnt++],
- str + 1,
- str + 1 - orig_str))
- goto failure_label;
-
- *end = ')';
- str = end + 1;
-
- continue;
- }
-
- sciprintf("[gfx-conf] Lexical error in pattern at offset %d: Unexpected '%c'\n",
- str - orig_str, *str);
- goto failure_label;
- } while (1);
-
-
- /* Flatten patterns */
- conf->patterns = NULL;
- total_patterns = conf->patterns_nr = pattern_list_len(patterns);
- total_patterns += (conf->loops_nr = pattern_list_len(loops));
- total_patterns += (conf->cels_nr = pattern_list_len(cels));
-
- conf->patterns = (gfx_res_pattern_t*)sci_malloc(1 + (sizeof(gfx_res_pattern_t) * total_patterns));
- pattern_list_flatten(conf->patterns, patterns);
- pattern_list_flatten(conf->patterns + conf->patterns_nr, loops);
- pattern_list_flatten(conf->patterns + conf->patterns_nr + conf->loops_nr, cels);
-
- pattern_list_free(patterns);
- patterns = NULL;
- pattern_list_free(loops);
- loops = NULL;
- pattern_list_free(cels);
- cels = NULL;
-
- /* Parse remainder */
- if (*str == '*') {
- mod = 1;
- ++str;
- }
-
- if (*str != '=') {
- sciprintf("[gfx-conf] Expected '='\n");
- goto failure_label;
- }
-
- do { ++str; }
- while (*str && isblank(*str));
-
- sem_end = strchr(str, ';');
- if (!sem_end) {
- sciprintf("[gfx-conf] Expected ';' at end of rule\n");
- goto failure_label;
- }
- do { *sem_end-- = 0; }
- while (sem_end >= str
- && isblank(*sem_end));
-
- if (mod) {
- if (extract_mod_rule(str, &conf->conf.mod))
- goto failure_label;
- } else {
- if (extract_assign_rule(str, &conf->conf.assign))
- goto failure_label;
- }
-
- /* Write back into options */
- if (mod) {
- conf->next = options->res_conf.mod[conf->type];
- options->res_conf.mod[conf->type] = conf;
- } else {
- conf->next = options->res_conf.assign[conf->type];
- options->res_conf.assign[conf->type] = conf;
- }
-
- return 0;
-
- /* Error handling */
-unexpected_end:
- sciprintf("[gfx-conf] Unexpected end of pattern encountered\n");
-failure_label:
- sciprintf("[gfx-conf] Error occured in: '%s'\n", orig_str);
- pattern_list_free(patterns);
- pattern_list_free(loops);
- pattern_list_free(cels);
- if (conf->patterns)
- free(conf->patterns);
- free(conf);
- return 1;
-}
-
static inline int
matches_patternlist(gfx_res_pattern_t *patterns, int nr, int val) {
int i;