From d7b46afcd49703170f43df38293847c22db16f59 Mon Sep 17 00:00:00 2001 From: Allofich <19624336+Allofich@users.noreply.github.com> Date: Mon, 5 Oct 2020 00:36:26 +0900 Subject: [PATCH] SVN r4267 (partial) Fix Bit8u instead of char weirdness for imageDisk Give the code that moves the Z drive its own function for readability. Give size arrays default values again for warning program. (IMGMOUNT rewrite part of original commit skipped due to code conflict) --- README.video | 2 +- include/bios_disk.h | 2 +- patch-integration/Skipped SVN commits.txt | 1 + src/dos/dos_programs.cpp | 81 ++++++++++++----------- src/dos/drive_fat.cpp | 2 +- src/ints/bios_disk.cpp | 2 +- src/ints/qcow2_disk.cpp | 2 +- 7 files changed, 48 insertions(+), 44 deletions(-) diff --git a/README.video b/README.video index 5b4f66511..2afeaf2a3 100644 --- a/README.video +++ b/README.video @@ -32,4 +32,4 @@ A: 1. Start DOSBox like this: dosbox -startmapper selected. Q: The colours are wrong and I'm using 64 bit windows -A: Look here: http://vogons.zetafleet.com/viewtopic.php?t=12133 +A: Look here: https://www.vogons.org/viewtopic.php?t=12133 diff --git a/include/bios_disk.h b/include/bios_disk.h index e432540fa..a4de3bdd9 100644 --- a/include/bios_disk.h +++ b/include/bios_disk.h @@ -74,7 +74,7 @@ public: virtual void Get_Geometry(uint32_t * getHeads, uint32_t *getCyl, uint32_t *getSect, uint32_t *getSectSize); virtual uint8_t GetBiosType(void); virtual uint32_t getSectSize(void); - imageDisk(FILE *imgFile, uint8_t *imgName, uint32_t imgSizeK, bool isHardDisk); + imageDisk(FILE *imgFile, const char *imgName, uint32_t imgSizeK, bool isHardDisk); imageDisk(FILE* diskimg, const char* diskName, uint32_t cylinders, uint32_t heads, uint32_t sectors, uint32_t sector_size, bool hardDrive); virtual ~imageDisk() { if(diskimg != NULL) { fclose(diskimg); diskimg=NULL; } }; diff --git a/patch-integration/Skipped SVN commits.txt b/patch-integration/Skipped SVN commits.txt index ff4cb494f..cd91b84b7 100644 --- a/patch-integration/Skipped SVN commits.txt +++ b/patch-integration/Skipped SVN commits.txt @@ -30,6 +30,7 @@ Commit#: Reason for skipping: 4229 Conflict 4235 Conflict 4245 Conflict +4267 IMGMOUNT rewrite part skipped due to conflict (Status for commits in this interval needs to be added) diff --git a/src/dos/dos_programs.cpp b/src/dos/dos_programs.cpp index 5e5fe5ebf..2c5b89205 100644 --- a/src/dos/dos_programs.cpp +++ b/src/dos/dos_programs.cpp @@ -723,6 +723,43 @@ void MenuBrowseProgramFile() { class MOUNT : public Program { public: std::vector options; + void Move_Z(char new_z) { + char newz_drive = (char)toupper(new_z); + int i_newz = (int)newz_drive - (int)'A'; + if (i_newz >= 0 && i_newz < DOS_DRIVES - 1 && !Drives[i_newz]) { + ZDRIVE_NUM = i_newz; + /* remap drives */ + Drives[i_newz] = Drives[25]; + Drives[25] = 0; + DOS_EnableDriveMenu(i_newz + 'A'); + DOS_EnableDriveMenu(25 + 'A'); + if (!first_shell) return; //Should not be possible + /* Update environment */ + std::string line = ""; + char ppp[2] = { newz_drive,0 }; + std::string tempenv = ppp; tempenv += ":\\"; + if (first_shell->GetEnvStr("PATH", line)) { + std::string::size_type idx = line.find('='); + std::string value = line.substr(idx + 1, std::string::npos); + while ((idx = value.find("Z:\\")) != std::string::npos || + (idx = value.find("z:\\")) != std::string::npos) + value.replace(idx, 3, tempenv); + line = value; + } + if (!line.size()) line = tempenv; + first_shell->SetEnv("PATH", line.c_str()); + tempenv += "COMMAND.COM"; + first_shell->SetEnv("COMSPEC", tempenv.c_str()); + + /* Update batch file if running from Z: (very likely: autoexec) */ + if (first_shell->bf) { + std::string& name = first_shell->bf->filename; + if (name.length() > 2 && name[0] == 'Z' && name[1] == ':') name[0] = newz_drive; + } + /* Change the active drive */ + if (DOS_GetDefaultDrive() == 25) DOS_SetDrive(i_newz); + } + } void ListMounts(void) { char name[DOS_NAMELENGTH_ASCII],lname[LFN_NAMELENGTH]; uint32_t size;uint16_t date;uint16_t time;uint8_t attr; @@ -816,41 +853,7 @@ public: /* Check for moving Z: */ /* Only allowing moving it once. It is merely a convenience added for the wine team */ if (ZDRIVE_NUM == 25 && cmd->FindString("-z", newz,false)) { - newz[0] = toupper(newz[0]); - int i_newz = (int)newz[0] - (int)'A'; - if (i_newz >= 0 && i_newz < DOS_DRIVES-1 && !Drives[i_newz]) { - ZDRIVE_NUM = i_newz; - /* remap drives */ - Drives[i_newz] = Drives[25]; - Drives[25] = 0; - DOS_EnableDriveMenu(i_newz+'A'); - DOS_EnableDriveMenu(25+'A'); - if (!first_shell) return; //Should not be possible - /* Update environment */ - std::string line = ""; - char ppp[2] = {newz[0],0}; - std::string tempenv = ppp; tempenv += ":\\"; - if (first_shell->GetEnvStr("PATH",line)){ - std::string::size_type idx = line.find('='); - std::string value = line.substr(idx +1 , std::string::npos); - while ( (idx = value.find("Z:\\")) != std::string::npos || - (idx = value.find("z:\\")) != std::string::npos ) - value.replace(idx,3,tempenv); - line = value; - } - if (!line.size()) line = tempenv; - first_shell->SetEnv("PATH",line.c_str()); - tempenv += "COMMAND.COM"; - first_shell->SetEnv("COMSPEC",tempenv.c_str()); - - /* Update batch file if running from Z: (very likely: autoexec) */ - if(first_shell->bf) { - std::string &name = first_shell->bf->filename; - if(name.length() >2 && name[0] == 'Z' && name[1] == ':') name[0] = newz[0]; - } - /* Change the active drive */ - if (DOS_GetDefaultDrive() == 25) DOS_SetDrive(i_newz); - } + Move_Z(newz[0]); return; } /* Show list of cdroms */ @@ -884,9 +887,9 @@ public: std::transform(type.begin(), type.end(), type.begin(), ::tolower); bool iscdrom = (type =="cdrom"); //Used for mscdex bug cdrom label name emulation if (type=="floppy" || type=="dir" || type=="cdrom" || type =="overlay") { - uint16_t sizes[4]; + uint16_t sizes[4] = { 0 }; uint8_t mediaid; - std::string str_size; + std::string str_size = ""; if (type=="floppy") { str_size="512,1,2880,2880"; mediaid=0xF0; /* Floppy 1.44 media */ @@ -1748,7 +1751,7 @@ public: newDiskSwap[i] = new imageDiskNFD(usefile, (uint8_t *)fname, floppysize, false, 1); } else { - newDiskSwap[i] = new imageDisk(usefile, (uint8_t *)fname, floppysize, false); + newDiskSwap[i] = new imageDisk(usefile, fname, floppysize, false); } newDiskSwap[i]->Addref(); if (newDiskSwap[i]->active && !newDiskSwap[i]->hardDrive) incrementFDD(); //moved from imageDisk constructor @@ -5400,7 +5403,7 @@ private: sectors = (uint64_t)ftello64(newDisk) / (uint64_t)sizes[0]; imagesize = (uint32_t)(sectors / 2); /* orig. code wants it in KBs */ setbuf(newDisk, NULL); - newImage = new imageDisk(newDisk, (uint8_t *)fname, imagesize, (imagesize > 2880)); + newImage = new imageDisk(newDisk, fname, imagesize, (imagesize > 2880)); } } diff --git a/src/dos/drive_fat.cpp b/src/dos/drive_fat.cpp index e35ef828c..c97008cab 100644 --- a/src/dos/drive_fat.cpp +++ b/src/dos/drive_fat.cpp @@ -1287,7 +1287,7 @@ fatDrive::fatDrive(const char* sysFilename, uint32_t bytesector, uint32_t cylsec else { fseeko64(diskfile, 0L, SEEK_END); filesize = (uint32_t)(ftello64(diskfile) / 1024L); - loadedDisk = new imageDisk(diskfile, (uint8_t *)fname, filesize, (filesize > 2880)); + loadedDisk = new imageDisk(diskfile, fname, filesize, (filesize > 2880)); } } diff --git a/src/ints/bios_disk.cpp b/src/ints/bios_disk.cpp index 79a9a39a7..c8809e75b 100644 --- a/src/ints/bios_disk.cpp +++ b/src/ints/bios_disk.cpp @@ -428,7 +428,7 @@ typedef struct { }NHD_FILE_HEAD,*LP_NHD_FILE_HEAD; #pragma pack(pop) -imageDisk::imageDisk(FILE* imgFile, uint8_t* imgName, uint32_t imgSizeK, bool isHardDisk) : diskSizeK(imgSizeK), diskimg(imgFile), image_length((uint64_t)imgSizeK * 1024) { +imageDisk::imageDisk(FILE* imgFile, const char* imgName, uint32_t imgSizeK, bool isHardDisk) : diskSizeK(imgSizeK), diskimg(imgFile), image_length((uint64_t)imgSizeK * 1024) { if (imgName != NULL) diskname = (const char*)imgName; diff --git a/src/ints/qcow2_disk.cpp b/src/ints/qcow2_disk.cpp index 544fa20d6..914aedfa3 100644 --- a/src/ints/qcow2_disk.cpp +++ b/src/ints/qcow2_disk.cpp @@ -433,7 +433,7 @@ using namespace std; //Public Constructor. - QCow2Disk::QCow2Disk(QCow2Image::QCow2Header& qcow2Header, FILE *qcow2File, uint8_t *imgName, uint32_t imgSizeK, uint32_t sectorSizeBytes, bool isHardDisk) : imageDisk(qcow2File, imgName, imgSizeK, isHardDisk), qcowImage(qcow2Header, qcow2File, (const char*) imgName, sectorSizeBytes){ + QCow2Disk::QCow2Disk(QCow2Image::QCow2Header& qcow2Header, FILE *qcow2File, uint8_t *imgName, uint32_t imgSizeK, uint32_t sectorSizeBytes, bool isHardDisk) : imageDisk(qcow2File, (const char*)imgName, imgSizeK, isHardDisk), qcowImage(qcow2Header, qcow2File, (const char*) imgName, sectorSizeBytes){ }