Пример #1
0
static void draw_text_info(int x, int y, int dx, int dy, int pos)
{
	char buffer[3][256];

	adv_crtc* crtc = menu_pos(pos);

	if (crtc) {
		format_info(buffer[0], buffer[1], buffer[2], 256, crtc);
	} else {
		sncpy(buffer[0], sizeof(buffer[0]), "");
		sncpy(buffer[1], sizeof(buffer[1]), "");
		sncpy(buffer[2], sizeof(buffer[2]), "");
	}

	draw_text_left(x, y+0, dx, buffer[0], COLOR_INFO_TITLE);
	draw_text_left(x, y+1, dx, buffer[1], COLOR_INFO_NORMAL);
	draw_text_left(x, y+2, dx, buffer[2], COLOR_INFO_NORMAL);

	if (crtc) {
		if (crtc_is_fake(crtc)) {
			draw_text_left(x+dx-8, y, 8, " SYSTEM ", COLOR_INFO_NORMAL);
		} else if (!crtc_clock_check(&the_monitor, crtc)) {
			draw_text_left(x+dx-14, y, 14, " OUT OF RANGE ", COLOR_ERROR);
		} else {
			draw_text_left(x+dx-14, y, 14, " PROGRAMMABLE ", COLOR_INFO_NORMAL);
		}
	} else {
		draw_text_fillrect(x, y, ' ', dx, dy, COLOR_INFO_NORMAL);
	}
}
Пример #2
0
void soundb_alsa_default(void)
{
	sncpy(alsa_option.device_buffer, sizeof(alsa_option.device_buffer), "default");
	sncpy(alsa_option.mixer_buffer, sizeof(alsa_option.mixer_buffer), "channel");

	alsa_option.initialized = 1;
}
Пример #3
0
static void mouseb_setup(struct mouse_item_context* item)
{
	unsigned i;
	struct button_entry {
		int code;
		const char* name;
	} button_map[] = {
		{ MOUSE_LEFTBUTTON, "left" },
		{ MOUSE_RIGHTBUTTON, "right" },
		{ MOUSE_MIDDLEBUTTON, "middle" },
		{ MOUSE_FOURTHBUTTON, "button4" },
		{ MOUSE_FIFTHBUTTON, "button5" },
		{ MOUSE_SIXTHBUTTON, "button6" }
	};

	struct axe_entry {
		int code;
		const char* name;
	} axe_map[] = {
		{ MOUSE_XDIM, "x" },
		{ MOUSE_YDIM, "y" },
		{ MOUSE_ZDIM, "z" },
		{ MOUSE_RXDIM, "rx" },
		{ MOUSE_RYDIM, "ry" },
		{ MOUSE_RZDIM, "rz" }
	};

	item->button_mac = 0;
	for (i = 0; i < sizeof(button_map) / sizeof(button_map[0]); ++i) {
		if ((item->context.info_button & button_map[i].code) != 0) {
			if (item->button_mac < RAW_MOUSE_BUTTON_MAX) {
				item->button_map[item->button_mac].code = button_map[i].code;
				item->button_map[item->button_mac].pvalue = &item->context.button;
				sncpy(item->button_map[item->button_mac].name, sizeof(item->button_map[item->button_mac].name), button_map[i].name);
				++item->button_mac;
			}
		}
	}

	item->axe_mac = 0;
	for (i = 0; i < sizeof(axe_map) / sizeof(axe_map[0]); ++i) {
		if ((item->context.info_button & axe_map[i].code) != 0) {
			if (item->axe_mac < RAW_MOUSE_AXE_MAX) {
				item->axe_map[item->axe_mac].code = axe_map[i].code;
				switch (axe_map[i].code) {
				case MOUSE_XDIM: item->axe_map[item->axe_mac].pvalue = &item->context.x; break;
				case MOUSE_YDIM: item->axe_map[item->axe_mac].pvalue = &item->context.y; break;
				case MOUSE_ZDIM: item->axe_map[item->axe_mac].pvalue = &item->context.z; break;
				case MOUSE_RXDIM: item->axe_map[item->axe_mac].pvalue = &item->context.rx; break;
				case MOUSE_RYDIM: item->axe_map[item->axe_mac].pvalue = &item->context.ry; break;
				case MOUSE_RZDIM: item->axe_map[item->axe_mac].pvalue = &item->context.rz; break;
				}
				sncpy(item->axe_map[item->axe_mac].name, sizeof(item->axe_map[item->axe_mac].name), axe_map[i].name);
				++item->axe_mac;
			}
		}
	}
}
Пример #4
0
adv_error soundb_alsa_load(adv_conf* context)
{
	sncpy(alsa_option.device_buffer, sizeof(alsa_option.device_buffer), conf_string_get_default(context, "device_alsa_device"));
	sncpy(alsa_option.mixer_buffer, sizeof(alsa_option.mixer_buffer), conf_string_get_default(context, "device_alsa_mixer"));

	alsa_option.initialized = 1;

	return 0;
}
Пример #5
0
static adv_error cmd_modeline_create(int favourite_vtotal)
{
	adv_crtc crtc;
	char buffer[80];
	double freq = 0;
	unsigned x;
	unsigned y;
	adv_error res;

	sncpy(buffer, sizeof(buffer), "");
	if (cmd_input_string(" Vertical clock [Hz] (example 60.0) : ", buffer, 10)!=0)
		return 0;
	freq = strtod(buffer, 0);
	if (freq < 10 || freq > 200) {
		error_set("Invalid vertical clock value, usually in the range 10 - 200.0 [Hz]");
		return -1;
	}

	sncpy(buffer, sizeof(buffer), "");
	if (cmd_input_string(" X resolution [pixel] : ", buffer, 10)!=0)
		return 0;
	x = atoi(buffer);
	if (x < 64 || x > 2048) {
		error_set("Invalid x resolution value");
		return -1;
	}

	sncpy(buffer, sizeof(buffer), "");
	if (cmd_input_string(" Y resolution [pixel] : ", buffer, 10)!=0)
		return 0;
	y = atoi(buffer);
	if (y < 64 || y > 2048) {
		error_set("Invalid y resolution value");
		return -1;
	}

	res = generate_find_interpolate_multi(&crtc, x, y, x*2, y*2, x*3, y*3, x*4, y*4, freq, &the_monitor, &the_interpolate, VIDEO_DRIVER_FLAGS_PROGRAMMABLE_SINGLESCAN | VIDEO_DRIVER_FLAGS_PROGRAMMABLE_DOUBLESCAN | VIDEO_DRIVER_FLAGS_PROGRAMMABLE_INTERLACE | VIDEO_DRIVER_FLAGS_PROGRAMMABLE_CLOCK | VIDEO_DRIVER_FLAGS_PROGRAMMABLE_CRTC, GENERATE_ADJUST_EXACT);
	if (favourite_vtotal) {
		if (res != 0)
			res = generate_find_interpolate_multi(&crtc, x, y, x*2, y*2, x*3, y*3, x*4, y*4, freq, &the_monitor, &the_interpolate, VIDEO_DRIVER_FLAGS_PROGRAMMABLE_SINGLESCAN | VIDEO_DRIVER_FLAGS_PROGRAMMABLE_DOUBLESCAN | VIDEO_DRIVER_FLAGS_PROGRAMMABLE_INTERLACE | VIDEO_DRIVER_FLAGS_PROGRAMMABLE_CLOCK | VIDEO_DRIVER_FLAGS_PROGRAMMABLE_CRTC, GENERATE_ADJUST_VCLOCK);
	} else {
		if (res != 0)
			res = generate_find_interpolate_multi(&crtc, x, y, x*2, y*2, x*3, y*3, x*4, y*4, freq, &the_monitor, &the_interpolate, VIDEO_DRIVER_FLAGS_PROGRAMMABLE_SINGLESCAN | VIDEO_DRIVER_FLAGS_PROGRAMMABLE_DOUBLESCAN | VIDEO_DRIVER_FLAGS_PROGRAMMABLE_INTERLACE | VIDEO_DRIVER_FLAGS_PROGRAMMABLE_CLOCK | VIDEO_DRIVER_FLAGS_PROGRAMMABLE_CRTC, GENERATE_ADJUST_VTOTAL);
	}
	if (res != 0)
		res = generate_find_interpolate_multi(&crtc, x, y, x*2, y*2, x*3, y*3, x*4, y*4, freq, &the_monitor, &the_interpolate, VIDEO_DRIVER_FLAGS_PROGRAMMABLE_SINGLESCAN | VIDEO_DRIVER_FLAGS_PROGRAMMABLE_DOUBLESCAN | VIDEO_DRIVER_FLAGS_PROGRAMMABLE_INTERLACE | VIDEO_DRIVER_FLAGS_PROGRAMMABLE_CLOCK | VIDEO_DRIVER_FLAGS_PROGRAMMABLE_CRTC, GENERATE_ADJUST_VCLOCK | GENERATE_ADJUST_VTOTAL);
	if (res != 0) {
		error_set("Request out of your monitor range");
		return -1;
	}

	menu_insert(&crtc);

	return 0;
}
Пример #6
0
static void mouseb_setup(struct mouse_item_context* item, unsigned nbutton)
{
	unsigned i;
	struct button_entry {
		int code;
		const char* name;
	} button_map[] = {
		{ 0x1, "left" },
		{ 0x2, "right" },
		{ 0x4, "middle" },
		{ 0x8, "button4" },
		{ 0x10, "button5" }
	};

	struct axe_entry {
		int code;
		const char* name;
	} axe_map[] = {
		{ 0, "x" },
		{ 1, "y" },
		{ 2, "z" }
	};

	item->button_mac = 0;
	for (i = 0; i < sizeof(button_map) / sizeof(button_map[0]); ++i) {
		if (i < nbutton) {
			if (item->button_mac < RAW_MOUSE_BUTTON_MAX) {
				item->button_map[item->button_mac].code = button_map[i].code;
				item->button_map[item->button_mac].pvalue = &item->context.button;
				sncpy(item->button_map[item->button_mac].name, sizeof(item->button_map[item->button_mac].name), button_map[i].name);
				++item->button_mac;
			}
		}
	}

	item->axe_mac = 0;
	for (i = 0; i < sizeof(axe_map) / sizeof(axe_map[0]); ++i) {
		if (item->axe_mac < RAW_MOUSE_AXE_MAX) {
			item->axe_map[item->axe_mac].code = axe_map[i].code;
			switch (axe_map[i].code) {
			case 0: item->axe_map[item->axe_mac].pvalue = &item->context.x; break;
			case 1: item->axe_map[item->axe_mac].pvalue = &item->context.y; break;
			case 2: item->axe_map[item->axe_mac].pvalue = &item->context.z; break;
			}
			sncpy(item->axe_map[item->axe_mac].name, sizeof(item->axe_map[item->axe_mac].name), axe_map[i].name);
			++item->axe_mac;
		}
	}
}
Пример #7
0
unsigned advance_ui_menu_option_insert(struct ui_menu* menu, const char* text, const char* option)
{
	struct ui_menu_entry* entry = &menu->map[menu->mac];

	assert(menu->mac < menu->max);
	if (menu->mac == menu->max)
		return -1;

	entry->type = ui_menu_option;
	sncpy(entry->text_buffer, sizeof(entry->text_buffer), text);
	sncpy(entry->option_buffer, sizeof(entry->option_buffer), option);
	++menu->mac;

	return ui_menu_select(menu) - 1;
}
Пример #8
0
adv_error device_check(const char* option, const char* arg, const adv_driver** driver_map, unsigned driver_mac, const char* driver_ignore)
{
	char buffer[DEVICE_NAME_MAX];
	const char* tag_one;
	unsigned i, j;

	/* check the validity of every item on the argument */
	sncpy(buffer, sizeof(buffer), arg);
	tag_one = strtok(buffer, " \t");
	while (tag_one) {
		if (strcmp("auto", tag_one)!=0 && strstr(driver_ignore, tag_one)==0) {
			for(i=0;i<driver_mac;++i) {
				if (strcmp(driver_map[i]->name, tag_one)==0)
					break;
				for(j=0;driver_map[i]->device_map[j].name;++j) {
					char cat_buffer[DEVICE_NAME_MAX];
					snprintf(cat_buffer, sizeof(cat_buffer), "%s/%s", driver_map[i]->name, driver_map[i]->device_map[j].name);
					if (strcmp(cat_buffer, tag_one)==0)
						break;
				}
				if (driver_map[i]->device_map[j].name)
					break;
			}
			if (i == driver_mac) {
				device_error(option, tag_one, driver_map, driver_mac);
				return -1;
			}
		}
		tag_one = strtok(NULL, " \t");
	}

	return 0;
}
Пример #9
0
int main(){
  char s[10]="hello";
  printf("%s: %d\n",s,slen(s)); //testing for slen
  char cpy[15]="aba";
  printf("After scpy, %s became: ",cpy);
  scpy(cpy,s);
  printf("%s\n",cpy);
  char ncpy[15]="abalaba";
  printf("After sncpy (n=3), %s became: ",ncpy);
  sncpy(ncpy,s,3);
  printf("%s\n",ncpy);
  char cat[15]="AddOn";
  printf("After scat, %s became: ",cpy);
  scat(cpy,cat);
  printf("%s\n",cpy);
  char s2[18]="hello";
  char s3[5]="po";
  char s4[5]="bao";
  printf("scmp %s and %s: %d\n",s,s2,scmp(s,s2));
  printf("scmp %s and %s: %d\n",s,cpy,scmp(s,cpy));
  printf("scmp %s and %s: %d\n",s,s3,scmp(s,s3));
  printf("scmp %s and %s: %d\n",s,s4,scmp(s,s4));
  printf("schr %s and %c: %s\n",s,'l',schr(s,'l'));
  printf("schr %s and %c: %s\n",s,'t',schr(s,'t'));
  char s5[5]="el";
  printf("sstr %s and %s: %s\n",s,s5,sstr(s,s5));
  printf("sstr %s and %s: %s\n",s,s3,sstr(s,s3));
  return 0;
}
Пример #10
0
adv_error mouseb_load(adv_conf* context)
{
	unsigned i;
	int at_least_one;

	if (mouseb_state.driver_mac == 0) {
		error_set("No mouse driver was compiled in.");
		return -1;
	}

	mouseb_state.is_initialized_flag = 1;
	sncpy(mouseb_state.name, DEVICE_NAME_MAX, conf_string_get_default(context, "device_mouse"));

	/* load specific driver options */
	at_least_one = 0;
	for (i = 0; i < mouseb_state.driver_mac; ++i) {
		const adv_device* dev;

		dev = device_match(mouseb_state.name, (adv_driver*)mouseb_state.driver_map[i], 0);

		if (dev)
			at_least_one = 1;

		if (mouseb_state.driver_map[i]->load(context) != 0)
			return -1;
	}

	if (!at_least_one) {
		device_error("device_mouse", mouseb_state.name, (const adv_driver**)mouseb_state.driver_map, mouseb_state.driver_mac);
		return -1;
	}

	return 0;
}
Пример #11
0
static void draw_text_bar(int x, int by1, int by2, int dx)
{
	char buffer[256];
	unsigned i;

	snprintf(buffer, sizeof(buffer), " AdvanceVIDEO Config - " __DATE__);

	draw_text_left(x, by1, dx, buffer, COLOR_BAR);

	sncpy(buffer, sizeof(buffer), "");
	for(i=0;i<video_driver_vector_max();++i) {
		if (video_driver_vector_pos(i) != 0) {
			if (*buffer)
				sncat(buffer, sizeof(buffer), "/");
			sncat(buffer, sizeof(buffer), video_driver_vector_pos(i)->name);
		}
	}

	draw_text_left(x + dx - strlen(buffer), by1, strlen(buffer), buffer, COLOR_BAR);

	snprintf(buffer, sizeof(buffer), " #    x    y pclock hclock vclock name");
	draw_text_left(x, by1+2, dx, buffer, COLOR_TITLE);

	snprintf(buffer, sizeof(buffer), " F1 Help  F2 Save  SPACE Select  TAB Rename  ENTER Test  ESC Exit");
	draw_text_left(x, by2, dx, buffer, COLOR_BAR);
}
Пример #12
0
int osd_get_path_info(int pathtype, int pathindex, const char* filename)
{
	struct fileio_item* i;
	char path_buffer[FILE_MAXPATH];
	struct stat st;

	log_std(("osd: osd_get_path_info(pathtype:%d,pathindex:%d,filename:%s)\n", pathtype, pathindex, filename));

	i = fileio_find(pathtype);
	if (!i) {
		log_std(("WARNING:fileio: file type %d unknown\n", pathtype));
		return PATH_NOT_FOUND;
	}

	sncpy(path_buffer, sizeof(path_buffer), file_abs(i->dir_map[pathindex], filename));

	log_std(("osd: osd_get_path_info() try %s\n", path_buffer));

	if (stat(path_buffer, &st) != 0) {
		log_std(("osd: osd_get_path_info() -> failed\n"));
		return PATH_NOT_FOUND;
	}
	if (S_ISDIR(st.st_mode)) {
		log_std(("osd: osd_get_path_info() -> directory\n"));
		return PATH_IS_DIRECTORY;
	}
	if (S_ISREG(st.st_mode)) {
		log_std(("osd: osd_get_path_info() -> file\n"));
		return PATH_IS_FILE;
	}

	log_std(("osd: osd_get_path_info() -> failed\n"));
	return PATH_NOT_FOUND;
}
Пример #13
0
adv_error vgaline_mode_import(adv_mode* mode, const vgaline_video_mode* vgaline_mode)
{
	sncpy(mode->name, MODE_NAME_MAX, vgaline_mode->crtc.name);
	*DRIVER(mode) = *vgaline_mode;

	/* adjust the pixel clock to an acceptable value */
	DRIVER(mode)->crtc.pixelclock = vga_pixelclock_nearest_get(DRIVER(mode)->crtc.pixelclock, DRIVER(mode)->is_text);

	mode->driver = &video_vgaline_driver;
	mode->flags = MODE_FLAGS_RETRACE_WAIT_SYNC | MODE_FLAGS_RETRACE_SET_ASYNC
		| (mode->flags & MODE_FLAGS_USER_MASK);

	if (DRIVER(mode)->is_text) {
		mode->flags |= MODE_FLAGS_INDEX_TEXT;
	} else {
		mode->flags |= MODE_FLAGS_INDEX_PALETTE8;
		if (DRIVER(mode)->crtc.vde * DRIVER(mode)->crtc.hde > 0x10000)
			return -1;
	}

	mode->size_x = DRIVER(mode)->crtc.hde;
	mode->size_y = DRIVER(mode)->crtc.vde;
	mode->vclock = crtc_vclock_get(&DRIVER(mode)->crtc);
	mode->hclock = crtc_hclock_get(&DRIVER(mode)->crtc);
	mode->scan = crtc_scan_get(&DRIVER(mode)->crtc);

	return 0;
}
Пример #14
0
void advance_ui_osd(struct advance_ui_context* context, const char* text, int val, int def, int min, int max)
{
	context->state.ui_osd_flag = 1;
	context->state.ui_osd_value = val;
	context->state.ui_osd_def = val;
	context->state.ui_osd_min = min;
	context->state.ui_osd_max = max;
	sncpy(context->state.ui_osd_buffer, sizeof(context->state.ui_osd_buffer), text);
}
Пример #15
0
static adv_error cmd_mode_clock(void)
{
	adv_crtc* crtc;
	char buffer[80];
	double freq = 0;

	int i = menu_base + menu_rel;
	if (i >= menu_max)
		return 0;

	crtc = crtc_container_pos(&the_modes, i);

	sncpy(buffer, sizeof(buffer), "");
	switch (cmd_input_key(" Set Vertical/Horizontal/Pixel clock ? ", "vhp")) {
		case 0 :
			if (cmd_input_string(" Vertical clock [Hz] (example 60.0) : ", buffer, 10)!=0)
				return 0;
			freq = strtod(buffer, 0);
			if (freq < 10 || freq > 200) {
				error_set("Invalid vertical clock value, usually in the range 10 - 200.0 [Hz]");
				return -1;
			}
			crtc->pixelclock = freq * crtc->ht * crtc->vt;
			if (crtc_is_interlace(crtc))
				crtc->pixelclock /= 2;
			if (crtc_is_doublescan(crtc))
				crtc->pixelclock *= 2;
			break;
		case 1 :
			if (cmd_input_string(" Horizontal clock [kHz] (example 31.5) : ", buffer, 10)!=0)
				return 0;
			freq = strtod(buffer, 0) * 1E3;
			if (freq < 10*1E3 || freq > 100*1E3) {
				error_set("Invalid horizontal clock value, usually in the range 15.0 - 80.0 [kHz]");
				return -1;
			}
			crtc->pixelclock = freq * crtc->ht;
			break;
		case 2 :
			if (cmd_input_string(" Pixel clock [MHz] (example 14.0) : ", buffer, 10)!=0)
				return 0;
			freq = strtod(buffer, 0) * 1E6;
			if (freq < 1*1E6 || freq > 300*1E6) {
				error_set("Invalid pixel clock value, usually in the range 1.0 - 300.0 [MHz]");
				return -1;
			}
			crtc->pixelclock = freq;
			break;
		default: return 0;
	}

	menu_modify();

	return 0;
}
Пример #16
0
adv_error advance_ui_config_load(struct advance_ui_context* context, adv_conf* cfg_context, struct mame_option* option)
{
	const char* s;
	char* e;

	context->config.ui_speedmark_flag = conf_bool_get_default(cfg_context, "debug_speedmark");

	sncpy(context->config.help_image_buffer, sizeof(context->config.help_image_buffer), conf_string_get_default(cfg_context, "ui_helpimage"));
	sncpy(context->config.ui_font_buffer, sizeof(context->config.ui_font_buffer), conf_string_get_default(cfg_context, "ui_font"));

	context->config.ui_translucency = conf_float_get_default(cfg_context, "ui_translucency") * 255;
	if (context->config.ui_translucency > 255)
		context->config.ui_translucency = 255;

	s = conf_string_get_default(cfg_context, "ui_fontsize");

	context->config.ui_font_sizey = strtol(s, &e, 10);
	while (*e && isspace(*e))
		++e;
	if (*e) {
		context->config.ui_font_sizex = strtol(e, &e, 10);
	} else {
		context->config.ui_font_sizex = 0;
	}

	context->config.ui_font_orientation = option->direct_orientation;

	if (ui_color_load(context, cfg_context, UI_COLOR_INTERFACE_F, UI_COLOR_INTERFACE_B, "ui_color[interface]") != 0
		|| ui_color_load(context, cfg_context, UI_COLOR_TAG_F, UI_COLOR_TAG_B, "ui_color[tag]") != 0
		|| ui_color_load(context, cfg_context, UI_COLOR_SELECT_F, UI_COLOR_SELECT_B, "ui_color[select]") != 0
		|| ui_color_load(context, cfg_context, -1, UI_COLOR_HELP_P1, "ui_color[help_p1]") != 0
		|| ui_color_load(context, cfg_context, -1, UI_COLOR_HELP_P2, "ui_color[help_p2]") != 0
		|| ui_color_load(context, cfg_context, -1, UI_COLOR_HELP_P3, "ui_color[help_p3]") != 0
		|| ui_color_load(context, cfg_context, -1, UI_COLOR_HELP_P4, "ui_color[help_p4]") != 0
		|| ui_color_load(context, cfg_context, -1, UI_COLOR_HELP_OTHER, "ui_color[help_other]") != 0)
		return -1;

	return 0;
}
Пример #17
0
adv_error mouseb_raw_load(adv_conf* context)
{
	unsigned i;
	for (i = 0; i < RAW_MOUSE_MAX; ++i) {
		char buf[64];
		const char* s;

		snprintf(buf, sizeof(buf), "device_raw_mousetype[%d]", i);
		raw_state.map[i].context.type = conf_int_get_default(context, buf);

		snprintf(buf, sizeof(buf), "device_raw_mousedev[%d]", i);
		s = conf_string_get_default(context, buf);
		if (strcmp(s, "auto") == 0) {
			if (i == 0 && access("/dev/mouse", F_OK) == 0) {
				sncpy(raw_state.map[i].context.dev, sizeof(raw_state.map[i].context.dev), "/dev/mouse");
				if (raw_state.map[i].context.type < 0)
					raw_state.map[i].context.type = MOUSE_PNP;
			} else {
				snprintf(raw_state.map[i].context.dev, sizeof(raw_state.map[i].context.dev), "/dev/input/mouse%d", i);
				switch (raw_state.map[i].context.type) {
				case MOUSE_PS2:
				case MOUSE_IMPS2:
				case MOUSE_EXPPS2:
					/* the /dev/input/mouse interfaces is compatible only with these three protocols */
					break;
				default:
					raw_state.map[i].context.type = MOUSE_IMPS2;
					break;
				}
			}
		} else {
			sncpy(raw_state.map[i].context.dev, sizeof(raw_state.map[i].context.dev), s);
			if (raw_state.map[i].context.type < 0)
				raw_state.map[i].context.type = MOUSE_PNP;
		}
	}

	return 0;
}
Пример #18
0
void advance_ui_menu_title_insert(struct ui_menu* menu, const char* title)
{
	struct ui_menu_entry* entry = &menu->map[menu->mac];

	assert(menu->mac < menu->max);
	if (menu->mac == menu->max)
		return;

	entry->type = ui_menu_title;
	sncpy(entry->text_buffer, sizeof(entry->text_buffer), title);

	++menu->mac;
}
Пример #19
0
int osd_dir_get_entry(void* void_h, char* name, int namelength, int* is_dir)
{
	struct dirio_handle* h = (struct dirio_handle*)void_h;
	struct dirent* d;

	d = readdir(h->h);

	while (d) {
		char file_buffer[FILE_MAXPATH];
		struct stat st;

		snprintf(file_buffer, sizeof(file_buffer), "%s/%s", h->dir, d->d_name);

		/* on any error ignore the file */

		if (stat(file_buffer, &st) == 0) {
			if (S_ISDIR(st.st_mode)) {
				if (namelength >= strlen(d->d_name) + 1) {
					*is_dir = 1;
					sncpy(name, namelength, d->d_name);
					log_std(("osd: osd_dir_get_entry() -> %s\n", name));
					return strlen(name);
				}
			} else if (match(d->d_name, h->pattern)) {
				if (namelength >= strlen(d->d_name) + 1) {
					*is_dir = 0;
					sncpy(name, namelength, d->d_name);
					log_std(("osd: osd_dir_get_entry() -> %s\n", name));
					return strlen(name);
				}
			}
		}

		d = readdir(h->h);
	}

	return 0;
}
Пример #20
0
static adv_error sound_start(struct advance_record_context* context, const char* file, double frequency, int stereo)
{
	unsigned* f;

	if (context->state.sound_active_flag)
		return -1;

	/* adjust the frequency to match the MP3 standard */
	f = SOUND_FREQUENCY_MAP;
	while (*f) {
		double v = *f;
		v /= frequency;
		if (v > 1)
			v = 1 / v;
		v = 1 - v;
		if (v<SOUND_FREQUENCY_ERROR) {
			context->state.sound_frequency = *f;
			break;
		}
                 ++f;
	}
	if (!*f)
		context->state.sound_frequency = frequency;

	context->state.sound_stereo_flag = stereo;
	context->state.sound_sample_counter = 0;
	context->state.sound_sample_size = 2;
	if (stereo)
		context->state.sound_sample_size *= 2;
	context->state.sound_stopped_flag = 0;

	sncpy(context->state.sound_file_buffer, sizeof(context->state.sound_file_buffer), file);

	context->state.sound_f = fopen(context->state.sound_file_buffer, "wb");
	if (!context->state.sound_f) {
		log_std(("ERROR: opening file %s\n", context->state.sound_file_buffer));
		return -1;
	}

	if (wave_write(context->state.sound_f, context->state.sound_stereo_flag ? 2 : 1, 16, 0, context->state.sound_frequency) != 0) {
		log_std(("ERROR: writing file %s\n", context->state.sound_file_buffer));
		fclose(context->state.sound_f);
		remove(context->state.sound_file_buffer);
		return -1;
	}

	context->state.sound_active_flag = 1;

	return 0;
}
Пример #21
0
int joystickb_sdl_device_desc_get(unsigned joystick, char* desc)
{
#if SDL_MAJOR_VERSION == 1
	const char* joy_name = SDL_JoystickName(joystick);

	if (!joy_name)
		return -1;

	log_std(("joystickb:sdl: desc:\"%s\"\n", joy_name));

	sncpy(desc, DEVICE_NAME_MAX, joy_name);
#else
	const char* joy_name = SDL_JoystickName(sdl_state.map[joystick]);

	if (!joy_name)
		return -1;

	log_std(("joystickb:sdl: desc:\"%s\"\n", joy_name));

	sncpy(desc, DEVICE_NAME_MAX, joy_name);
#endif
	return 0;
}
Пример #22
0
/**
 * Check if a adv_device name match the user specification.
 * \param tag user specification.
 * \param drv adv_device to check.
 * \param allow_none if true allows the "none" driver also if it
 *   isn't specified. Otherwise the "none" driver is used only if explictly
 *   specified. It isn't used from "auto".
 */
