Esempio n. 1
0
int config_load_settings(running_machine *machine)
{
	const char *controller = options_get_string(mame_options(), OPTION_CTRLR);
	file_error filerr;
	config_type *type;
	mame_file *file;
	int loaded = 0;
	astring *fname;

	/* loop over all registrants and call their init function */
	for (type = typelist; type; type = type->next)
		(*type->load)(CONFIG_TYPE_INIT, NULL);

	/* now load the controller file */
	if (controller[0] != 0)
	{
		/* open the config file */
		fname = astring_assemble_2(astring_alloc(), controller, ".cfg");
		filerr = mame_fopen(SEARCHPATH_CTRLR, astring_c(fname), OPEN_FLAG_READ, &file);
		astring_free(fname);

		if (filerr != FILERR_NONE)
			fatalerror("Could not load controller file %s.cfg", controller);

		/* load the XML */
		if (!config_load_xml(machine, file, CONFIG_TYPE_CONTROLLER))
			fatalerror("Could not load controller file %s.cfg", controller);
		mame_fclose(file);
	}

	/* next load the defaults file */
	filerr = mame_fopen(SEARCHPATH_CONFIG, "default.cfg", OPEN_FLAG_READ, &file);
	if (filerr == FILERR_NONE)
	{
		config_load_xml(machine, file, CONFIG_TYPE_DEFAULT);
		mame_fclose(file);
	}

	/* finally, load the game-specific file */
	fname = astring_assemble_2(astring_alloc(), machine->basename, ".cfg");
	filerr = mame_fopen(SEARCHPATH_CONFIG, astring_c(fname), OPEN_FLAG_READ, &file);
	astring_free(fname);

	if (filerr == FILERR_NONE)
	{
		loaded = config_load_xml(machine, file, CONFIG_TYPE_GAME);
		mame_fclose(file);
	}

	/* loop over all registrants and call their final function */
	for (type = typelist; type; type = type->next)
		(*type->load)(CONFIG_TYPE_FINAL, NULL);

	/* if we didn't find a saved config, return 0 so the main core knows that it */
	/* is the first time the game is run and it should diplay the disclaimer. */
	return loaded;
}
Esempio n. 2
0
void config_save_settings(running_machine *machine)
{
	file_error filerr;
	config_type *type;
	mame_file *file;
	astring *fname;

	/* loop over all registrants and call their init function */
	for (type = typelist; type; type = type->next)
		(*type->save)(CONFIG_TYPE_INIT, NULL);

	/* save the defaults file */
	filerr = mame_fopen(SEARCHPATH_CONFIG, "default.cfg", OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
	if (filerr == FILERR_NONE)
	{
		config_save_xml(machine, file, CONFIG_TYPE_DEFAULT);
		mame_fclose(file);
	}

	/* finally, save the game-specific file */
	fname = astring_assemble_2(astring_alloc(), machine->basename, ".cfg");
	filerr = mame_fopen(SEARCHPATH_CONFIG, astring_c(fname), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
	astring_free(fname);

	if (filerr == FILERR_NONE)
	{
		config_save_xml(machine, file, CONFIG_TYPE_GAME);
		mame_fclose(file);
	}

	/* loop over all registrants and call their final function */
	for (type = typelist; type; type = type->next)
		(*type->save)(CONFIG_TYPE_FINAL, NULL);
}
Esempio n. 3
0
mame_file *nvram_fopen(running_machine *machine, UINT32 openflags)
{
	file_error filerr;
	mame_file *file;
	astring *fname;

	fname = astring_assemble_2(astring_alloc(), machine->basename, ".nv");
	filerr = mame_fopen(SEARCHPATH_NVRAM, astring_c(fname), openflags, &file);
	astring_free(fname);

	return (filerr == FILERR_NONE) ? file : NULL;
}
Esempio n. 4
0
BOOL LoadDIB(const char *filename, HGLOBAL *phDIB, HPALETTE *pPal, int pic_type)
{
	file_error filerr;
	core_file *file = NULL;
	BOOL success = FALSE;
	const char *dir_name;
	const char *zip_name;
	astring *fname;
	void *buffer = NULL;
	if (pPal != NULL ) {
		DeletePalette(pPal);
	}

	switch (pic_type)
	{
		case TAB_SCREENSHOT:
			dir_name = GetImgDir();
			zip_name = "snap";
			break;
		case TAB_FLYER:
			dir_name = GetFlyerDir();
			zip_name = "flyers";
			break;
		case TAB_CABINET:
			dir_name = GetCabinetDir();
			zip_name = "cabinets";
			break;
		case TAB_MARQUEE:
			dir_name = GetMarqueeDir();
			zip_name = "marquees";
			break;
		case TAB_TITLE:
			dir_name = GetTitlesDir();
			zip_name = "titles";
			break;
		case TAB_CONTROL_PANEL:
			dir_name = GetControlPanelDir();
			zip_name = "cpanel";
			break;
        case TAB_PCB :
			dir_name = GetPcbDir();
		    zip_name = "pcb";
			break;
		case BACKGROUND:
			dir_name = GetBgDir();
			zip_name = "bkground";
			break;
		default :
			// in case a non-image tab gets here, which can happen
			return FALSE;
	}
	//Add handling for the displaying of all the different supported snapshot patterntypes
	//%g
	fname = astring_assemble_2(astring_alloc(), filename, ".png");
	filerr = OpenDIBFile(dir_name, zip_name, astring_c(fname), &file, &buffer);
	astring_free(fname);
	if (filerr != FILERR_NONE) {
		//%g/%i
		fname = astring_assemble_3(astring_alloc(), filename, PATH_SEPARATOR, "0000.png");
		filerr = OpenDIBFile(dir_name, zip_name, astring_c(fname), &file, &buffer);
		astring_free(fname);
	}
	if (filerr != FILERR_NONE) {
		//%g%i
		fname = astring_assemble_2(astring_alloc(), filename, "0000.png");
		filerr = OpenDIBFile(dir_name, zip_name, astring_c(fname), &file, &buffer);
		astring_free(fname);
	}
	if (filerr != FILERR_NONE) {
		//%g/%g
		fname = astring_assemble_4(astring_alloc(), filename, PATH_SEPARATOR, filename, ".png");
		filerr = OpenDIBFile(dir_name, zip_name, astring_c(fname), &file, &buffer);
		astring_free(fname);
	}
	if (filerr != FILERR_NONE) {
		//%g/%g%i
		fname = astring_assemble_4(astring_alloc(), filename, PATH_SEPARATOR, filename, "0000.png");
		filerr = OpenDIBFile(dir_name, zip_name, astring_c(fname), &file, &buffer);
		astring_free(fname);
	}

	if (filerr == FILERR_NONE) {
		success = png_read_bitmap_gui(file, phDIB, pPal);
		core_fclose(file);
	}

	// free the buffer if we have to
	if (buffer != NULL) {
		free(buffer);
	}
	return success;
}