1
0
Fork 0

Make Media ID table relative to DPB table. Fixes Hattrick by Ikarion.

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4116
This commit is contained in:
ripsaw8080 2018-06-12 20:52:08 +00:00
parent ff8d4f287f
commit 1afaf28921
5 changed files with 15 additions and 12 deletions

View file

@ -494,10 +494,10 @@ static Bitu DOS_21Handler(void) {
Bit8u drive=reg_dl;
if (!drive || reg_ah==0x1f) drive = DOS_GetDefaultDrive();
else drive--;
if (Drives[drive]) {
if (drive < DOS_DRIVES && Drives[drive] && !Drives[drive]->isRemovable()) {
reg_al = 0x00;
SegSet16(ds,dos.tables.dpb);
reg_bx = drive;//Faking only the first entry (that is the driveletter)
reg_bx = drive*5;//Faking the first entry (drive number) and media id
LOG(LOG_DOSMISC,LOG_ERROR)("Get drive parameter block.");
} else {
reg_al=0xff;

View file

@ -1281,14 +1281,14 @@ bool DOS_FileExists(char const * const name) {
bool DOS_GetAllocationInfo(Bit8u drive,Bit16u * _bytes_sector,Bit8u * _sectors_cluster,Bit16u * _total_clusters) {
if (!drive) drive = DOS_GetDefaultDrive();
else drive--;
if (drive >= DOS_DRIVES || !Drives[drive]) {
if (drive >= DOS_DRIVES || !Drives[drive] || Drives[drive]->isRemovable()) {
DOS_SetError(DOSERR_INVALID_DRIVE);
return false;
}
Bit16u _free_clusters;
Drives[drive]->AllocationInfo(_bytes_sector,_sectors_cluster,_total_clusters,&_free_clusters);
SegSet16(ds,RealSeg(dos.tables.mediaid));
reg_bx=RealOff(dos.tables.mediaid+drive*2);
reg_bx=RealOff(dos.tables.mediaid+drive*5);
return true;
}

View file

@ -90,7 +90,7 @@ static bool DOS_MultiplexFunctions(void) {
mem_writew(sftptr+sftofs+0x02,(Bit16u)(Files[reg_bx]->flags&3)); // file open mode
mem_writeb(sftptr+sftofs+0x04,(Bit8u)(Files[reg_bx]->attr)); // file attribute
mem_writew(sftptr+sftofs+0x05,0x40|drive); // device info word
mem_writed(sftptr+sftofs+0x07,RealMake(dos.tables.dpb,drive)); // dpb of the drive
mem_writed(sftptr+sftofs+0x07,RealMake(dos.tables.dpb,drive*5)); // dpb of the drive
mem_writew(sftptr+sftofs+0x0d,Files[reg_bx]->time); // packed file time
mem_writew(sftptr+sftofs+0x0f,Files[reg_bx]->date); // packed file date
Bit32u curpos=0;

View file

@ -126,6 +126,7 @@ public:
switch (DriveManager::UnmountDrive(i_drive)) {
case 0:
Drives[i_drive] = 0;
mem_writeb(Real2Phys(dos.tables.mediaid)+i_drive*5,0);
if(i_drive == DOS_GetDefaultDrive())
DOS_SetDrive(ZDRIVE_NUM);
WriteOut(MSG_Get("PROGRAM_MOUNT_UMOUNT_SUCCESS"),umount[0]);
@ -394,7 +395,7 @@ public:
if (!newdrive) E_Exit("DOS:Can't create drive");
Drives[drive-'A']=newdrive;
/* Set the correct media byte in the table */
mem_writeb(Real2Phys(dos.tables.mediaid)+(drive-'A')*2,newdrive->GetMediaByte());
mem_writeb(Real2Phys(dos.tables.mediaid)+(drive-'A')*5,newdrive->GetMediaByte());
WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_2"),drive,newdrive->GetInfo());
/* check if volume label is given and don't allow it to updated in the future */
if (cmd->FindString("-label",label,true)) newdrive->dirCache.SetLabel(label.c_str(),iscdrom,false);
@ -1314,7 +1315,7 @@ public:
DriveManager::InitializeDrive(drive - 'A');
// Set the correct media byte in the table
mem_writeb(Real2Phys(dos.tables.mediaid) + (drive - 'A') * 2, mediaid);
mem_writeb(Real2Phys(dos.tables.mediaid) + (drive - 'A') * 5, mediaid);
/* Command uses dta so set it to our internal dta */
RealPt save_dta = dos.dta();
@ -1392,7 +1393,7 @@ public:
DriveManager::InitializeDrive(drive - 'A');
// Set the correct media byte in the table
mem_writeb(Real2Phys(dos.tables.mediaid) + (drive - 'A') * 2, mediaid);
mem_writeb(Real2Phys(dos.tables.mediaid) + (drive - 'A') * 5, mediaid);
// Print status message (success)
WriteOut(MSG_Get("MSCDEX_SUCCESS"));

View file

@ -73,10 +73,8 @@ static Bit8u country_info[0x22] = {
void DOS_SetupTables(void) {
Bit16u seg;Bitu i;
dos.tables.mediaid=RealMake(DOS_GetMemory(4),0);
dos.tables.tempdta=RealMake(DOS_GetMemory(4),0);
dos.tables.tempdta_fcbdelete=RealMake(DOS_GetMemory(4),0);
for (i=0;i<DOS_DRIVES;i++) mem_writew(Real2Phys(dos.tables.mediaid)+i*2,0);
/* Create the DOS Info Block */
dos_infoblock.SetLocation(DOS_INFOBLOCK_SEG); //c2woody
@ -150,8 +148,12 @@ void DOS_SetupTables(void) {
dos_infoblock.SetFCBTable(RealMake(seg,0));
/* Create a fake DPB */
dos.tables.dpb=DOS_GetMemory(2);
for(Bitu d=0;d<26;d++) real_writeb(dos.tables.dpb,d,d);
dos.tables.dpb=DOS_GetMemory(10);
dos.tables.mediaid=RealMake(dos.tables.dpb,0x17); //Media ID offset in DPB
for (i=0;i<DOS_DRIVES;i++) {
real_writeb(dos.tables.dpb,i*5,i);
mem_writew(Real2Phys(dos.tables.mediaid)+i*5,0);
}
/* Create a fake disk buffer head */
seg=DOS_GetMemory(6);