Skip to content

Commit

Permalink
Merge pull request joncampbell123#4825 from maron2000/fix_hdifdi
Browse files Browse the repository at this point in the history
Fix some .hdi & .fdi images could not be mounted
  • Loading branch information
joncampbell123 authored Feb 16, 2024
2 parents 06cec5c + fa0088c commit b3efb34
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/dos/drive_fat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1378,31 +1378,33 @@ fatDrive::fatDrive(const char* sysFilename, uint32_t bytesector, uint32_t cylsec
}

const char *ext = strrchr(sysFilename,'.');
bool is_hdd = false;
if((ext != NULL) && (!strcasecmp(ext, ".hdi") || !strcasecmp(ext, ".nhd"))) is_hdd = true;

if (ext != NULL && !strcasecmp(ext, ".d88")) {
fseeko64(diskfile, 0L, SEEK_END);
filesize = (uint32_t)(ftello64(diskfile) / 1024L);
loadedDisk = new imageDiskD88(diskfile, fname, filesize, (filesize > 2880));
loadedDisk = new imageDiskD88(diskfile, fname, filesize, false);
}
else if (!memcmp(bootcode,"VFD1.",5)) { /* FDD files */
fseeko64(diskfile, 0L, SEEK_END);
filesize = (uint32_t)(ftello64(diskfile) / 1024L);
loadedDisk = new imageDiskVFD(diskfile, fname, filesize, (filesize > 2880));
loadedDisk = new imageDiskVFD(diskfile, fname, filesize, false);
}
else if (!memcmp(bootcode,"T98FDDIMAGE.R0\0\0",16)) {
fseeko64(diskfile, 0L, SEEK_END);
filesize = (uint32_t)(ftello64(diskfile) / 1024L);
loadedDisk = new imageDiskNFD(diskfile, fname, filesize, (filesize > 2880), 0);
loadedDisk = new imageDiskNFD(diskfile, fname, filesize, false, 0);
}
else if (!memcmp(bootcode,"T98FDDIMAGE.R1\0\0",16)) {
fseeko64(diskfile, 0L, SEEK_END);
filesize = (uint32_t)(ftello64(diskfile) / 1024L);
loadedDisk = new imageDiskNFD(diskfile, fname, filesize, (filesize > 2880), 1);
loadedDisk = new imageDiskNFD(diskfile, fname, filesize, false, 1);
}
else {
fseeko64(diskfile, 0L, SEEK_END);
filesize = (uint32_t)(ftello64(diskfile) / 1024L);
loadedDisk = new imageDisk(diskfile, fname, filesize, (filesize > 2880));
loadedDisk = new imageDisk(diskfile, fname, filesize, (is_hdd | (filesize > 2880)));
}
}

Expand Down Expand Up @@ -1531,6 +1533,11 @@ void fatDrive::fatDriveInit(const char *sysFilename, uint32_t bytesector, uint32
bool pc98_512_to_1024_allow = false;
int opt_partition_index = -1;
bool is_hdd = (filesize > 2880);
if(!is_hdd) {
char* ext = strrchr((char*)sysFilename, '.');
if(ext != NULL && (!strcasecmp(ext, ".hdi") || !strcasecmp(ext, ".nhd"))) is_hdd = true;
}
//LOG_MSG("is_hdd = %s", is_hdd ? "true" : "false");

physToLogAdj = 0;
req_ver_major = req_ver_minor = 0;
Expand Down Expand Up @@ -1941,7 +1948,7 @@ void fatDrive::fatDriveInit(const char *sysFilename, uint32_t bytesector, uint32
loadedDisk->Read_AbsoluteSector(1,&sectorBuffer);
uint8_t mdesc = sectorBuffer[0];

if (mdesc >= 0xf8) {
if (mdesc >= 0xf8 && !IS_PC98_ARCH) {
/* DOS 1.x format, create BPB for 160kB floppy */
bootbuffer.bpb.v.BPB_BytsPerSec = 512;
bootbuffer.bpb.v.BPB_SecPerClus = 1;
Expand All @@ -1968,7 +1975,7 @@ void fatDrive::fatDriveInit(const char *sysFilename, uint32_t bytesector, uint32
bootbuffer.bpb.v.BPB_TotSec16 *= 2;
bootbuffer.bpb.v.BPB_NumHeads = 2;
}
} else {
} else if (!IS_PC98_ARCH) {
/* Unknown format */
created_successfully = false;
return;
Expand Down

0 comments on commit b3efb34

Please sign in to comment.