Пример #1
0
static int internal_floppy_device_load(mess_image *image, mame_file *file, int create_format, option_resolution *create_args)
{
	floperr_t err;
	struct mess_flopimg *flopimg;
	const struct IODevice *dev;
	const struct FloppyFormat *floppy_options;
	int floppy_flags, i;
	const char *extension;

	/* look up instance data */
	flopimg = get_flopimg(image);

	/* figure out the floppy options */
	dev = image_device(image);
	floppy_options = device_get_info_ptr(&dev->devclass, DEVINFO_PTR_FLOPPY_OPTIONS);

	if (image_has_been_created(image))
	{
		/* creating an image */
		assert(create_format >= 0);
		err = floppy_create(file, &mess_ioprocs, &floppy_options[create_format], create_args, &flopimg->floppy);
		if (err)
			goto error;
	}
	else
	{
		/* opening an image */
		floppy_flags = image_is_writable(image) ? FLOPPY_FLAGS_READWRITE : FLOPPY_FLAGS_READONLY;
		extension = image_filetype(image);
		err = floppy_open_choices(file, &mess_ioprocs, extension, floppy_options, floppy_flags, &flopimg->floppy);
		if (err)
			goto error;
	}

	/* if we can get head and track counts, then set the geometry accordingly */
	if (floppy_callbacks(flopimg->floppy)->get_heads_per_disk
		&& floppy_callbacks(flopimg->floppy)->get_tracks_per_disk)
	{
		floppy_drive_set_geometry_absolute(image,
			floppy_get_tracks_per_disk(flopimg->floppy), 
			floppy_get_heads_per_disk(flopimg->floppy));
	}
	return INIT_PASS;

error:
	for (i = 0; i < sizeof(errmap) / sizeof(errmap[0]); i++)
	{
		if (err == errmap[i].ferr)
			image_seterror(image, errmap[i].ierr, errmap[i].message);
	}
	return INIT_FAIL;
}
Пример #2
0
/* dir_sector is a relative offset from the start of the disc,
dir_length is a relative offset from the start of the disc */
void basicdsk_set_geometry(mess_image *img, UINT8 tracks, UINT8 heads, UINT8 sec_per_track, UINT16 sector_length, UINT8 first_sector_id, UINT16 offset_track_zero, int track_skipping)
{
	unsigned long N;
	unsigned long ShiftCount;
	basicdsk *pDisk = get_basicdsk(img);

	pDisk->tracks = tracks;
	pDisk->heads = heads;
	pDisk->first_sector_id = first_sector_id;
	pDisk->sec_per_track = sec_per_track;
	pDisk->sector_length = sector_length;
	pDisk->offset = offset_track_zero;

	pDisk->track_divider = track_skipping ? 2 : 1;

	floppy_drive_set_geometry_absolute(img, tracks * pDisk->track_divider, heads );
	
	pDisk->image_size = pDisk->tracks * pDisk->heads * pDisk->sec_per_track * pDisk->sector_length;

	/* setup a new ddam map */
	pDisk->ddam_map_size = ((pDisk->tracks * pDisk->heads * pDisk->sec_per_track)+7)>>3;
	pDisk->ddam_map = (UINT8 *) image_realloc(img, pDisk->ddam_map, pDisk->ddam_map_size);

	if (pDisk->ddam_map!=NULL)
	{
		memset(pDisk->ddam_map, 0, pDisk->ddam_map_size);
	}


	/* from sector length calculate N value for sector id's */
	/* N = 0 for 128, N = 1 for 256, N = 2 for 512 ... */
	N = (pDisk->sector_length);
	ShiftCount = 0;

	if (N!=0)
	{
		while ((N & 0x080000000)==0)
		{
			N = N<<1;
			ShiftCount++;
		}

		/* get left-shift required to shift 1 to this
		power of 2 */

		pDisk->N = (31 - ShiftCount)-7;
	}
	else
	{
		pDisk->N = 0;
	}
}
Пример #3
0
static int internal_floppy_device_load(device_image_interface *image, int create_format, option_resolution *create_args)
{
	floperr_t err;
	floppy_drive *flopimg;
	const struct FloppyFormat *floppy_options;
	int floppy_flags, i;
	const char *extension;

	/* look up instance data */
	flopimg = get_safe_token( &image->device() );

	/* figure out the floppy options */
	floppy_options = ((floppy_interface*)image->device().static_config())->formats;

	if (image->has_been_created())
	{
		/* creating an image */
		assert(create_format >= 0);
		err = floppy_create((void *) image, &image_ioprocs, &floppy_options[create_format], create_args, &flopimg->floppy);
		if (err)
			goto error;
	}
	else
	{
		/* opening an image */
		floppy_flags = !image->is_readonly() ? FLOPPY_FLAGS_READWRITE : FLOPPY_FLAGS_READONLY;
		extension = image->filetype();
		err = floppy_open_choices((void *) image, &image_ioprocs, extension, floppy_options, floppy_flags, &flopimg->floppy);
		if (err)
			goto error;
	}
	if (floppy_callbacks(flopimg->floppy)->get_heads_per_disk && floppy_callbacks(flopimg->floppy)->get_tracks_per_disk)
	{
		floppy_drive_set_geometry_absolute(&image->device(),
			floppy_get_tracks_per_disk(flopimg->floppy),
			floppy_get_heads_per_disk(flopimg->floppy));
	}
	/* disk changed */
	flopimg->dskchg = CLEAR_LINE;

	return IMAGE_INIT_PASS;

error:
	for (i = 0; i < ARRAY_LENGTH(errmap); i++)
	{
		if (err == errmap[i].ferr)
			image->seterror(errmap[i].ierr, errmap[i].message);
	}
	return IMAGE_INIT_FAIL;
}
Пример #4
0
image_init_result legacy_floppy_image_device::internal_floppy_device_load(bool is_create, int create_format, util::option_resolution *create_args)
{
	floperr_t err;
	const struct FloppyFormat *floppy_options;
	int floppy_flags, i;

	device_image_interface *image = nullptr;
	interface(image);   /* figure out the floppy options */
	floppy_options = m_config->formats;

	if (is_create)
	{
		/* creating an image */
		assert(create_format >= 0);
		err = floppy_create((void *) image, &image_ioprocs, &floppy_options[create_format], create_args, &m_floppy);
		if (err)
			goto error;
	}
	else
	{
		/* opening an image */
		floppy_flags = !is_readonly() ? FLOPPY_FLAGS_READWRITE : FLOPPY_FLAGS_READONLY;
		err = floppy_open_choices((void *) image, &image_ioprocs, filetype(), floppy_options, floppy_flags, &m_floppy);
		if (err)
			goto error;
	}
	if (floppy_callbacks(m_floppy)->get_heads_per_disk && floppy_callbacks(m_floppy)->get_tracks_per_disk)
	{
		floppy_drive_set_geometry_absolute(floppy_get_tracks_per_disk(m_floppy),floppy_get_heads_per_disk(m_floppy));
	}
	/* disk changed */
	m_dskchg = CLEAR_LINE;

	// If we have one of our hacky load procs, call it
	if (m_load_proc)
		m_load_proc(*this, is_create);

	return image_init_result::PASS;

error:
	for (i = 0; i < ARRAY_LENGTH(errmap); i++)
	{
		if (err == errmap[i].ferr)
			seterror(errmap[i].ierr, errmap[i].message);
	}
	return image_init_result::FAIL;
}
Пример #5
0
int legacy_floppy_image_device::internal_floppy_device_load(int create_format, util::option_resolution *create_args)
{
	floperr_t err;
	const struct FloppyFormat *floppy_options;
	int floppy_flags, i;
	const char *extension;

	device_image_interface *image = nullptr;
	interface(image);   /* figure out the floppy options */
	floppy_options = m_config->formats;

	if (has_been_created())
	{
		/* creating an image */
		assert(create_format >= 0);
		err = floppy_create((void *) image, &image_ioprocs, &floppy_options[create_format], create_args, &m_floppy);
		if (err)
			goto error;
	}
	else
	{
		/* opening an image */
		floppy_flags = !is_readonly() ? FLOPPY_FLAGS_READWRITE : FLOPPY_FLAGS_READONLY;
		extension = filetype();
		err = floppy_open_choices((void *) image, &image_ioprocs, extension, floppy_options, floppy_flags, &m_floppy);
		if (err)
			goto error;
	}
	if (floppy_callbacks(m_floppy)->get_heads_per_disk && floppy_callbacks(m_floppy)->get_tracks_per_disk)
	{
		floppy_drive_set_geometry_absolute(floppy_get_tracks_per_disk(m_floppy),floppy_get_heads_per_disk(m_floppy));
	}
	/* disk changed */
	m_dskchg = CLEAR_LINE;

	return IMAGE_INIT_PASS;

error:
	for (i = 0; i < ARRAY_LENGTH(errmap); i++)
	{
		if (err == errmap[i].ferr)
			seterror(errmap[i].ierr, errmap[i].message);
	}
	return IMAGE_INIT_FAIL;
}
Пример #6
0
void floppy_drive_set_geometry(device_t *img, floppy_type_t type)
{
	floppy_drive_set_geometry_absolute(img, type.max_track_number, type.head_number);
}
Пример #7
0
void legacy_floppy_image_device::floppy_drive_set_geometry(floppy_type_t type)
{
	floppy_drive_set_geometry_absolute(type.max_track_number, type.head_number);
}