mirror of
https://github.com/jfdelnero/HxCFloppyEmulator.git
synced 2026-07-27 19:56:23 +00:00
D71 support added.
This commit is contained in:
@@ -72,7 +72,7 @@ int D64_libIsValidDiskFile( HXCFE_IMGLDR * imgldr_ctx, HXCFE_IMGLDR_FILEINFOS *
|
||||
{
|
||||
imgldr_ctx->hxcfe->hxc_printf(MSG_DEBUG,"D64_libIsValidDiskFile");
|
||||
|
||||
if(hxc_checkfileext(imgfile->path,"d64",SYS_PATH_TYPE))
|
||||
if(hxc_checkfileext(imgfile->path,"d64",SYS_PATH_TYPE) || hxc_checkfileext(imgfile->path,"d71",SYS_PATH_TYPE))
|
||||
{
|
||||
imgldr_ctx->hxcfe->hxc_printf(MSG_DEBUG,"D64_libIsValidDiskFile : D64 file !");
|
||||
return HXCFE_VALIDFILE;
|
||||
@@ -88,16 +88,17 @@ int D64_libLoad_DiskFile(HXCFE_IMGLDR * imgldr_ctx,HXCFE_FLOPPY * floppydisk,cha
|
||||
{
|
||||
FILE * f;
|
||||
unsigned int filesize;
|
||||
int i,j,k;
|
||||
int i,j,k,trk;
|
||||
unsigned char* trackdata;
|
||||
int tracklen;
|
||||
int rpm;
|
||||
int sectorsize;
|
||||
HXCFE_CYLINDER* currentcylinder;
|
||||
HXCFE_SIDE* currentside;
|
||||
unsigned char errormap[1024];
|
||||
unsigned char errormap[2048];
|
||||
d64trackpos * tracklistpos;
|
||||
int number_of_track;
|
||||
int number_of_sides;
|
||||
int errormap_size;
|
||||
|
||||
tracklistpos = NULL;
|
||||
@@ -114,17 +115,22 @@ int D64_libLoad_DiskFile(HXCFE_IMGLDR * imgldr_ctx,HXCFE_FLOPPY * floppydisk,cha
|
||||
|
||||
filesize = hxc_fgetsize(f);
|
||||
|
||||
number_of_track=35;
|
||||
number_of_sides=1;
|
||||
|
||||
errormap_size=0;
|
||||
switch(filesize)
|
||||
{
|
||||
case 174848:
|
||||
//35 track, no errors
|
||||
number_of_track=35;
|
||||
number_of_sides=1;
|
||||
break;
|
||||
|
||||
case 175531:
|
||||
//35 track, 683 error bytes
|
||||
number_of_track=35;
|
||||
number_of_sides=1;
|
||||
|
||||
errormap_size=683;
|
||||
memset(errormap,0,errormap_size);
|
||||
@@ -136,11 +142,13 @@ int D64_libLoad_DiskFile(HXCFE_IMGLDR * imgldr_ctx,HXCFE_FLOPPY * floppydisk,cha
|
||||
case 196608:
|
||||
//40 track, no errors
|
||||
number_of_track=40;
|
||||
number_of_sides=1;
|
||||
break;
|
||||
|
||||
case 197376:
|
||||
//40 track, 768 error bytes
|
||||
number_of_track=40;
|
||||
number_of_sides=1;
|
||||
|
||||
errormap_size=768;
|
||||
memset(errormap,0,errormap_size);
|
||||
@@ -149,6 +157,44 @@ int D64_libLoad_DiskFile(HXCFE_IMGLDR * imgldr_ctx,HXCFE_FLOPPY * floppydisk,cha
|
||||
|
||||
break;
|
||||
|
||||
case 349696:
|
||||
//35 track, 2 sides, no errors (d71)
|
||||
number_of_track=35;
|
||||
number_of_sides=2;
|
||||
|
||||
break;
|
||||
|
||||
case 351062:
|
||||
//35 track, 2 sides, 1366 error bytes (d71)
|
||||
number_of_track=35;
|
||||
number_of_sides=2;
|
||||
|
||||
errormap_size=683*2;
|
||||
memset(errormap,0,errormap_size);
|
||||
fseek(f,errormap_size,SEEK_END);
|
||||
hxc_fread(errormap,errormap_size,f);
|
||||
|
||||
break;
|
||||
|
||||
case 393216:
|
||||
//40 track, 2 sides, no errors (d71)
|
||||
number_of_track=40;
|
||||
number_of_sides=2;
|
||||
|
||||
break;
|
||||
|
||||
case 394752:
|
||||
//40 track, 2 sides, 1536 error bytes (d71)
|
||||
number_of_track=40;
|
||||
number_of_sides=2;
|
||||
|
||||
errormap_size=768*2;
|
||||
memset(errormap,0,errormap_size);
|
||||
fseek(f,errormap_size,SEEK_END);
|
||||
hxc_fread(errormap,errormap_size,f);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
// not supported !
|
||||
imgldr_ctx->hxcfe->hxc_printf(MSG_ERROR,"Unsupported D64 file size ! (%d Bytes)",filesize);
|
||||
@@ -158,60 +204,70 @@ int D64_libLoad_DiskFile(HXCFE_IMGLDR * imgldr_ctx,HXCFE_FLOPPY * floppydisk,cha
|
||||
break;
|
||||
}
|
||||
|
||||
tracklistpos=(d64trackpos*)malloc(number_of_track*sizeof(d64trackpos));
|
||||
tracklistpos=(d64trackpos*)malloc(number_of_track*number_of_sides*sizeof(d64trackpos));
|
||||
if( !tracklistpos )
|
||||
goto alloc_error;
|
||||
|
||||
memset(tracklistpos,0,number_of_track*sizeof(d64trackpos));
|
||||
memset(tracklistpos,0,number_of_track*number_of_sides*sizeof(d64trackpos));
|
||||
|
||||
i=0;
|
||||
k=0;
|
||||
do
|
||||
j=0;
|
||||
i=0;
|
||||
|
||||
while(j<number_of_sides)
|
||||
{
|
||||
tracklistpos[i].number_of_sector=21;
|
||||
tracklistpos[i].fileoffset=k;
|
||||
tracklistpos[i].bitrate=307693;//XTAL_16_MHz / 13
|
||||
trk=0;
|
||||
|
||||
k=k+(21*256);
|
||||
i++;
|
||||
}while(i<number_of_track && i<17);
|
||||
do
|
||||
{
|
||||
tracklistpos[i].number_of_sector=21;
|
||||
tracklistpos[i].fileoffset=k;
|
||||
tracklistpos[i].bitrate=307693;//XTAL_16_MHz / 13
|
||||
|
||||
i=17;
|
||||
do
|
||||
{
|
||||
tracklistpos[i].number_of_sector=19;
|
||||
tracklistpos[i].fileoffset=k;
|
||||
tracklistpos[i].bitrate=285715; //XTAL_16_MHz / 14
|
||||
k=k+(21*256);
|
||||
i++;
|
||||
trk++;
|
||||
}while(i<(number_of_track*number_of_sides) && trk<17);
|
||||
|
||||
k=k+(19*256);
|
||||
i++;
|
||||
}while(i<number_of_track && i<24);
|
||||
do
|
||||
{
|
||||
tracklistpos[i].number_of_sector=19;
|
||||
tracklistpos[i].fileoffset=k;
|
||||
tracklistpos[i].bitrate=285715; //XTAL_16_MHz / 14
|
||||
|
||||
i=24;
|
||||
do
|
||||
{
|
||||
tracklistpos[i].number_of_sector=18;
|
||||
tracklistpos[i].fileoffset=k;
|
||||
tracklistpos[i].bitrate=266667;//XTAL_16_MHz / 15
|
||||
k=k+(19*256);
|
||||
i++;
|
||||
trk++;
|
||||
}while(i<(number_of_track*number_of_sides) && trk<24);
|
||||
|
||||
k=k+(18*256);
|
||||
i++;
|
||||
}while(i<number_of_track && i<30);
|
||||
do
|
||||
{
|
||||
tracklistpos[i].number_of_sector=18;
|
||||
tracklistpos[i].fileoffset=k;
|
||||
tracklistpos[i].bitrate=266667;//XTAL_16_MHz / 15
|
||||
|
||||
i=30;
|
||||
do
|
||||
{
|
||||
tracklistpos[i].number_of_sector=17;
|
||||
tracklistpos[i].fileoffset=k;
|
||||
tracklistpos[i].bitrate=250000;//XTAL_16_MHz / 16
|
||||
k=k+(18*256);
|
||||
i++;
|
||||
trk++;
|
||||
}while(i<(number_of_track*number_of_sides) && trk<30);
|
||||
|
||||
k=k+(17*256);
|
||||
i++;
|
||||
}while(i<number_of_track);
|
||||
do
|
||||
{
|
||||
tracklistpos[i].number_of_sector=17;
|
||||
tracklistpos[i].fileoffset=k;
|
||||
tracklistpos[i].bitrate=250000;//XTAL_16_MHz / 16
|
||||
|
||||
k=k+(17*256);
|
||||
i++;
|
||||
trk++;
|
||||
}while(i<(number_of_track*number_of_sides) && trk<number_of_track);
|
||||
|
||||
j++;
|
||||
}
|
||||
|
||||
floppydisk->floppyNumberOfTrack = number_of_track;
|
||||
floppydisk->floppyNumberOfSide = number_of_sides;
|
||||
|
||||
floppydisk->floppyNumberOfTrack=number_of_track;
|
||||
floppydisk->floppyNumberOfSide=1;
|
||||
floppydisk->floppySectorPerTrack=-1;
|
||||
|
||||
sectorsize=256; // c64 file support only 256bytes/sector floppies.
|
||||
@@ -237,7 +293,7 @@ int D64_libLoad_DiskFile(HXCFE_IMGLDR * imgldr_ctx,HXCFE_FLOPPY * floppydisk,cha
|
||||
{
|
||||
hxcfe_imgCallProgressCallback(imgldr_ctx,(j<<1) + (i&1),floppydisk->floppyNumberOfTrack*2 );
|
||||
|
||||
tracklen=(tracklistpos[j].bitrate/(rpm/60))/4;
|
||||
tracklen=(tracklistpos[j+(i*trk)].bitrate/(rpm/60))/4;
|
||||
|
||||
currentcylinder->sides[i] = malloc(sizeof(HXCFE_SIDE));
|
||||
if( !currentcylinder->sides[i] )
|
||||
@@ -246,7 +302,7 @@ int D64_libLoad_DiskFile(HXCFE_IMGLDR * imgldr_ctx,HXCFE_FLOPPY * floppydisk,cha
|
||||
memset(currentcylinder->sides[i],0,sizeof(HXCFE_SIDE));
|
||||
currentside=currentcylinder->sides[i];
|
||||
|
||||
currentside->number_of_sector=tracklistpos[j].number_of_sector;
|
||||
currentside->number_of_sector=tracklistpos[j+(i*trk)].number_of_sector;
|
||||
currentside->tracklen=tracklen;
|
||||
|
||||
currentside->databuffer = malloc(currentside->tracklen);
|
||||
@@ -264,16 +320,16 @@ int D64_libLoad_DiskFile(HXCFE_IMGLDR * imgldr_ctx,HXCFE_FLOPPY * floppydisk,cha
|
||||
memset(currentside->indexbuffer,0,currentside->tracklen);
|
||||
|
||||
currentside->timingbuffer=0;
|
||||
currentside->bitrate=tracklistpos[j].bitrate;
|
||||
currentside->bitrate=tracklistpos[j+(i*trk)].bitrate;
|
||||
currentside->track_encoding=UNKNOWN_ENCODING;
|
||||
|
||||
fseek (f , tracklistpos[j].fileoffset , SEEK_SET);
|
||||
fseek (f , tracklistpos[j+(i*trk)].fileoffset , SEEK_SET);
|
||||
|
||||
hxc_fread(trackdata,sectorsize*currentside->number_of_sector,f);
|
||||
|
||||
imgldr_ctx->hxcfe->hxc_printf(MSG_DEBUG,"Track:%d Size:%d File offset:%d Number of sector:%d Bitrate:%d",j,currentside->tracklen,tracklistpos[j].fileoffset,tracklistpos[j].number_of_sector,currentside->bitrate);
|
||||
imgldr_ctx->hxcfe->hxc_printf(MSG_DEBUG,"Track:%d Size:%d File offset:%d Number of sector:%d Bitrate:%d",j,currentside->tracklen,tracklistpos[j+(i*trk)].fileoffset,tracklistpos[j+(i*trk)].number_of_sector,currentside->bitrate);
|
||||
|
||||
BuildC64GCRTrack(currentside->number_of_sector,sectorsize,j,i,trackdata,currentside->databuffer,¤tside->tracklen);
|
||||
BuildC64GCRTrack(currentside->number_of_sector,sectorsize,j+(floppydisk->floppyNumberOfTrack*i),i,trackdata,currentside->databuffer,¤tside->tracklen);
|
||||
|
||||
currentside->tracklen=currentside->tracklen*8;
|
||||
|
||||
@@ -304,7 +360,7 @@ alloc_error:
|
||||
int D64_libGetPluginInfo(HXCFE_IMGLDR * imgldr_ctx,uint32_t infotype,void * returnvalue)
|
||||
{
|
||||
static const char plug_id[]="C64_D64";
|
||||
static const char plug_desc[]="C64 D64 file image loader";
|
||||
static const char plug_desc[]="C64 D64/D71 file image loader";
|
||||
static const char plug_ext[]="d64";
|
||||
|
||||
plugins_ptr plug_funcs=
|
||||
|
||||
Reference in New Issue
Block a user