コード例 #1
0
ファイル: xdms.c プロジェクト: lleoha/WinFellow
USHORT dmsUnpack(char *src, char *dest)
{
	return Process_File(src, dest, 0, 0, 0);
}
コード例 #2
0
ファイル: dms_loader.c プロジェクト: slimlogic/hxc-software
int DMS_libLoad_DiskFile(HXCFLOPPYEMULATOR* floppycontext,FLOPPY * floppydisk,char * imgfile,void * parameters)
{
	unsigned int filesize;
	unsigned int i,j;
	unsigned int file_offset;
	unsigned short sectorsize;
	unsigned char gap3len,skew,trackformat,interleave;
	HXCFILE * fo;
	unsigned char* flatimg;
	int retxdms;
	CYLINDER* currentcylinder;

	floppycontext->hxc_printf(MSG_DEBUG,"DMS_libLoad_DiskFile %s",imgfile);

	// ouverture et decompression du fichier dms
	fo=HXC_fopen("","");
	retxdms=Process_File(imgfile,fo, CMD_UNPACK, 0, 0, 0);
	if(retxdms)
	{
		floppycontext->hxc_printf(MSG_ERROR,"XDMS: Error %d while reading the file!",retxdms);
		HXC_fclose(fo);
		return HXCFE_ACCESSERROR;
	}


	filesize=fo->buffersize;
	flatimg=fo->buffer;

	if(fo!=0)
	{
		sectorsize=512;
		interleave=1;
		gap3len=0;
		skew=0;
		trackformat=AMIGAFORMAT_DD;
		floppydisk->floppySectorPerTrack=11;
		floppydisk->floppyNumberOfSide=2;
		floppydisk->floppyNumberOfTrack=(filesize/(512*2*11));
		floppydisk->floppyBitRate=DEFAULT_AMIGA_BITRATE;
		floppydisk->floppyiftype=AMIGA_DD_FLOPPYMODE;
		floppydisk->tracks=(CYLINDER**)malloc(sizeof(CYLINDER*)*(floppydisk->floppyNumberOfTrack+4));

		for(j=0;j<floppydisk->floppyNumberOfTrack;j++)
		{

			floppydisk->tracks[j]=allocCylinderEntry(DEFAULT_AMIGA_RPM,floppydisk->floppyNumberOfSide);
			currentcylinder=floppydisk->tracks[j];

			for(i=0;i<floppydisk->floppyNumberOfSide;i++)
			{

				file_offset=(sectorsize*(j*floppydisk->floppySectorPerTrack*floppydisk->floppyNumberOfSide))+
							(sectorsize*(floppydisk->floppySectorPerTrack)*i);

				currentcylinder->sides[i]=tg_generateTrack(&flatimg[file_offset],sectorsize,floppydisk->floppySectorPerTrack,(unsigned char)j,(unsigned char)i,0,interleave,(unsigned char)(((j<<1)|(i&1))*skew),floppydisk->floppyBitRate,currentcylinder->floppyRPM,trackformat,gap3len,0,2500,-11150);

			}
		}

		// Add 4 empty tracks
		for(j=floppydisk->floppyNumberOfTrack;j<(unsigned int)(floppydisk->floppyNumberOfTrack + 4);j++)
		{
			floppydisk->tracks[j]=allocCylinderEntry(DEFAULT_AMIGA_RPM,floppydisk->floppyNumberOfSide);
			currentcylinder=floppydisk->tracks[j];

			for(i=0;i<floppydisk->floppyNumberOfSide;i++)
			{
				currentcylinder->sides[i]=tg_generateTrack(&flatimg[file_offset],sectorsize,0,(unsigned char)j,(unsigned char)i,0,interleave,(unsigned char)(((j<<1)|(i&1))*skew),floppydisk->floppyBitRate,currentcylinder->floppyRPM,trackformat,gap3len,0,2500,-11150);
			}
		}

		floppydisk->floppyNumberOfTrack += 4;

		floppycontext->hxc_printf(MSG_INFO_1,"DMS Loader : tracks file successfully loaded and encoded!");
		HXC_fclose(fo);
		return HXCFE_NOERROR;
	}

	floppycontext->hxc_printf(MSG_ERROR,"DMS file access error!");
	return HXCFE_ACCESSERROR;
}