diff --git a/src/dos/cdrom.h b/src/dos/cdrom.h index bad8406b..39268232 100644 --- a/src/dos/cdrom.h +++ b/src/dos/cdrom.h @@ -169,6 +169,7 @@ public: bool ReadSectors (PhysPt buffer, bool raw, unsigned long sector, unsigned long num); bool LoadUnloadMedia (bool unload); bool ReadSector (Bit8u *buffer, bool raw, unsigned long sector); + bool HasDataTrack (void); static CDROM_Interface_Image* images[26]; @@ -202,6 +203,7 @@ static struct imagePlayer { static int refCount; std::vector tracks; +typedef std::vector::iterator track_it; std::string mcn; Bit8u subUnit; }; diff --git a/src/dos/cdrom_image.cpp b/src/dos/cdrom_image.cpp index 5cf0b764..1d035ee2 100644 --- a/src/dos/cdrom_image.cpp +++ b/src/dos/cdrom_image.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: cdrom_image.cpp,v 1.16 2007-06-12 20:22:08 c2woody Exp $ */ +/* $Id: cdrom_image.cpp,v 1.17 2007-08-22 11:54:35 qbix79 Exp $ */ #include #include @@ -261,7 +261,7 @@ bool CDROM_Interface_Image::ReadSectors(PhysPt buffer, bool raw, unsigned long s MEM_BlockWrite(buffer, buf, buflen); delete[] buf; - + return success; } @@ -294,7 +294,7 @@ bool CDROM_Interface_Image::ReadSector(Bit8u *buffer, bool raw, unsigned long se if (tracks[track].sectorSize != RAW_SECTOR_SIZE && raw) return false; if (tracks[track].sectorSize == RAW_SECTOR_SIZE && !tracks[track].mode2 && !raw) seek += 16; if (tracks[track].mode2 && !raw) seek += 24; - + return tracks[track].file->read(buffer, seek, length); } @@ -521,7 +521,7 @@ bool CDROM_Interface_Image::LoadCueSheet(char *cuefile) track.length = 0; track.file = NULL; if(!AddTrack(track, shift, 0, totalPregap, 0)) return false; - + return true; } @@ -575,6 +575,16 @@ bool CDROM_Interface_Image::AddTrack(Track &curr, int &shift, int prestart, int return true; } +bool CDROM_Interface_Image::HasDataTrack(void) +{ + //Data track has attribute 0x40 + for(track_it it = tracks.begin(); it != tracks.end(); it++) { + if ((*it).attr == 0x40) return true; + } + return false; +} + + bool CDROM_Interface_Image::GetRealFileName(string &filename, string &pathname) { // check if file exists diff --git a/src/dos/drive_iso.cpp b/src/dos/drive_iso.cpp index 9ad4a3ca..b339e003 100644 --- a/src/dos/drive_iso.cpp +++ b/src/dos/drive_iso.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: drive_iso.cpp,v 1.20 2007-06-15 19:05:48 c2woody Exp $ */ +/* $Id: drive_iso.cpp,v 1.21 2007-08-22 11:54:35 qbix79 Exp $ */ #include #include @@ -182,7 +182,36 @@ isoDrive::isoDrive(char driveLetter, const char *fileName, Bit8u mediaid, int &e //Remove trailing dot. if((labelPos > 0) && (discLabel[labelPos - 1] == '.')) discLabel[labelPos - 1] = 0; - } else error = 6; + } 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; + + } else error = 6; //Corrupt image } } @@ -530,13 +559,19 @@ int isoDrive :: readDirEntry(isoDirEntry *de, Bit8u *data) bool isoDrive :: loadImage() { isoPVD pvd; + dataCD = false; readSector((Bit8u*)(&pvd), ISO_FIRST_VD); if (pvd.type != 1 || strncmp((char*)pvd.standardIdent, "CD001", 5) || pvd.version != 1) return false; - return (readDirEntry(&this->rootEntry, pvd.rootEntry)>0); + if (readDirEntry(&this->rootEntry, pvd.rootEntry)>0) { + dataCD = true; + return true; + } + return false; } bool isoDrive :: lookup(isoDirEntry *de, const char *path) { + if (!dataCD) return false; *de = this->rootEntry; if (!strcmp(path, "")) return true; diff --git a/src/dos/drives.h b/src/dos/drives.h index 371cb01b..b80e1ac2 100644 --- a/src/dos/drives.h +++ b/src/dos/drives.h @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: drives.h,v 1.37 2007-06-14 08:23:46 qbix79 Exp $ */ +/* $Id: drives.h,v 1.38 2007-08-22 11:54:35 qbix79 Exp $ */ #ifndef _DRIVES_H__ #define _DRIVES_H__ @@ -357,6 +357,7 @@ private: Bit8u data[ISO_FRAMESIZE]; } sectorHashEntries[ISO_MAX_HASH_TABLE_SIZE]; + bool dataCD; isoDirEntry rootEntry; Bit8u mediaid; char fileName[CROSS_LEN];