Example #1
0
static int a78_get_pcb_id(const char *slot)
{
	for (auto & elem : slot_list)
	{
		if (!core_stricmp(elem.slot_option, slot))
			return elem.pcb_id;
	}

	return 0;
}
Example #2
0
static int a800_get_pcb_id(const char *slot)
{
	for (int i = 0; i < ARRAY_LENGTH(slot_list); i++)
	{
		if (!core_stricmp(slot_list[i].slot_option, slot))
			return slot_list[i].pcb_id;
	}

	return 0;
}
Example #3
0
static const zip_file_header *find_file(zip_file *zip, const char *filename)
{
	const zip_file_header *header;
	for (header = zip_file_first_file(zip); header != NULL; header = zip_file_next_file(zip))
	{
		if (!core_stricmp(header->filename, filename))
			return header;
	}
	return NULL;
}
Example #4
0
void inifile_manager::load_ini_category(std::vector<int> &temp_filter)
{
	if (ini_index.empty())
		return;

	bool search_clones = false;
	std::string filename(ini_index[current_file].name);
	long offset = ini_index[current_file].category[current_category].offset;

	if (!core_stricmp(filename.c_str(), "category.ini") || !core_stricmp(filename.c_str(), "alltime.ini"))
		search_clones = true;

	if (parseopen(filename.c_str()))
	{
		fseek(fp, offset, SEEK_SET);
		int num_game = driver_list::total();
		char rbuf[MAX_CHAR_INFO];
		std::string readbuf;
		while (fgets(rbuf, MAX_CHAR_INFO, fp) != nullptr)
		{
			readbuf = chartrimcarriage(rbuf);

			if (readbuf.empty() || readbuf[0] == '[')
				break;

			int dfind = driver_list::find(readbuf.c_str());
			if (dfind != -1 && search_clones)
			{
				temp_filter.push_back(dfind);
				int clone_of = driver_list::non_bios_clone(dfind);
				if (clone_of == -1)
				{
					for (int x = 0; x < num_game; x++)
						if (readbuf == driver_list::driver(x).parent && readbuf != driver_list::driver(x).name)
							temp_filter.push_back(x);
				}
			}
			else if (dfind != -1)
				temp_filter.push_back(dfind);
		}
		parseclose();
	}
}
Example #5
0
int CLIB_DECL main(int argc, char *argv[])
{
	init_formats();

	if (argc == 1) {
		display_full_usage();
		return 0;
	}

	if (!core_stricmp("identify", argv[1]))
		return identify(argc, argv);
	else if (!core_stricmp("convert", argv[1]))
		return convert(argc, argv);
	else {
		fprintf(stderr, "Unknown command '%s'\n\n", argv[1]);
		display_usage();
		return 1;
	}
}
Example #6
0
machine_config::machine_config(const game_driver &gamedrv, emu_options &options)
	: m_minimum_quantum(attotime::zero),
		m_default_layout(nullptr),
		m_gamedrv(gamedrv),
		m_options(options)
{
	// construct the config
	(*gamedrv.machine_config)(*this, nullptr, nullptr);

	bool is_selected_driver = core_stricmp(gamedrv.name,options.system_name())==0;
	// intialize slot devices - make sure that any required devices have been allocated

	for (device_slot_interface &slot : slot_interface_iterator(root_device()))
	{
		device_t &owner = slot.device();
		std::string selval;
		bool isdefault = (options.priority(owner.tag()+1)==OPTION_PRIORITY_DEFAULT);
		if (is_selected_driver && options.exists(owner.tag()+1))
			selval = options.main_value(owner.tag()+1);
		else if (slot.default_option() != nullptr)
			selval.assign(slot.default_option());

		if (!selval.empty())
		{
			const device_slot_option *option = slot.option(selval.c_str());

			if (option && (isdefault || option->selectable()))
			{
				device_t *new_dev = device_add(&owner, option->name(), option->devtype(), option->clock());

				const char *default_bios = option->default_bios();
				if (default_bios != nullptr)
					device_t::static_set_default_bios_tag(*new_dev, default_bios);

				machine_config_constructor additions = option->machine_config();
				if (additions != nullptr)
					(*additions)(const_cast<machine_config &>(*this), new_dev, new_dev);

				const input_device_default *input_device_defaults = option->input_device_defaults();
				if (input_device_defaults)
					device_t::static_set_input_default(*new_dev, input_device_defaults);
			}
			else
				throw emu_fatalerror("Unknown slot option '%s' in slot '%s'", selval.c_str(), owner.tag()+1);
		}
	}

	// when finished, set the game driver
	driver_device::static_set_game(*m_root_device, gamedrv);

	// then notify all devices that their configuration is complete
	for (device_t &device : device_iterator(root_device()))
		if (!device.configured())
			device.config_complete();
}
Example #7
0
void favorite_manager::update_sorted()
{
	if (m_need_sort)
	{
		if (m_sorted.empty())
			std::copy(m_favorites.begin(), m_favorites.end(), std::back_inserter(m_sorted));

		assert(m_favorites.size() == m_sorted.size());
		std::stable_sort(
				m_sorted.begin(),
				m_sorted.end(),
				[] (ui_software_info const &lhs, ui_software_info const &rhs) -> bool
				{
					assert(lhs.driver);
					assert(rhs.driver);

					int cmp;

					cmp = core_stricmp(lhs.longname.c_str(), rhs.longname.c_str());
					if (0 > cmp)
						return true;
					else if (0 < cmp)
						return false;

					cmp = core_stricmp(lhs.driver->type.fullname(), rhs.driver->type.fullname());
					if (0 > cmp)
						return true;
					else if (0 < cmp)
						return false;

					cmp = std::strcmp(lhs.listname.c_str(), rhs.listname.c_str());
					if (0 > cmp)
						return true;
					else if (0 < cmp)
						return false;

					return false;
				});

		m_need_sort = false;
	}
}
Example #8
0
imgtool_stream *stream_open(const char *fname, int read_or_write)
{
	static const UINT32 write_modes[] =
	{
		OPEN_FLAG_READ,
		OPEN_FLAG_WRITE | OPEN_FLAG_CREATE,
		OPEN_FLAG_READ | OPEN_FLAG_WRITE,
		OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE
	};
	imgtool_stream *s = nullptr;
	char c;

	/* maybe we are just a ZIP? */
	const char *ext = strrchr(fname, '.');
	if (ext && !core_stricmp(ext, ".zip"))
		return stream_open_zip(fname, nullptr, read_or_write);

	util::core_file::ptr f = nullptr;
	auto const filerr = util::core_file::open(fname, write_modes[read_or_write], f);
	if (filerr != osd_file::error::NONE)
	{
		if (!read_or_write)
		{
			int const len = strlen(fname);

			/* can't open the file; try opening ZIP files with other names */
			std::vector<char> buf(len + 1);
			strcpy(&buf[0], fname);

			for (int i = len-1; !s && (i >= 0); i--)
			{
				if ((buf[i] == '\\') || (buf[i] == '/'))
				{
					c = buf[i];
					buf[i] = '\0';
					s = stream_open_zip(&buf[0], &buf[i + 1], read_or_write);
					buf[i] = c;
				}
			}

			if (s)
				return s;
		}

		/* ah well, it was worth a shot */
		return nullptr;
	}

	imgtool_stream::ptr imgfile(new imgtool_stream(read_or_write ? false : true, std::move(f)));

	/* Normal file */
	imgfile->name = fname;
	return imgfile.release();
}
Example #9
0
UINT16 a7800_state::a7800_get_pcb_id(const char *pcb)
{
	int i;

	for (i = 0; i < ARRAY_LENGTH(pcb_list); i++)
	{
		if (!core_stricmp(pcb_list[i].pcb_name, pcb))
			return pcb_list[i].type;
	}

	return 0;
}
Example #10
0
std::string vic10_expansion_slot_device::get_default_card_software()
{
	if (open_image_file(mconfig().options()))
	{
		if (!core_stricmp(filetype(), "crt"))
			return cbm_crt_get_card(m_file);

		clear();
	}

	return software_get_default_slot("standard");
}
Example #11
0
int SoftwareList_LookupIndex(HWND hwndPicker, LPCSTR pszFilename)
{
	software_list_info *pPickerInfo;
	int i;

	pPickerInfo = GetSoftwareListInfo(hwndPicker);
	for (i = 0; i < pPickerInfo->file_index_length; i++)
	{
		if (core_stricmp(pPickerInfo->file_index[i]->file_name, pszFilename)==0)
			return i;
	}
	return -1;
}
Example #12
0
int core_strwildcmp(const char *sp1, const char *sp2)
{
	char s1[17], s2[17];
	size_t i, l1, l2;
	char *p;

	//assert(strlen(sp1) < 16);
	//assert(strlen(sp2) < 16);

	if (sp1[0] == 0) strcpy(s1, "*");
	else { strncpy(s1, sp1, 16); s1[16] = 0; }

	if (sp2[0] == 0) strcpy(s2, "*");
	else { strncpy(s2, sp2, 16); s2[16] = 0; }

	p = strchr(s1, '*');
	if (p)
	{
		for (i = p - s1; i < 16; i++) s1[i] = '?';
		s1[16] = 0;
	}

	p = strchr(s2, '*');
	if (p)
	{
		for (i = p - s2; i < 16; i++) s2[i] = '?';
		s2[16] = 0;
	}

	l1 = strlen(s1);
	if (l1 < 16)
	{
		for (i = l1 + 1; i < 16; i++) s1[i] = ' ';
		s1[16] = 0;
	}

	l2 = strlen(s2);
	if (l2 < 16)
	{
		for (i = l2 + 1; i < 16; i++) s2[i] = ' ';
		s2[16] = 0;
	}

	for (i = 0; i < 16; i++)
	{
		if (s1[i] == '?' && s2[i] != '?') s1[i] = s2[i];
		if (s2[i] == '?' && s1[i] != '?') s2[i] = s1[i];
	}

	return core_stricmp(s1, s2);
}
Example #13
0
int library::module_compare(const imgtool_module *m1, const imgtool_module *m2, sort_type sort)
{
	int rc = 0;
	switch(sort)
	{
	case sort_type::NAME:
		rc = strcmp(m1->name, m2->name);
		break;
	case sort_type::DESCRIPTION:
		rc = core_stricmp(m1->description, m2->description);
		break;
	}
	return rc;
}
Example #14
0
int menu_software_list::compare_entries(const entry_info &e1, const entry_info &e2, bool shortname)
{
	int result;
	const char *e1_basename = shortname ? e1.short_name.c_str() : e1.long_name.c_str();
	const char *e2_basename = shortname ? e2.short_name.c_str() : e2.long_name.c_str();

	result = core_stricmp(e1_basename, e2_basename);
	if (result == 0)
	{
		result = strcmp(e1_basename, e2_basename);
	}

	return result;
}
Example #15
0
static int vmsx_gm2_image_readfile(imgtool_image *img, const char *fname, imgtool_stream *destf)
	{
	GM2_IMAGE *image=(GM2_IMAGE*)img;

	if (core_stricmp (fname, NewName) )
		return IMGTOOLERR_MODULENOTFOUND;

	if (stream_write(destf, image->data + 0x1000, 0x1000)!=0x1000)
			return IMGTOOLERR_WRITEERROR;

	if (stream_write(destf, image->data + 0x3000, 0x1000)!=0x1000)
			return IMGTOOLERR_WRITEERROR;

	return 0;
	}
Example #16
0
File: exp.cpp Project: stengun/mame
void c64_expansion_slot_device::get_default_card_software(std::string &result)
{
	if (open_image_file(mconfig().options()))
	{
		if (!core_stricmp(filetype(), "crt"))
		{
			cbm_crt_get_card(result, m_file);
			return;
		}

		clear();
	}

	software_get_default_slot(result, "standard");
}
Example #17
0
bool cbm2_expansion_slot_device::call_load()
{
	size_t size = 0;

	if (m_card)
	{
		if (software_entry() == NULL)
		{
			size = length();

			if (!core_stricmp(filetype(), "20"))
			{
				m_card->m_bank1.allocate(size);
				fread(m_card->m_bank1, size);
			}
			else if (!core_stricmp(filetype(), "40"))
			{
				m_card->m_bank2.allocate(size);
				fread(m_card->m_bank2, size);
			}
			else if (!core_stricmp(filetype(), "60"))
			{
				m_card->m_bank3.allocate(size);
				fread(m_card->m_bank3, size);
			}
		}
		else
		{
			load_software_region("bank1", m_card->m_bank1);
			load_software_region("bank2", m_card->m_bank2);
			load_software_region("bank3", m_card->m_bank3);
		}
	}

	return IMAGE_INIT_PASS;
}
Example #18
0
static int module_compare(const imgtool_module *m1,
	const imgtool_module *m2, imgtool_libsort_t sort)
{
	int rc = 0;
	switch(sort)
	{
		case ITLS_NAME:
			rc = strcmp(m1->name, m2->name);
			break;
		case ITLS_DESCRIPTION:
			rc = core_stricmp(m1->name, m2->name);
			break;
	}
	return rc;
}
Example #19
0
int core_strwildcmp(const char *sp1, const char *sp2)
{
	char s1[9], s2[9];
	int i, l1, l2;
	char *p;

	strncpy(s1, sp1, 8); s1[8] = 0; if (s1[0] == 0) strcpy(s1, "*");

	strncpy(s2, sp2, 8); s2[8] = 0; if (s2[0] == 0) strcpy(s2, "*");

	p = strchr(s1, '*');
	if (p)
	{
		for (i = p - s1; i < 8; i++) s1[i] = '?';
		s1[8] = 0;
	}

	p = strchr(s2, '*');
	if (p)
	{
		for (i = p - s2; i < 8; i++) s2[i] = '?';
		s2[8] = 0;
	}

	l1 = (int)strlen(s1);
	if (l1 < 8)
	{
		for (i = l1 + 1; i < 8; i++) s1[i] = ' ';
		s1[8] = 0;
	}

	l2 = (int)strlen(s2);
	if (l2 < 8)
	{
		for (i = l2 + 1; i < 8; i++) s2[i] = ' ';
		s2[8] = 0;
	}

	for (i = 0; i < 8; i++)
	{
		if (s1[i] == '?' && s2[i] != '?') s1[i] = s2[i];
		if (s2[i] == '?' && s1[i] != '?') s2[i] = s1[i];
	}

	return core_stricmp(s1, s2);
}
Example #20
0
static const zip_file_header *find_file_crc(zip_file *zip, const char *filename, UINT32 crc)
{
	const zip_file_header *header;
	for (header = zip_file_first_file(zip); header != NULL; header = zip_file_next_file(zip))
	{
		// if the CRC and name both match, we're good
		// if the CRC matches and the name doesn't, we're still good
		if ((!core_stricmp(header->filename, filename)) && (header->crc == crc))
		{
			return header;
		}
		else if (header->crc == crc)
		{
			return header;
		}
	}
	return NULL;
}
Example #21
0
bool device_image_interface::uses_file_extension(const char *file_extension) const
{
	bool result = false;

	if (file_extension[0] == '.')
		file_extension++;

	/* find the extensions */
	std::string extensions(file_extensions());
	char *ext = strtok((char*)extensions.c_str(),",");
	while (ext != nullptr)
	{
		if (!core_stricmp(ext, file_extension))
		{
			result = true;
			break;
		}
		ext = strtok (nullptr, ",");
	}
	return result;
}
Example #22
0
bool device_image_interface::uses_file_extension(const char *file_extension) const
{
	bool result = FALSE;

	if (file_extension[0] == '.')
		file_extension++;

	/* find the extensions */
	astring extensions(file_extensions());
	char *ext = strtok((char*)extensions.cstr(),",");
	while (ext != NULL)
	{
		if (!core_stricmp(ext, file_extension))
		{
			result = TRUE;
			break;
		}
		ext = strtok (NULL, ",");
	}
	return result;
}
Example #23
0
bool vic20_expansion_slot_device::call_load()
{
	if (m_card)
	{
		if (software_entry() == NULL)
		{
			if (!core_stricmp(filetype(), "20")) fread(m_card->m_blk1, 0x2000);
			else if (!core_stricmp(filetype(), "40")) fread(m_card->m_blk2, 0x2000);
			else if (!core_stricmp(filetype(), "60")) fread(m_card->m_blk3, 0x2000);
			else if (!core_stricmp(filetype(), "70")) fread(m_card->m_blk3, 0x2000, 0x1000);
			else if (!core_stricmp(filetype(), "a0")) fread(m_card->m_blk5, 0x2000);
			else if (!core_stricmp(filetype(), "b0")) fread(m_card->m_blk5, 0x2000, 0x1000);
			else if (!core_stricmp(filetype(), "crt"))
			{
				// read the header
				UINT8 header[2];
				fread(&header, 2);
				UINT16 address = (header[1] << 8) | header[0];

				switch (address)
				{
				case 0x2000: fread(m_card->m_blk1, 0x2000); break;
				case 0x4000: fread(m_card->m_blk2, 0x2000); break;
				case 0x6000: fread(m_card->m_blk3, 0x2000); break;
				case 0x7000: fread(m_card->m_blk3, 0x2000, 0x1000); break;
				case 0xa000: fread(m_card->m_blk5, 0x2000); break;
				case 0xb000: fread(m_card->m_blk5, 0x2000, 0x1000); break;
				default: return IMAGE_INIT_FAIL;
				}
			}
		}
		else
		{
			load_software_region("blk1", m_card->m_blk1);
			load_software_region("blk2", m_card->m_blk2);
			load_software_region("blk3", m_card->m_blk3);
			load_software_region("blk5", m_card->m_blk5);
		}
	}

	return IMAGE_INIT_PASS;
}
Example #24
0
const software_info *software_list_device::find(const std::string &look_for)
{
	// empty search returns nothing
	if (look_for.empty())
		return nullptr;

	const bool iswild = look_for.find_first_of("*?") != std::string::npos;

	// find a match (will cause a parse if needed when calling get_info)
	const auto &info_list = get_info();
	auto iter = std::find_if(
			info_list.begin(),
			info_list.end(),
			[&look_for, iswild] (const software_info &info)
			{
				const char *shortname = info.shortname().c_str();
				return (iswild && core_strwildcmp(look_for.c_str(), shortname) == 0)
						|| core_stricmp(look_for.c_str(), shortname) == 0;
			});

	return iter != info_list.end() ? &*iter : nullptr;
}
Example #25
0
const imgtool_module *imgtool_library_unlink(imgtool_library *library,
	const char *module)
{
	imgtool_module *m;
	imgtool_module **previous;
	imgtool_module **next;

	for (m = library->first; m; m = m->next)
	{
		if (!core_stricmp(m->name, module))
		{
			previous = m->previous ? &m->previous->next : &library->first;
			next = m->next ? &m->next->previous : &library->last;
			*previous = m->next;
			*next = m->previous;
			m->previous = nullptr;
			m->next = nullptr;
			return m;
		}
	}
	return nullptr;
}
Example #26
0
void esq5505_state::machine_reset()
{
	floppy_connector *con = machine().device<floppy_connector>("wd1772:0");
	floppy_image_device *floppy = con ? con->get_device() : 0;

	m_rom = (UINT16 *)(void *)memregion("osrom")->base();
	m_ram = (UINT16 *)(void *)memshare("osram")->ptr();

	// Default analog values:
	m_analog_values[0] = 0x7fff; // pitch mod: start in the center
	m_analog_values[1] = 0x0000; // patch select: nothing pressed.
	m_analog_values[2] = 0x0000; // mod wheel: at the bottom, no modulation
	m_analog_values[3] = 0xcccc; // data entry: somewhere in the middle
	m_analog_values[4] = 0xffff; // control voltage / pedal: full on.
	m_analog_values[5] = 0xffff; // Volume control: full on.
	m_analog_values[6] = 0x7fc0; // Battery voltage: something reasonable.
	m_analog_values[7] = 0x5540; // vRef to check battery.

	// on VFX, bit 0 is 1 for 'cartridge present'.
	// on VFX-SD and later, bit 0 is 1 for floppy present, bit 1 is 1 for cartridge present
	if (core_stricmp(machine().system().name, "vfx") == 0)
	{
		// todo: handle VFX cart-in when we support cartridges
		m_duart->ip0_w(ASSERT_LINE);
	}
	else
	{
		m_duart->ip1_w(CLEAR_LINE);

		if (floppy)
		{
			m_duart->ip0_w(ASSERT_LINE);
		}
		else
		{
			m_duart->ip0_w(CLEAR_LINE);
		}
	}
}
Example #27
0
/* search the index for a directory entry */
static imgtoolerr_t vzdos_searchentry(imgtool_image *image, const char *fname, int *entry) {
	int i, len, ret;
	vzdos_dirent ent;
	char filename[9];

	/* check for invalid filenames */
	if (strlen(fname) > 8)
		return IMGTOOLERR_BADFILENAME;

	/* TODO: check for invalid characters */

	*entry = -1;

	for (i = 0; i < MAX_DIRENTS; i++) {

		ret = vzdos_get_dirent(image, i, &ent);
		if (ret) return (imgtoolerr_t)ret;

		len = vzdos_get_fname_len(ent.fname) + 1;

		if (strlen(fname) != len)
			continue;

		memset(filename, 0x00, sizeof(filename));
		memcpy(filename, ent.fname, len);

		if (!core_stricmp(fname, filename)) {
			*entry = i;
			break;
		}

	}

	if (*entry == -1)
		return IMGTOOLERR_FILENOTFOUND;

	return IMGTOOLERR_SUCCESS;
}
Example #28
0
int TabView_GetCurrentTab(HWND hwndTabView)
{
	struct TabViewInfo *pTabViewInfo;
	LPCSTR pszTab = NULL;
	LPCSTR pszThatTab;
	int i, nTab = -1;

	pTabViewInfo = GetTabViewInfo(hwndTabView);

	if (pTabViewInfo->pCallbacks->pfnGetCurrentTab)
		pszTab = pTabViewInfo->pCallbacks->pfnGetCurrentTab();

	if (pszTab)
	{
		if (pTabViewInfo->pCallbacks->pfnGetTabShortName)
		{
			for (i = 0; i < pTabViewInfo->nTabCount; i++)
			{
				pszThatTab = pTabViewInfo->pCallbacks->pfnGetTabShortName(i);
				if (pszThatTab && !core_stricmp(pszTab, pszThatTab))
				{
					nTab = i;
					break;
				}
			}
		}
		if (nTab < 0)
		{
			nTab = 0;
			sscanf(pszTab, "%d", &nTab);
		}
	}
	else
	{
		nTab = 0;
	}
	return nTab;
}
Example #29
0
const software_info *software_list_device::find(const char *look_for)
{
	// nullptr search returns nothing
	if (look_for == nullptr)
		return nullptr;

	bool iswild = strchr(look_for, '*') != nullptr || strchr(look_for, '?');

	// find a match (will cause a parse if needed when calling get_info)
	const auto &info_list = get_info();
	auto iter = std::find_if(
		info_list.begin(),
		info_list.end(),
		[&](const software_info &info)
	{
		const char *shortname = info.shortname().c_str();
		return (iswild && core_strwildcmp(look_for, shortname) == 0)
			|| core_stricmp(look_for, shortname) == 0;
	});

	return iter != info_list.end()
		? &*iter
		: nullptr;
}
Example #30
0
int TabView_GetCurrentTab(HWND hWndTabView)
{
    struct TabViewInfo *pTabViewInfo = GetTabViewInfo(hWndTabView);
    const char *pszTab = NULL;
    int nTab = -1;

    if (pTabViewInfo->pCallbacks->pfnGetCurrentTab)
        pszTab = pTabViewInfo->pCallbacks->pfnGetCurrentTab();

    if (pszTab)
    {
        if (pTabViewInfo->pCallbacks->pfnGetTabShortName)
        {
            for (int i = 0; i < pTabViewInfo->nTabCount; i++)
            {
                const char *pszThatTab = pTabViewInfo->pCallbacks->pfnGetTabShortName(i);

                if (pszThatTab && !core_stricmp(pszTab, pszThatTab))
                {
                    nTab = i;
                    break;
                }
            }
        }

        if (nTab < 0)
        {
            nTab = 0;
            sscanf(pszTab, "%d", &nTab);
        }
    }
    else
        nTab = 0;

    return nTab;
}