Пример #1
0
adv_error generate_interpolate_load(adv_conf* context, adv_generate_interpolate_set* interpolate)
{
	adv_conf_iterator i;
	unsigned mac = 0;

	conf_iterator_begin(&i, context, "device_video_format");
	while (!conf_iterator_is_end(&i)) {
		const char* s = conf_iterator_string_get(&i);

		if (parse_generate_interpolate(s, s+strlen(s), &interpolate->map[mac])!=0) {
			error_set("Invalid argument '%s' in option 'device_video_format'", s);
			return -1;
		}

		++mac;

		conf_iterator_next(&i);
	}

	if (!mac) {
		generate_interpolate_reset(interpolate);
		error_set("Missing 'device_video_format' specification");
		return 1;
	}

	/* sort */
	qsort(interpolate->map, mac, sizeof(adv_generate_interpolate), generate_interpolate_cmp);

	interpolate->mac = mac;

	return 0;
}
Пример #2
0
/* Load the list of video mode */
adv_error crtc_container_load(adv_conf* context, adv_crtc_container* cc)
{
	adv_conf_iterator i;
	int error = 0;

	conf_iterator_begin(&i, context, "device_video_modeline");
	while (!conf_iterator_is_end(&i)) {
		adv_crtc crtc;
		const char* s = conf_iterator_string_get(&i);
		if (crtc_parse(&crtc, s, s + strlen(s)) == 0) {
			crtc_container_insert(cc, &crtc);
		} else {
			if (!error) {
				error = 1;
				error_set("%s in argument '%s' for option 'device_video_modeline'", video_mode_parse_error_buffer, s);
			}
		}
		conf_iterator_next(&i);
	}

	return error ? -1 : 0;
}
Пример #3
0
adv_error advance_ui_inner_init(struct advance_ui_context* context, adv_conf* cfg_context)
{
	adv_conf_iterator k;
	adv_color_def def;

	context->state.ui_font = 0;
	context->state.ui_font_oriented = 0;

	if (strcmp(context->config.ui_font_buffer, "auto") != 0) {
		/* try reading the font, the real font is loaded later */
		adv_font* font;
		adv_fz* f;

		const char* file = file_config_file_home(context->config.ui_font_buffer);

		log_std(("emu:ui: font '%s'\n", file));

		f = fzopen(file, "rb");
		if (!f) {
			target_err("Error opening the font %s\n", file);
			return -1;
		}

		font = adv_font_load(f, 16, 16);
		if (!font) {
			target_err("Error reading the font %s\n%s\n", file, error_get());
			return -1;
		}

		adv_font_free(font);

		fzclose(f);
	}

	def = color_def_make_rgb_from_sizelenpos(3, 8, 0, 8, 8, 8, 16);

	if (strcmp(context->config.help_image_buffer, "auto") == 0) {
		adv_fz* f;
		unsigned i;

		log_std(("emu:ui: helpimage auto\n"));

		f = fzopenmemory(HELPIMAGE, HELPIMAGE_SIZE);

		context->state.help_image = adv_bitmap_load_png_rgb(f, def);
		if (!context->state.help_image) {
			target_err("Error reading the internal help image\n");
			return -1;
		}

		fzclose(f);

		log_std(("emu:ui: helptag auto\n"));
		i = 0;
		while (HELPTAG[i]) {
			char* d = strdup(HELPTAG[i]);

			log_std(("emu:ui: helptag '%s'\n", d));

			if (advance_ui_parse_help(context, d) != 0) {
				free(d);
				target_err("Invalid 'ui_helptag' option.\n%s\n", error_get());
				return -1;
			}

			free(d);

			++i;
		}
	} else {
		if (strcmp(context->config.help_image_buffer, "none") != 0) {
			adv_fz* f;
			const char* file = file_config_file_home(context->config.help_image_buffer);

			log_std(("emu:ui: helpimage '%s'\n", file));

			f = fzopen(file, "rb");
			if (!f) {
				target_err("Error opening the help image %s\n", file);
				return -1;
			}

			context->state.help_image = adv_bitmap_load_png_rgb(f, def);
			if (!context->state.help_image) {
				target_err("Error reading the help image %s\n%s\n", file, error_get());
				return -1;
			}

			fzclose(f);
		} else {
			context->state.help_image = 0;
		}

		log_std(("emu:ui: helptag start\n"));
		for (conf_iterator_begin(&k, cfg_context, "ui_helptag"); !conf_iterator_is_end(&k); conf_iterator_next(&k)) {
			char* d = strdup(conf_iterator_string_get(&k));

			log_std(("emu:ui: helptag '%s'\n", d));

			if (advance_ui_parse_help(context, d) != 0) {
				free(d);
				target_err("Invalid 'ui_helptag' option.\n%s\n", error_get());
				return -1;
			}

			free(d);
		}
	}

	return 0;
}