1
0
Fork 0

Emulate a trailing dot on volume labels of 8 characters when on a cdrom drive. mscdex weirdness. Fixes Fifa96 cdrom detection.

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3033
This commit is contained in:
Peter Veenstra 2007-11-01 12:15:34 +00:00
parent 1b2e2b541e
commit ac66214dab
7 changed files with 51 additions and 77 deletions

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: dos_system.h,v 1.40 2007-06-13 07:25:14 qbix79 Exp $ */
/* $Id: dos_system.h,v 1.41 2007-11-01 12:15:34 qbix79 Exp $ */
#ifndef DOSBOX_DOS_SYSTEM_H
#define DOSBOX_DOS_SYSTEM_H
@ -148,7 +148,7 @@ public:
void DeleteEntry (const char* path, bool ignoreLastDir = false);
void EmptyCache (void);
void SetLabel (const char* name,bool allowupdate=true);
void SetLabel (const char* name,bool cdrom,bool allowupdate);
char* GetLabel (void) { return label; };
class CFileInfo {

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: dos_programs.cpp,v 1.78 2007-10-14 17:31:52 c2woody Exp $ */
/* $Id: dos_programs.cpp,v 1.79 2007-11-01 12:15:34 qbix79 Exp $ */
#include "dosbox.h"
#include <stdlib.h>
@ -128,6 +128,7 @@ public:
std::string type="dir";
cmd->FindString("-t",type,true);
bool iscdrom = (type =="cdrom"); //Used for mscdex bug cdrom label name emulation
if (type=="floppy" || type=="dir" || type=="cdrom") {
Bit16u sizes[4];
Bit8u mediaid;
@ -297,16 +298,16 @@ public:
mem_writeb(Real2Phys(dos.tables.mediaid)+(drive-'A')*2,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(),false);
if (cmd->FindString("-label",label,true)) newdrive->dirCache.SetLabel(label.c_str(),iscdrom,false);
/* For hard drives set the label to DRIVELETTER_Drive.
* For floppy drives set the label to DRIVELETTER_Floppy.
* This way every drive except cdroms should get a label.*/
else if(type == "dir") {
label = drive; label += "_DRIVE";
newdrive->dirCache.SetLabel(label.c_str(),true);
newdrive->dirCache.SetLabel(label.c_str(),iscdrom,true);
} else if(type == "floppy") {
label = drive; label += "_FLOPPY";
newdrive->dirCache.SetLabel(label.c_str(),true);
newdrive->dirCache.SetLabel(label.c_str(),iscdrom,true);
}
return;
showusage:
@ -1179,7 +1180,7 @@ public:
WriteOut(MSG_Get("PROGRAM_IMGMOUNT_MOUNT_NUMBER"),drive-'0',temp_line.c_str());
}
// check if volume label is given
// check if volume label is given. becareful for cdrom
//if (cmd->FindString("-label",label,true)) newdrive->dirCache.SetLabel(label.c_str());
return;
}

