add mount option and support in INT 13h code for "reserved cylinder"

emulation
This commit is contained in:
Jonathan Campbell 2013-10-21 01:30:58 -07:00
parent df522c2fa7
commit 32e0e40dde
3 changed files with 31 additions and 1 deletions

View File

@ -50,6 +50,8 @@ public:
Bit8u Read_AbsoluteSector(Bit32u sectnum, void * data);
Bit8u Write_AbsoluteSector(Bit32u sectnum, void * data);
void Set_Reserved_Cylinders(Bitu resCyl);
Bit32u Get_Reserved_Cylinders();
void Set_Geometry(Bit32u setHeads, Bit32u setCyl, Bit32u setSect, Bit32u setSectSize);
void Get_Geometry(Bit32u * getHeads, Bit32u *getCyl, Bit32u *getSect, Bit32u *getSectSize);
Bit8u GetBiosType(void);
@ -65,6 +67,7 @@ public:
Bit32u sector_size;
Bit32u heads,cylinders,sectors;
Bit32u reserved_cylinders;
Bit64u current_fpos;
};

View File

@ -1935,10 +1935,18 @@ public:
if (type=="floppy" || type=="hdd" || type=="iso") {
Bit16u sizes[4];
bool imgsizedetect=false;
int reserved_cylinders=0;
std::string reservecyl;
std::string str_size;
mediaid=0xF8;
/* DOSBox-X: to please certain 32-bit drivers like Windows 3.1 WDCTRL, or to emulate older h/w configurations,
* we allow the user or script to specify the number of reserved cylinders. older BIOSes were known
* to subtract 1 or 2 additional cylinders from the total in the fixed disk param table. the -reservecyl
* option allows the number we subtract from the total in INT 13H to be set */
cmd->FindString("-reservecyl",reservecyl,true);
if (reservecyl != "") reserved_cylinders = atoi(reservecyl.c_str());
/* DOSBox-X: we allow "-ide" to allow controlling which IDE controller and slot to attach the hard disk/CD-ROM to */
cmd->FindString("-ide",ideattach,true);
@ -2306,6 +2314,7 @@ public:
newImage = new imageDisk(newDisk, (Bit8u *)temp_line.c_str(), imagesize, (imagesize > 2880));
if(imagesize>2880) newImage->Set_Geometry(sizes[2],sizes[3],sizes[1],sizes[0]);
if (reserved_cylinders > 0) newImage->Set_Reserved_Cylinders(reserved_cylinders);
}
} else {
WriteOut(MSG_Get("PROGRAM_IMGMOUNT_TYPE_UNSUPPORTED"),type.c_str());

View File

@ -201,11 +201,20 @@ Bit8u imageDisk::Write_AbsoluteSector(Bit32u sectnum, void *data) {
}
void imageDisk::Set_Reserved_Cylinders(Bitu resCyl) {
reserved_cylinders = resCyl;
}
Bit32u imageDisk::Get_Reserved_Cylinders() {
return reserved_cylinders;
}
imageDisk::imageDisk(FILE *imgFile, Bit8u *imgName, Bit32u imgSizeK, bool isHardDisk) {
heads = 0;
cylinders = 0;
sectors = 0;
sector_size = 512;
reserved_cylinders = 0;
diskimg = imgFile;
memset(diskname,0,512);
@ -519,6 +528,15 @@ static Bitu INT13_DiskHandler(void) {
else tmpcyl--; // cylinder count -> max cylinder
if (tmpheads==0) LOG(LOG_BIOS,LOG_ERROR)("INT13 DrivParm: head count zero!");
else tmpheads--; // head count -> max head
/* older BIOSes were known to subtract 1 or 2 additional "reserved" cylinders.
* some code, such as Windows 3.1 WDCTRL, might assume that fact. emulate that here */
{
Bit32u reserv = imageDiskList[drivenum]->Get_Reserved_Cylinders();
if (tmpcyl > reserv) tmpcyl -= reserv;
else tmpcyl = 0;
}
reg_ch = (Bit8u)(tmpcyl & 0xff);
reg_cl = (Bit8u)(((tmpcyl >> 2) & 0xc0) | (tmpsect & 0x3f));
reg_dh = (Bit8u)tmpheads;