From 1afaf2892107501e25e6d4ef58c0d863cb5b8b51 Mon Sep 17 00:00:00 2001 From: ripsaw8080 Date: Tue, 12 Jun 2018 20:52:08 +0000 Subject: [PATCH] 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 --- src/dos/dos.cpp | 4 ++-- src/dos/dos_files.cpp | 4 ++-- src/dos/dos_misc.cpp | 2 +- src/dos/dos_programs.cpp | 7 ++++--- src/dos/dos_tables.cpp | 10 ++++++---- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/dos/dos.cpp b/src/dos/dos.cpp index 2864fb02..897b6880 100644 --- a/src/dos/dos.cpp +++ b/src/dos/dos.cpp @@ -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; diff --git a/src/dos/dos_files.cpp b/src/dos/dos_files.cpp index fb4992bb..49d7eeea 100644 --- a/src/dos/dos_files.cpp +++ b/src/dos/dos_files.cpp @@ -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; } diff --git a/src/dos/dos_misc.cpp b/src/dos/dos_misc.cpp index 182cf239..ed180b3a 100644 --- a/src/dos/dos_misc.cpp +++ b/src/dos/dos_misc.cpp @@ -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; diff --git a/src/dos/dos_programs.cpp b/src/dos/dos_programs.cpp index bb442481..55a9d7fe 100644 --- a/src/dos/dos_programs.cpp +++ b/src/dos/dos_programs.cpp @@ -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")); diff --git a/src/dos/dos_tables.cpp b/src/dos/dos_tables.cpp index 4943593a..5579da44 100644 --- a/src/dos/dos_tables.cpp +++ b/src/dos/dos_tables.cpp @@ -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