const adv_device* device_match(const char* tag, const adv_driver* drv, adv_bool allow_none)
{
	char buffer[DEVICE_NAME_MAX];
	const char* tag_one;

	sncpy(buffer, sizeof(buffer), tag);
	tag_one = strtok(buffer, " \t");
	while (tag_one) {
		const adv_device* dev = device_match_one(tag_one, drv, allow_none);
		if (dev)
			return dev;
		tag_one = strtok(NULL, " \t");
	}

	return 0;
}
Пример #23
0
static void cmd_rename(void)
{
	adv_crtc* crtc;
	char buffer[128];

	crtc = menu_current();
	if (!crtc)
		return;

	sncpy(buffer, sizeof(buffer), "");
	if (cmd_input_string(" Name : ", buffer, MODE_NAME_MAX)!=0)
		return;

	crtc_name_set(crtc, buffer);

	menu_modify();
}
Пример #24
0
adv_error fb_mode_import(adv_mode* mode, const fb_video_mode* fb_mode)
{
	sncpy(mode->name, MODE_NAME_MAX, fb_mode->crtc.name);

	*DRIVER(mode) = *fb_mode;

	mode->driver = &video_fb_driver;
	mode->flags = MODE_FLAGS_RETRACE_WAIT_SYNC | MODE_FLAGS_RETRACE_SET_ASYNC
		| (mode->flags & MODE_FLAGS_USER_MASK)
		| fb_mode->index;
	mode->size_x = DRIVER(mode)->crtc.hde;
	mode->size_y = DRIVER(mode)->crtc.vde;
	mode->vclock = crtc_vclock_get(&DRIVER(mode)->crtc);
	mode->hclock = crtc_hclock_get(&DRIVER(mode)->crtc);
	mode->scan = crtc_scan_get(&DRIVER(mode)->crtc);

	return 0;
}
Пример #25
0
adv_error advance_fileio_config_load(struct advance_fileio_context* context, adv_conf* cfg_context, struct mame_option* option)
{
	struct fileio_item* i;
	for(i=FILEIO_CONFIG;i->type != FILETYPE_end;++i) {
		/* free a previously loaded value */
		path_free(i->dir_map, i->dir_mac);
		i->dir_map = 0;
		i->dir_mac = 0;

		if (i->config) {
			unsigned j;
			const char* s = conf_string_get_default(cfg_context, i->config);
			const char* a;

			switch (i->mode) {
			case FILEIO_MODE_MULTI : a = file_config_list(s, file_config_dir_multidir, 0); break;
			case FILEIO_MODE_SINGLE : a = file_config_list(s, file_config_dir_singledir, 0); break;
			default: a = s; break;
			}

			log_std(("advance:fileio: %s %s\n", i->config, a));
			path_allocate(&i->dir_map, &i->dir_mac, a);
			for(j=0;j<i->dir_mac;++j)
				dir_create(i->dir_map[j]);
		} else {
			/* add the standard directories search as default */
			path_allocate(&i->dir_map, &i->dir_mac, file_config_dir_singlefile());
		}
	}

#ifdef MESS
	{
		const char* s = conf_string_get_default(cfg_context, "dir_crc");
		const char* a = file_config_list(s, file_config_dir_singledir, 0);
		log_std(("advance:fileio: %s %s\n", "dir_crc", a));
		sncpy(option->crc_dir_buffer, sizeof(option->crc_dir_buffer), a);
	}
#endif

	return 0;
}
Пример #26
0
static const adv_device* device_match_one(const char* tag, const adv_driver* drv, adv_bool allow_none)
{
	char tag_driver[DEVICE_NAME_MAX];
	char* tag_device;
	const adv_device* i;

	sncpy(tag_driver, DEVICE_NAME_MAX, tag);
	tag_device = strchr(tag_driver, '/');
	if (tag_device) {
		*tag_device = 0;
		++tag_device;
	} else {
		tag_device = "auto";
	}

	if (strcmp(drv->name, "none")==0) {
		if (allow_none || strcmp(tag_driver, "none")==0) {
			assert(drv->device_map->name != 0);
			return drv->device_map;
		} else {
			return 0; /* "auto" never choose "none" */
		}
	}

	if (strcmp(tag_driver, "auto")!=0 && strcmp(tag_driver, drv->name)!=0)
		return 0;

	i = drv->device_map;
	while (i->name) {
		if (strcmp(i->name, tag_device)==0)
			break;
		++i;
	}

	if (!i->name)
		return 0;

	return i;
}
Пример #27
0
static adv_error none_mode_import(adv_mode* mode, const none_video_mode* none_mode)
{
	sncpy(mode->name, MODE_NAME_MAX, none_mode->crtc.name);

	*DRIVER(mode) = *none_mode;

	mode->driver = &video_none_driver;
	mode->flags = (mode->flags & MODE_FLAGS_USER_MASK)
		| none_mode->index;
	mode->size_x = DRIVER(mode)->crtc.hde;
	mode->size_y = DRIVER(mode)->crtc.vde;
	mode->vclock = crtc_vclock_get(&DRIVER(mode)->crtc);
	mode->hclock = crtc_hclock_get(&DRIVER(mode)->crtc);

	if (crtc_is_doublescan(&none_mode->crtc))
		mode->scan = 1;
	else if (crtc_is_interlace(&none_mode->crtc))
		mode->scan = -1;
	else
		mode->scan = 0;

	return 0;
}
Пример #28
0
int osd_create_directory(int pathtype, int pathindex, const char *dirname)
{
	struct fileio_item* i;
	char path_buffer[FILE_MAXPATH];

	log_std(("osd: osd_create_directory(pathtype:%d,pathindex:%d,dirname:%s)\n", pathtype, pathindex, dirname));

	i = fileio_find(pathtype);
	if (!i) {
		log_std(("WARNING:fileio: file type %d unknown\n", pathtype));
		return -1;
	}

	sncpy(path_buffer, sizeof(path_buffer), file_abs(i->dir_map[pathindex], dirname));

	log_std(("osd: osd_create_directory() -> %s\n", path_buffer));

	if (file_dir_make(path_buffer) != 0) {
		log_std(("ERROR:fileio: mkdir(%s) failed\n", path_buffer));
		return -1;
	}

	return 0;
}
Пример #29
0
void advance_ui_direct_text(struct advance_ui_context* context, const char* text)
{
	context->state.ui_direct_text_flag = 1;
	sncpy(context->state.ui_direct_buffer, sizeof(context->state.ui_direct_buffer), text);
}
Пример #30
0
int osd2_audio_menu(int selected, unsigned input)
{
	struct advance_video_context* video_context = &CONTEXT.video;
	struct advance_sound_context* sound_context = &CONTEXT.sound;
	struct advance_global_context* global_context = &CONTEXT.global;
	struct advance_ui_context* ui_context = &CONTEXT.ui;

	struct ui_menu menu;
	unsigned mac;
	int mode_index;
	int adjust_index;
	int volume_index;
	int normalize_index;
	int eql_index;
	int eqm_index;
	int eqh_index;
	int save_game_index;
	int pipeline_index;
	int exit_index;
	char buffer[128];
	const char* text = 0;
	const char* option = 0;

	/* the menu data is not duplicated for the thread, so we have to wait for its completion */
	advance_video_thread_wait(video_context);

	if (selected >= 1)
		selected = selected - 1;
	else
		selected = 0;

	if (sound_context->state.menu_sub_flag) {
		int ret = 0;
		switch (sound_context->state.menu_sub_flag) {
		case 1: ret = audio_pipeline_menu(sound_context, ui_context, sound_context->state.menu_sub_selected, input); break;
		}
		switch (ret) {
		case -1: return -1;  /* hide interface */
		case 0: sound_context->state.menu_sub_flag = 0; sound_context->state.menu_sub_selected = 1; break;  /* close submenu */
		default: sound_context->state.menu_sub_selected = ret; break;
		}
		return selected + 1;
	}

	advance_ui_menu_init(&menu);

	advance_ui_menu_title_insert(&menu, "Audio Menu");

	switch (sound_context->state.output_mode) {
	case SOUND_MODE_MONO: text = "Mode [mono]"; break;
	case SOUND_MODE_STEREO: text = "Mode [stereo]"; break;
	case SOUND_MODE_SURROUND: text = "Mode [surround]"; break;
	}
	switch (sound_context->config.mode) {
	case SOUND_MODE_AUTO: option = "auto"; break;
	case SOUND_MODE_MONO: option = "mono"; break;
	case SOUND_MODE_STEREO: option = "stereo"; break;
	case SOUND_MODE_SURROUND: option = "surround"; break;
	}
	mode_index = advance_ui_menu_option_insert(&menu, text, option);

	if (sound_context->config.attenuation > -40)
		snprintf(buffer, sizeof(buffer), "%d", sound_context->config.attenuation);
	else
		sncpy(buffer, sizeof(buffer), "mute");
	volume_index = advance_ui_menu_option_insert(&menu, "Attenuation (dB)", buffer);

	advance_ui_menu_title_insert(&menu, "Normalize");

	if (sound_context->config.normalize_flag)
		option = "yes";
	else
		option = "no";
	normalize_index = advance_ui_menu_option_insert(&menu, "Auto normalize", option);

	snprintf(buffer, sizeof(buffer), "%d", sound_context->config.adjust);
	adjust_index = advance_ui_menu_option_insert(&menu, "Amplifier (dB)", buffer);

	advance_ui_menu_title_insert(&menu, "Equalizer");

	if (sound_context->config.equalizer_low > -40)
		snprintf(buffer, sizeof(buffer), "%d", sound_context->config.equalizer_low);
	else
		sncpy(buffer, sizeof(buffer), "mute");
	eql_index = advance_ui_menu_option_insert(&menu, "Low Freq (dB)", buffer);

	if (sound_context->config.equalizer_mid > -40)
		snprintf(buffer, sizeof(buffer), "%d", sound_context->config.equalizer_mid);
	else
		sncpy(buffer, sizeof(buffer), "mute");
	eqm_index = advance_ui_menu_option_insert(&menu, "Mid Freq (dB)", buffer);

	if (sound_context->config.equalizer_high > -40)
		snprintf(buffer, sizeof(buffer), "%d", sound_context->config.equalizer_high);
	else
		sncpy(buffer, sizeof(buffer), "mute");
	eqh_index = advance_ui_menu_option_insert(&menu, "High Freq (dB)", buffer);

	pipeline_index = advance_ui_menu_text_insert(&menu, "Details...");

	if (global_context->state.is_config_writable) {
		save_game_index = advance_ui_menu_text_insert(&menu, "Save for this game");
	} else {
		save_game_index = -1;
	}

	exit_index = advance_ui_menu_text_insert(&menu, "Return to Main Menu");

	mac = advance_ui_menu_done(&menu, ui_context, selected);

	if (input == OSD_INPUT_DOWN) {
		selected = (selected + 1) % mac;
	}

	if (input == OSD_INPUT_UP) {
		selected = (selected + mac - 1) % mac;
	}

	if (input == OSD_INPUT_SELECT) {
		if (selected == exit_index) {
			selected = -1;
		} else if (selected == pipeline_index) {
			sound_context->state.menu_sub_flag = 1;
		} else if (selected == save_game_index) {
			advance_sound_config_save(sound_context, video_context->config.section_name_buffer);
		}
	}

	if (input == OSD_INPUT_RIGHT) {
		if (selected == volume_index) {
			struct advance_sound_config_context config = sound_context->config;
			config.attenuation = sound_context->config.attenuation + 1;
			advance_sound_reconfigure(sound_context, &config);
		} else if (selected == adjust_index) {
			struct advance_sound_config_context config = sound_context->config;
			config.adjust = sound_context->config.adjust + 1;
			advance_sound_reconfigure(sound_context, &config);
		} else if (selected == normalize_index) {
			struct advance_sound_config_context config = sound_context->config;
			config.normalize_flag = !sound_context->config.normalize_flag;
			advance_sound_reconfigure(sound_context, &config);
		} else if (selected == mode_index) {
			struct advance_sound_config_context config = sound_context->config;
			switch (config.mode) {
			case SOUND_MODE_AUTO: config.mode = SOUND_MODE_MONO; break;
			case SOUND_MODE_MONO: config.mode = SOUND_MODE_STEREO; break;
			case SOUND_MODE_STEREO: config.mode = SOUND_MODE_SURROUND; break;
			case SOUND_MODE_SURROUND: config.mode = SOUND_MODE_AUTO; break;
			}
			advance_sound_reconfigure(sound_context, &config);
		} else if (selected == eql_index) {
			struct advance_sound_config_context config = sound_context->config;
			config.equalizer_low = sound_context->config.equalizer_low + 2;
			advance_sound_reconfigure(sound_context, &config);
		} else if (selected == eqm_index) {
			struct advance_sound_config_context config = sound_context->config;
			config.equalizer_mid = sound_context->config.equalizer_mid + 2;
			advance_sound_reconfigure(sound_context, &config);
		} else if (selected == eqh_index) {
			struct advance_sound_config_context config = sound_context->config;
			config.equalizer_high = sound_context->config.equalizer_high + 2;
			advance_sound_reconfigure(sound_context, &config);
		}
	}

	if (input == OSD_INPUT_LEFT) {
		if (selected == volume_index) {
			struct advance_sound_config_context config = sound_context->config;
			config.attenuation = sound_context->config.attenuation - 1;
			advance_sound_reconfigure(sound_context, &config);
		} else if (selected == adjust_index) {
			struct advance_sound_config_context config = sound_context->config;
			config.adjust = sound_context->config.adjust - 1;
			advance_sound_reconfigure(sound_context, &config);
		} else if (selected == normalize_index) {
			struct advance_sound_config_context config = sound_context->config;
			config.normalize_flag = !sound_context->config.normalize_flag;
			advance_sound_reconfigure(sound_context, &config);
		} else if (selected == mode_index) {
			struct advance_sound_config_context config = sound_context->config;
			switch (config.mode) {
			case SOUND_MODE_AUTO: config.mode = SOUND_MODE_SURROUND; break;
			case SOUND_MODE_MONO: config.mode = SOUND_MODE_AUTO; break;
			case SOUND_MODE_STEREO: config.mode = SOUND_MODE_MONO; break;
			case SOUND_MODE_SURROUND: config.mode = SOUND_MODE_STEREO; break;
			}
			advance_sound_reconfigure(sound_context, &config);
		} else if (selected == eql_index) {
			struct advance_sound_config_context config = sound_context->config;
			config.equalizer_low = sound_context->config.equalizer_low - 2;
			advance_sound_reconfigure(sound_context, &config);
		} else if (selected == eqm_index) {
			struct advance_sound_config_context config = sound_context->config;
			config.equalizer_mid = sound_context->config.equalizer_mid - 2;
			advance_sound_reconfigure(sound_context, &config);
		} else if (selected == eqh_index) {
			struct advance_sound_config_context config = sound_context->config;
			config.equalizer_high = sound_context->config.equalizer_high - 2;
			advance_sound_reconfigure(sound_context, &config);
		}
	}

	if (input == OSD_INPUT_CANCEL)
		selected = -1;

	if (input == OSD_INPUT_CONFIGURE)
		selected = -2;

	return selected + 1;
}