示例#1
0
image_init_result harddisk_image_device::call_create(int create_format, util::option_resolution *create_args)
{
	int err;
	UINT32 sectorsize, hunksize;
	UINT32 cylinders, heads, sectors, totalsectors;

	assert_always(create_args != nullptr, "Expected create_args to not be nullptr");
	cylinders   = create_args->lookup_int('C');
	heads       = create_args->lookup_int('H');
	sectors     = create_args->lookup_int('S');
	sectorsize  = create_args->lookup_int('L');
	hunksize    = create_args->lookup_int('K');

	totalsectors = cylinders * heads * sectors;

	/* create the CHD file */
	chd_codec_type compression[4] = { CHD_CODEC_NONE };
	err = m_origchd.create(image_core_file(), (UINT64)totalsectors * (UINT64)sectorsize, hunksize, sectorsize, compression);
	if (err != CHDERR_NONE)
		goto error;

	/* if we created the image and hence, have metadata to set, set the metadata */
	err = m_origchd.write_metadata(HARD_DISK_METADATA_TAG, 0, string_format(HARD_DISK_METADATA_FORMAT, cylinders, heads, sectors, sectorsize));
	m_origchd.close();

	if (err != CHDERR_NONE)
		goto error;

	return internal_load_hd();

error:
	return image_init_result::FAIL;
}
示例#2
0
文件: harddriv.c 项目: LeWoY/MAMEHub
bool harddisk_image_device::call_create(int create_format, option_resolution *create_args)
{
	int err;
	UINT32 sectorsize, hunksize;
	UINT32 cylinders, heads, sectors, totalsectors;
	astring metadata;

	cylinders   = option_resolution_lookup_int(create_args, 'C');
	heads       = option_resolution_lookup_int(create_args, 'H');
	sectors     = option_resolution_lookup_int(create_args, 'S');
	sectorsize  = option_resolution_lookup_int(create_args, 'L');
	hunksize    = option_resolution_lookup_int(create_args, 'K');

	totalsectors = cylinders * heads * sectors;

	/* create the CHD file */
	chd_codec_type compression[4] = { CHD_CODEC_NONE };
	err = m_origchd.create(*image_core_file(), (UINT64)totalsectors * (UINT64)sectorsize, hunksize, sectorsize, compression);
	if (err != CHDERR_NONE)
		goto error;

	/* if we created the image and hence, have metadata to set, set the metadata */
	metadata.format(HARD_DISK_METADATA_FORMAT, cylinders, heads, sectors, sectorsize);
	err = m_origchd.write_metadata(HARD_DISK_METADATA_TAG, 0, metadata);
	m_origchd.close();

	if (err != CHDERR_NONE)
		goto error;

	return internal_load_hd();

error:
	return IMAGE_INIT_FAIL;
}
示例#3
0
bool harddisk_image_device::call_create(int create_format, option_resolution *create_args)
{
	int err;
	char metadata[256];
	UINT32 sectorsize, hunksize;
	UINT32 cylinders, heads, sectors, totalsectors;

	cylinders	= option_resolution_lookup_int(create_args, 'C');
	heads		= option_resolution_lookup_int(create_args, 'H');
	sectors		= option_resolution_lookup_int(create_args, 'S');
	sectorsize	= option_resolution_lookup_int(create_args, 'L');
	hunksize	= option_resolution_lookup_int(create_args, 'K');

	totalsectors = cylinders * heads * sectors;

	/* create the CHD file */
	err = chd_create_file(image_core_file(), (UINT64)totalsectors * (UINT64)sectorsize, hunksize, CHDCOMPRESSION_NONE, NULL);
	if (err != CHDERR_NONE)
		goto error;

	sprintf(metadata, HARD_DISK_METADATA_FORMAT, cylinders, heads, sectors, sectorsize);
	return internal_load_hd(metadata);

error:
	return IMAGE_INIT_FAIL;
}
示例#4
0
image_init_result harddisk_image_device::call_load()
{
	image_init_result our_result;

	our_result = internal_load_hd();

	/* Check if there is an image_load callback defined */
	if (!m_device_image_load.isnull())
	{
		/* Let the override do some additional work/checks */
		our_result = m_device_image_load(*this);
	}
	return our_result;

}