From 7156968b477dba13f1422633d88a974de21282d4 Mon Sep 17 00:00:00 2001 From: Wengier Date: Tue, 22 Dec 2020 00:22:09 -0500 Subject: [PATCH] Fix physfs etc --- README.md | 6 +++-- src/dos/dos_files.cpp | 2 +- src/dos/dos_programs.cpp | 2 +- src/dos/drive_local.cpp | 42 +++++++++++++++----------------- src/dos/drives.h | 6 ++++- src/gui/sdlmain.cpp | 6 +++++ src/libs/physfs/physfs_lzmasdk.h | 8 ++++++ 7 files changed, 45 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 3cf3d5e1e..6648494fe 100644 --- a/README.md +++ b/README.md @@ -59,9 +59,11 @@ Although based on the DOSBox project, DOSBox-X is now a separate project because * Support for long filenames and FAT32 disk images (DOS 7+ features) -* Support for printer output, either a real or virtual printer +* Support for TrueType font (TTF) output for text-mode DOS programs -* Support for 3dfx Voodoo chip and Glide emulation +* Support for printing features, either to a real or to a virtual printer + +* Support for 3dfx Voodoo chip and Glide emulation (including Glide wrapper) * Support for cue sheets with FLAC, MP3, WAV, OGG Vorbis and Opus CD-DA tracks diff --git a/src/dos/dos_files.cpp b/src/dos/dos_files.cpp index 0cb782dc9..2e26da3f9 100644 --- a/src/dos/dos_files.cpp +++ b/src/dos/dos_files.cpp @@ -2272,7 +2272,7 @@ void POD_Load_DOS_Files( std::istream& stream ) std::size_t found=str.find(", "); if (found!=std::string::npos) str=str.substr(0,found); - Drives[lcv]=new physfsDrive((":"+str+"\\").c_str(),lalloc.bytes_sector,lalloc.sectors_cluster,lalloc.total_clusters,lalloc.free_clusters,lalloc.mediaid,options); + Drives[lcv]=new physfsDrive('A'+lcv,(":"+str+"\\").c_str(),lalloc.bytes_sector,lalloc.sectors_cluster,lalloc.total_clusters,lalloc.free_clusters,lalloc.mediaid,options); if (Drives[lcv]) { DOS_EnableDriveMenu('A'+lcv); mem_writeb(Real2Phys(dos.tables.mediaid)+lcv*dos.tables.dpb_size,lalloc.mediaid); diff --git a/src/dos/dos_programs.cpp b/src/dos/dos_programs.cpp index 8dbd75b84..4e6d99f63 100644 --- a/src/dos/dos_programs.cpp +++ b/src/dos/dos_programs.cpp @@ -1177,7 +1177,7 @@ public: #endif } if (is_physfs) { - newdrive=new physfsDrive(temp_line.c_str(),sizes[0],bit8size,sizes[2],sizes[3],mediaid,options); + newdrive=new physfsDrive(drive,temp_line.c_str(),sizes[0],bit8size,sizes[2],sizes[3],mediaid,options); } else if(type == "overlay") { //Ensure that the base drive exists: if (!Drives[drive-'A']) { diff --git a/src/dos/drive_local.cpp b/src/dos/drive_local.cpp index 8f5d73366..8b770947e 100644 --- a/src/dos/drive_local.cpp +++ b/src/dos/drive_local.cpp @@ -2076,9 +2076,12 @@ bool physfsDrive::read_directory_next(void* dirp, char* entry_name, char* entry_ } static uint8_t physfs_used = 0; -physfsDrive::physfsDrive(const char * startdir,uint16_t _bytes_sector,uint8_t _sectors_cluster,uint16_t _total_clusters,uint16_t _free_clusters,uint8_t _mediaid, std::vector &options) +physfsDrive::physfsDrive(const char driveLetter, const char * startdir,uint16_t _bytes_sector,uint8_t _sectors_cluster,uint16_t _total_clusters,uint16_t _free_clusters,uint8_t _mediaid, std::vector &options) :localDrive(startdir,_bytes_sector,_sectors_cluster,_total_clusters,_free_clusters,_mediaid,options) { + this->driveLetter = driveLetter; + this->mountarc = ""; + char mp[3] = {'_', driveLetter, 0}; char newname[CROSS_LEN+1]; strcpy(newname,startdir); CROSS_FILENAME(newname); @@ -2100,13 +2103,19 @@ physfsDrive::physfsDrive(const char * startdir,uint16_t _bytes_sector,uint8_t _s dir[tmp++] = CROSS_FILESPLIT; dir[tmp] = '\0'; } - if (*lastdir && PHYSFS_addToSearchPath(lastdir,true) == 0) { - LOG_MSG("PHYSFS couldn't add '%s': %s",lastdir,PHYSFS_getLastError()); - } + if (*lastdir) { + if (PHYSFS_mount(lastdir,mp,true) == 0) + LOG_MSG("PHYSFS couldn't mount '%s': %s",lastdir,PHYSFS_getLastError()); + else { + if (mountarc.size()) mountarc+=", "; + mountarc+= lastdir; + } + } lastdir = dir; dir = strchr(lastdir+(((lastdir[0]|0x20) >= 'a' && (lastdir[0]|0x20) <= 'z')?2:0),':'); } - strcpy(basedir,lastdir); + strcpy(basedir,"\\"); + strcat(basedir,mp); allocation.bytes_sector=_bytes_sector; allocation.sectors_cluster=_sectors_cluster; @@ -2130,14 +2139,7 @@ physfsDrive::~physfsDrive(void) { } const char *physfsDrive::GetInfo() { - char **files = PHYSFS_getSearchPath(), **list = files; - sprintf(info,"PhysFS directory "); - while (*files != NULL) { - strcat(info,*files++); - strcat(info,", "); - } - if (info[strlen(info)-1]==' '&&info[strlen(info)-2]==',') info[strlen(info)-2]=0; - PHYSFS_freeList(list); + sprintf(info,"PhysFS directory %s", mountarc.c_str()); return info; } @@ -2324,6 +2326,8 @@ bool physfsDrive::isRemovable(void) { } Bits physfsDrive::UnMount(void) { + char mp[3] = {'_', driveLetter, 0}; + PHYSFS_unmount(mp); delete this; return 0; } @@ -2420,24 +2424,18 @@ bool physfsFile::UpdateDateTimeFromHost(void) { } physfscdromDrive::physfscdromDrive(const char driveLetter, const char * startdir,uint16_t _bytes_sector,uint8_t _sectors_cluster,uint16_t _total_clusters,uint16_t _free_clusters,uint8_t _mediaid, int& error, std::vector &options) - :physfsDrive(startdir,_bytes_sector,_sectors_cluster,_total_clusters,_free_clusters,_mediaid,options) + :physfsDrive(driveLetter,startdir,_bytes_sector,_sectors_cluster,_total_clusters,_free_clusters,_mediaid,options) { // Init mscdex error = MSCDEX_AddDrive(driveLetter,startdir,subUnit); + this->driveLetter = driveLetter; // Get Volume Label char name[32]; if (MSCDEX_GetVolumeName(subUnit,name)) dirCache.SetLabel(name,true,true); }; const char *physfscdromDrive::GetInfo() { - char **files = PHYSFS_getSearchPath(), **list = files; - sprintf(info,"PhysFS CDRom "); - while (*files != NULL) { - strcat(info,*files++); - strcat(info,", "); - } - if (info[strlen(info)-1]==' '&&info[strlen(info)-2]==',') info[strlen(info)-1]=info[strlen(info)-2]=0; - PHYSFS_freeList(list); + sprintf(info,"PhysFS CDRom %s", mountarc.c_str()); return info; } diff --git a/src/dos/drives.h b/src/dos/drives.h index 77d951306..29190410c 100644 --- a/src/dos/drives.h +++ b/src/dos/drives.h @@ -119,9 +119,10 @@ protected: class physfsDrive : public localDrive { private: bool isdir(const char *dir); + char driveLetter; public: - physfsDrive(const char * startdir,uint16_t _bytes_sector,uint8_t _sectors_cluster,uint16_t _total_clusters,uint16_t _free_clusters,uint8_t _mediaid, std::vector &options); + physfsDrive(const char driveLetter, const char * startdir,uint16_t _bytes_sector,uint8_t _sectors_cluster,uint16_t _total_clusters,uint16_t _free_clusters,uint8_t _mediaid, std::vector &options); virtual bool FileOpen(DOS_File * * file,const char * name,uint32_t flags); virtual bool FileCreate(DOS_File * * file,const char * name,uint16_t attributes); virtual bool FileUnlink(const char * name); @@ -151,6 +152,9 @@ public: virtual const char *GetInfo(void); Bits UnMount(); virtual ~physfsDrive(void); + +protected: + std::string mountarc; }; #ifdef _MSC_VER diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index 8ae848685..82f69155f 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -3256,6 +3256,12 @@ void setVGADAC() { bool setColors(const char *colorArray, int n) { if (IS_PC98_ARCH) return false; + if (!colorChanged) + for (uint8_t i = 0; i < 0x10; i++) { + altBGR1[i].red=rgbColors[i].red; + altBGR1[i].green=rgbColors[i].green; + altBGR1[i].blue=rgbColors[i].blue; + } const char * nextRGB = colorArray; uint8_t * altPtr = (uint8_t *)altBGR1; int rgbVal[3] = {-1,-1,-1}; diff --git a/src/libs/physfs/physfs_lzmasdk.h b/src/libs/physfs/physfs_lzmasdk.h index 8bc3de6c8..239f8f0d1 100644 --- a/src/libs/physfs/physfs_lzmasdk.h +++ b/src/libs/physfs/physfs_lzmasdk.h @@ -1253,7 +1253,15 @@ static void MY_FAST_CALL CrcGenerateTable() #endif } else if (p[0] != 1 || p[1] != 2) + #if CRC_NUM_TABLES < 4 g_CrcUpdate = CrcUpdateT1; + #else + g_CrcUpdate = CrcUpdateT4; + #ifdef MY_CPU_X86_OR_AMD64 + if (!CPU_Is_InOrder()) + g_CrcUpdate = CrcUpdateT8; + #endif + #endif else #endif {