View file

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: drive_cache.cpp,v 1.50 2007-06-12 20:22:08 c2woody Exp $ */
/* $Id: drive_cache.cpp,v 1.51 2007-11-01 12:15:34 qbix79 Exp $ */
#include "drives.h"
#include "dos_inc.h"
@ -115,7 +115,7 @@ void DOS_Drive_Cache::EmptyCache(void)
SetBaseDir(basePath);
};
void DOS_Drive_Cache::SetLabel(const char* vname,bool allowupdate)
void DOS_Drive_Cache::SetLabel(const char* vname,bool cdrom,bool allowupdate)
{
/* allowupdate defaults to true. if mount sets a label then allowupdate is
* false and will this function return at once after the first call.
@ -123,25 +123,7 @@ void DOS_Drive_Cache::SetLabel(const char* vname,bool allowupdate)
if(!this->updatelabel) return;
this->updatelabel = allowupdate;
Bitu togo = 8;
Bitu vnamePos = 0;
Bitu labelPos = 0;
bool point = false;
while (togo>0) {
if (vname[vnamePos]==0) break;
if (!point && (vname[vnamePos]=='.')) { togo=4; point=true; }
label[labelPos] = toupper(vname[vnamePos]);
labelPos++; vnamePos++;
togo--;
if ((togo==0) && !point) {
if (vname[vnamePos]=='.') vnamePos++;
label[labelPos]='.'; labelPos++; point=true; togo=3;
}
};
label[labelPos]=0;
//Remove trailing dot.
if((labelPos > 0) && (label[labelPos-1] == '.'))
label[labelPos-1]=0;
Set_Label(vname,label,cdrom);
LOG(LOG_DOSMISC,LOG_NORMAL)("DIRCACHE: Set volume label to %s",label);
};

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: drive_iso.cpp,v 1.21 2007-08-22 11:54:35 qbix79 Exp $ */
/* $Id: drive_iso.cpp,v 1.22 2007-11-01 12:15:34 qbix79 Exp $ */
#include <cctype>
#include <cstring>
@ -161,56 +161,16 @@ isoDrive::isoDrive(char driveLetter, const char *fileName, Bit8u mediaid, int &e
this->mediaid = mediaid;
char buffer[32] = { 0 };
if (!MSCDEX_GetVolumeName(subUnit, buffer)) strcpy(buffer, "");
Set_Label(buffer,discLabel,true);
//Code Copied from drive_cache. (convert mscdex label to a dos 8.3 file)
Bitu togo = 8;
Bitu bufPos = 0;
Bitu labelPos = 0;
bool point = false;
while (togo>0) {
if (buffer[bufPos]==0) break;
if (!point && (buffer[bufPos]=='.')) { togo=4; point=true; }
discLabel[labelPos] = toupper(buffer[bufPos]);
labelPos++; bufPos++;
togo--;
if ((togo==0) && !point) {
if (buffer[bufPos]=='.') bufPos++;
discLabel[labelPos]='.'; labelPos++; point=true; togo=3;
}
};
discLabel[labelPos]=0;
//Remove trailing dot.
if((labelPos > 0) && (discLabel[labelPos - 1] == '.'))
discLabel[labelPos - 1] = 0;
} else if (CDROM_Interface_Image::images[subUnit]->HasDataTrack() == false) { //Audio only cdrom
strcpy(info, "isoDrive ");
strcat(info, fileName);
this->driveLetter = driveLetter;
this->mediaid = mediaid;
char buffer[32] = { 0 };
strcpy(buffer, "Audio CD");
//Code Copied from drive_cache. (convert mscdex label to a dos 8.3 file)
Bitu togo = 8;
Bitu bufPos = 0;
Bitu labelPos = 0;
bool point = false;
while (togo>0) {
if (buffer[bufPos]==0) break;
if (!point && (buffer[bufPos]=='.')) { togo=4; point=true; }
discLabel[labelPos] = toupper(buffer[bufPos]);
labelPos++; bufPos++;
togo--;
if ((togo==0) && !point) {
if (buffer[bufPos]=='.') bufPos++;
discLabel[labelPos]='.'; labelPos++; point=true; togo=3;
}
};
discLabel[labelPos]=0;
//Remove trailing dot.
if((labelPos > 0) && (discLabel[labelPos - 1] == '.'))
discLabel[labelPos - 1] = 0;
strcpy(buffer, "Audio_CD");
Set_Label(buffer,discLabel,true);
} else error = 6; //Corrupt image
}
}

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: drive_local.cpp,v 1.75 2007-06-13 07:25:14 qbix79 Exp $ */
/* $Id: drive_local.cpp,v 1.76 2007-11-01 12:15:34 qbix79 Exp $ */
#include <stdio.h>
#include <stdlib.h>
@ -565,7 +565,7 @@ cdromDrive::cdromDrive(const char driveLetter, const char * startdir,Bit16u _byt
this->driveLetter = driveLetter;
// Get Volume Label
char name[32];
if (MSCDEX_GetVolumeName(subUnit,name)) dirCache.SetLabel(name);
if (MSCDEX_GetVolumeName(subUnit,name)) dirCache.SetLabel(name,true,true);
};
bool cdromDrive::FileOpen(DOS_File * * file,char * name,Bit32u flags)
@ -625,7 +625,7 @@ bool cdromDrive::FindFirst(char * _dir,DOS_DTA & dta,bool fcb_findfirst)
dirCache.EmptyCache();
// Get Volume Label
char name[32];
if (MSCDEX_GetVolumeName(subUnit,name)) dirCache.SetLabel(name);
if (MSCDEX_GetVolumeName(subUnit,name)) dirCache.SetLabel(name,true,true);
}
return localDrive::FindFirst(_dir,dta);
};
@ -637,7 +637,7 @@ void cdromDrive::SetDir(const char* path)
dirCache.EmptyCache();
// Get Volume Label
char name[32];
if (MSCDEX_GetVolumeName(subUnit,name)) dirCache.SetLabel(name);
if (MSCDEX_GetVolumeName(subUnit,name)) dirCache.SetLabel(name,true,true);
}
localDrive::SetDir(path);
};

View file

@ -16,6 +16,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: drives.cpp,v 1.12 2007-11-01 12:15:34 qbix79 Exp $ */
#include "dosbox.h"
#include "dos_system.h"
#include "drives.h"
@ -73,6 +75,34 @@ checkext:
return true;
}
void Set_Label(char const * const input, char * const output, bool cdrom) {
Bitu togo = 8;
Bitu vnamePos = 0;
Bitu labelPos = 0;
bool point = false;
//spacepadding the filenamepart to include spaces after the terminating zero is more closely to the specs. (not doing this now)
// HELLO\0' '' '
while (togo > 0) {
if (input[vnamePos]==0) break;
if (!point && (input[vnamePos]=='.')) { togo=4; point=true; }
output[labelPos] = toupper(input[vnamePos]);
labelPos++; vnamePos++;
togo--;
if ((togo==0) && !point) {
if (input[vnamePos]=='.') vnamePos++;
output[labelPos]='.'; labelPos++; point=true; togo=3;
}
};
output[labelPos]=0;
//Remove trailing dot. except when on cdrom and filename is exactly 8 (9 including the dot) letters. MSCDEX feature/bug (fifa96 cdrom detection)
if((labelPos > 0) && (output[labelPos-1] == '.') && !(cdrom && labelPos ==9))
output[labelPos-1] = 0;
}
DOS_Drive::DOS_Drive() {

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: drives.h,v 1.38 2007-08-22 11:54:35 qbix79 Exp $ */
/* $Id: drives.h,v 1.39 2007-11-01 12:15:34 qbix79 Exp $ */
#ifndef _DRIVES_H__
#define _DRIVES_H__
@ -28,6 +28,7 @@
#include "bios.h" /* for fatDrive */
bool WildFileCmp(const char * file, const char * wild);
void Set_Label(char const * const input, char * const output, bool cdrom);
class DriveManager {
public: