Skip to content

Commit

Permalink
Merge pull request joncampbell123#4836 from maron2000/fix_hdifdi
Browse files Browse the repository at this point in the history
PC-98: Enable mounting partitions with non-genuine IPL entry names
  • Loading branch information
joncampbell123 authored Feb 21, 2024
2 parents 9c3c4a8 + dc6636c commit 85528ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions include/bios_disk.h
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ class imageDiskElToritoFloppy : public imageDisk {
* Maximum 16 entries. */
#pragma pack(push,1)
struct _PC98RawPartition {
uint8_t mid; /* 0x80 - boot */
uint8_t sid; /* 0x80 - active */
uint8_t mid; /* 0x00: unused, 0x20: MS-DOS(not bootable), 0xa1-0xaf: MS-DOS(bootable) */
uint8_t sid; /* 0x00: unused, 0x81,0x91,0xa1,0xe1: MS-DOS(active), 0x01,0x11,0x21,0x61: MS-DOS(sleep) */
uint8_t dum1; /* dummy for padding */
uint8_t dum2; /* dummy for padding */
uint8_t ipl_sect; /* IPL sector */
Expand Down
16 changes: 10 additions & 6 deletions src/dos/drive_fat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,22 @@ bool systemmessagebox(char const * aTitle, char const * aMessage, char const * a
int PC98AutoChoose_FAT(const std::vector<_PC98RawPartition> &parts,imageDisk *loadedDisk) {
for (size_t i=0;i < parts.size();i++) {
const _PC98RawPartition &pe = parts[i];

/* skip partitions already in use */
if (loadedDisk->partitionInUse(i)) continue;
uint8_t syss = parts[i].sid;

/* We're looking for MS-DOS partitions.
* I've heard that some other OSes were once ported to PC-98, including Windows NT and OS/2,
* so I would rather not mistake NTFS or HPFS as FAT and cause damage. --J.C.
* FIXME: Is there a better way? */
if ( !strncasecmp(pe.name,"MS-DOS",6) ||
!strncasecmp(pe.name,"MSDOS",5) ||
!strncasecmp(pe.name,"Windows",7))
return (int)i;
if(!strncasecmp(pe.name, "MS-DOS", 6) ||
!strncasecmp(pe.name, "MSDOS", 5) ||
!strncasecmp(pe.name, "Windows", 7) ||
((parts[i].mid == 0x20 || (parts[i].mid >= 0xa1 && parts[i].mid <= 0xaf)) // bootable or non-bootable MS-DOS partition
&& (syss == 0x81 || syss == 0x91 || syss == 0xa1 || syss == 0xe1) // is an active MS-DOS partition
&& (parts[i].end_cyl <= loadedDisk->cylinders))) { // end_cyl is a valid value
return (int)i;
}
}

return -1;
Expand Down Expand Up @@ -1632,7 +1636,7 @@ void fatDrive::fatDriveInit(const char *sysFilename, uint32_t bytesector, uint32

LogPrintPartitionTable(parts);

/* user knows best! */
/* user knows best! */
if (opt_partition_index >= 0)
chosen_idx = opt_partition_index;
else
Expand Down

0 comments on commit 85528ee

Please sign in to comment.