コード例 #1
0
int td0dsk_t::data_read(UINT8 *buf, UINT16 size)
{
	if (floppy_file_offset + size > floppy_image_size(floppy_file) ) {
		size = floppy_image_size(floppy_file) - floppy_file_offset;
	}
	floppy_image_read(floppy_file,buf,floppy_file_offset,size);
	floppy_file_offset += size;
	return size;
}
コード例 #2
0
ファイル: nes_dsk.c プロジェクト: vorlenko/mame
static FLOPPY_IDENTIFY( nes_dsk_identify )
{
	UINT64 size;
	UINT8 header[3];

	*vote = 0;

	/* get first 3 bytes */
	floppy_image_read(floppy, &header, 0, sizeof(header));

	/* first check the size of the image */
	size = floppy_image_size(floppy);

	if ((size == 65516) || (size == 131016) || (size == 262016))
	{
		/* the image has an header, hence check the first sector for the magic string */
		if (!memcmp(header, "FDS", 3))
			*vote = 100;
	}

	if ((size == 65500) || (size == 131000) || (size == 262000))
	{
		/* the image has no header, hence let's trust the extension and load the file */
		*vote = 100;
	}

	return FLOPPY_ERROR_SUCCESS;
}
コード例 #3
0
ファイル: cpis_dsk.c プロジェクト: Ander-son/libretro-mame
static int compis_get_tracks_and_sectors(floppy_image_legacy *floppy, int *tracks, int *sectors)
{
	switch(floppy_image_size(floppy)) {
	case 0x50000:   /* 320 KB */
		*tracks = 40;
		*sectors = 8;
		break;

	case 0x5a000:   /* 360 KB */
		*tracks = 40;
		*sectors = 9;
		break;

	case 0xa0000:   /* 640 KB */
		*tracks = 80;
		*sectors = 8;
		break;

	case 0xb4000:   /* 720 KB */
		*tracks = 80;
		*sectors = 9;
		break;

	case 0x12c000:  /* 1200 KB */
		*tracks = 80;
		*sectors = 15;
		break;

	default:
		return 0;
	}
	return 1;
}
コード例 #4
0
ファイル: trs_dsk.c プロジェクト: AreaScout/mame-libretro
static FLOPPY_IDENTIFY( trs80_jv1_identify )
{
	UINT64 size;
	size = floppy_image_size(floppy);
	*vote = (size % (TRS80_JV1_HEADS * TRS80_JV1_SECTORS * TRS80_JV1_SECTORLENGTH))
		? 0 : 100;
	return FLOPPY_ERROR_SUCCESS;
}
コード例 #5
0
ファイル: trs_dsk.c プロジェクト: Synapseware/coco
static floperr_t trs80_jv1_identify(floppy_image *floppy, int *vote)
{
	UINT64 size;
	size = floppy_image_size(floppy);
	*vote = (size % (TRS80_JV1_HEADS * TRS80_JV1_SECTORS * TRS80_JV1_SECTORLENGTH))
		? 0 : 100;
	return FLOPPY_ERROR_SUCCESS;
}
コード例 #6
0
ファイル: pc_dsk.c プロジェクト: jiangzhonghui/mame
static floperr_t pc_dsk_compute_geometry(floppy_image_legacy *floppy, struct basicdsk_geometry *geometry)
{
	int i;
	UINT64 size;

	memset(geometry, 0, sizeof(*geometry));
	size = floppy_image_size(floppy);

	for (i = 0; i < ARRAY_LENGTH(disk_sizes); i++)
	{
		if (disk_sizes[i].image_size == size)
		{
			geometry->sectors = disk_sizes[i].sectors;
			geometry->heads = disk_sizes[i].heads;
			geometry->sector_length = 512;
			geometry->first_sector_id = 1;
			geometry->tracks = (int) (size / disk_sizes[i].sectors / disk_sizes[i].heads / geometry->sector_length);
			return FLOPPY_ERROR_SUCCESS;
		}
	}

	if (size >= 0x1a)
	{
		/*
		 * get info from boot sector.
		 * not correct on all disks
		 */
		UINT8 scl, spt, heads;
		floppy_image_read(floppy, &scl, 0x0c, 1);
		floppy_image_read(floppy, &spt, 0x18, 1);
		floppy_image_read(floppy, &heads, 0x1A, 1);

		if (size == ((UINT64) scl) * spt * heads * 0x200)
		{
			geometry->sectors = spt;
			geometry->heads = heads;
			geometry->sector_length = 512;
			geometry->first_sector_id = 1;
			geometry->tracks = scl;
			return FLOPPY_ERROR_SUCCESS;
		}
	}

	return FLOPPY_ERROR_SUCCESS;
}
コード例 #7
0
static FLOPPY_IDENTIFY(oric_dsk_identify)
{
	UINT8 header[mfm_disk_header_size];

	floppy_image_read(floppy, header, 0, mfm_disk_header_size);
	if ( memcmp( header, MFM_ID, 8 ) ==0) {
		int heads  = pick_integer_le(header, 8, 4);
		int tracks = pick_integer_le(header, 12, 4);

		if (floppy_image_size(floppy)==((tracks*heads*TRACK_SIZE_MFM)+mfm_disk_header_size)) {
			*vote = 100;
		} else {
			*vote = 0;
		}
	} else {
		*vote = 0;
	}
	return FLOPPY_ERROR_SUCCESS;
}
コード例 #8
0
ファイル: d88_dsk.cpp プロジェクト: Robbbert/store1
static void d88_get_header(floppy_image_legacy* floppy,uint32_t* size, uint8_t* prot, uint8_t* type, uint32_t* offsets)
{
	uint8_t header[D88_HEADER_LEN];
	int x,s;

	floppy_image_read(floppy,header,0,D88_HEADER_LEN);

#ifdef SPOT_DUPLICATES
		// there exist many .d88 files with same data and different headers and
		// this allows to spot duplicates, making easier to debug softlists.
		uint32_t temp_size = floppy_image_size(floppy);
		uint8_t tmp_copy[temp_size - D88_HEADER_LEN];
		floppy_image_read(floppy,tmp_copy,D88_HEADER_LEN,temp_size - D88_HEADER_LEN);
		printf("CRC16: %d\n", ccitt_crc16(0xffff, tmp_copy, temp_size - D88_HEADER_LEN));
#endif

	if(prot)
		*prot = header[0x1a];
	if(type)
		*type = header[0x1b];
	if(size)
	{
		s = 0;
		s |= header[0x1f] << 24;
		s |= header[0x1e] << 16;
		s |= header[0x1d] << 8;
		s |= header[0x1c];
		*size = s;
	}
	if(offsets)
	{
		for(x=0;x<164;x++)
		{
			s = 0;
			s |= header[0x23 + (x*4)] << 24;
			s |= header[0x22 + (x*4)] << 16;
			s |= header[0x21 + (x*4)] << 8;
			s |= header[0x20 + (x*4)];
			*(offsets+x) = s;
		}
	}
}
コード例 #9
0
ファイル: comx35_dsk.c プロジェクト: bdidier/MAME-OS-X
static FLOPPY_CONSTRUCT( comx35_dsk_construct )
{
	UINT8 header[1];
	int heads = 1;
	int cylinders = 35;

	switch (floppy_image_size(floppy))
	{
	case 35*1*16*128:
		heads = 1;
		cylinders = 35;
		break;

	case 35*2*16*128:
		floppy_image_read(floppy, header, 0x12, 1);

		if (header[0] == 0x01)
		{
			heads = 1;
			cylinders = 70;
		}
		else
		{
			heads = 2;
			cylinders = 35;
		}
		break;
	}

	struct basicdsk_geometry geometry;
	memset(&geometry, 0, sizeof(geometry));

	geometry.heads = heads;
	geometry.first_sector_id = 0;
	geometry.sector_length = 128;
	geometry.tracks = cylinders;
	geometry.sectors = 16;

	return basicdsk_construct(floppy, &geometry);
}
コード例 #10
0
ファイル: trs_dsk.c プロジェクト: Synapseware/coco
static floperr_t trs80_jv1_construct(floppy_image *floppy, option_resolution *params)
{
	struct basicdsk_geometry geometry;

	memset(&geometry, 0, sizeof(geometry));
	geometry.heads				= TRS80_JV1_HEADS;
	geometry.sectors			= TRS80_JV1_SECTORS;
	geometry.first_sector_id	= TRS80_JV1_FIRSTSECTORID;
	geometry.sector_length		= TRS80_JV1_SECTORLENGTH;

	if (params)
	{
		/* create */
		geometry.tracks = option_resolution_lookup_int(params, PARAM_TRACKS);
	}
	else
	{
		/* load */
		geometry.tracks = (int) (floppy_image_size(floppy) / geometry.heads
			/ geometry.sectors / geometry.sector_length);
	}
	return basicdsk_construct(floppy, &geometry);
}
コード例 #11
0
ファイル: vt_dsk.c プロジェクト: BrandoCommando/mame
static FLOPPY_CONSTRUCT(vz_construct)
{
	struct basicdsk_geometry geometry;
	memset(&geometry, 0, sizeof(geometry));

	if (params)
	{
		geometry.heads           = option_resolution_lookup_int(params, PARAM_HEADS);
		geometry.tracks          = option_resolution_lookup_int(params, PARAM_TRACKS);
		geometry.sectors         = option_resolution_lookup_int(params, PARAM_SECTORS);
		geometry.first_sector_id = option_resolution_lookup_int(params, PARAM_FIRST_SECTOR_ID);
		geometry.sector_length   = option_resolution_lookup_int(params, PARAM_SECTOR_LENGTH);
	}
	else
	{
		geometry.heads           = 1;
		geometry.tracks          = 40;
		geometry.sectors         = 16;
		geometry.first_sector_id = 0;
		geometry.sector_length   = floppy_image_size(floppy)/geometry.tracks/geometry.sectors;
	}

	return basicdsk_construct(floppy, &geometry);
}
コード例 #12
0
ファイル: vt_dsk.c プロジェクト: BrandoCommando/mame
static FLOPPY_IDENTIFY(vz_identify)
{
	UINT64 size = floppy_image_size(floppy);
	*vote = ((size == 98560) || (size == 99200) || (size == 99184)) ? 100 : 0;
	return FLOPPY_ERROR_SUCCESS;
}
コード例 #13
0
static FLOPPY_IDENTIFY(exi_dsk_identify)
{
	*vote = (floppy_image_size(floppy) == 332640) ? 100 : 0;
	return FLOPPY_ERROR_SUCCESS;
}
コード例 #14
0
static FLOPPY_IDENTIFY(smx_dsk_identify)
{
	*vote = (floppy_image_size(floppy) == 819200) ? 100 : 0;
	return FLOPPY_ERROR_SUCCESS;
}
コード例 #15
0
static FLOPPY_IDENTIFY(hector_disc2_dsk800_identify)
{
	*vote = (floppy_image_size(floppy) == (2*80*10*512)) ? 100 : 0;
	return FLOPPY_ERROR_SUCCESS;
}
コード例 #16
0
ファイル: comx35_dsk.c プロジェクト: bdidier/MAME-OS-X
static FLOPPY_IDENTIFY( comx35_dsk_identify )
{
	*vote = ((floppy_image_size(floppy) == (35*1*16*128)) || (floppy_image_size(floppy) == (35*2*16*128))) ? 100 : 0;

	return FLOPPY_ERROR_SUCCESS;
}