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)
This commit is contained in:
Allofich
2020-10-05 00:36:26 +09:00
parent e89b4a232a
commit d7b46afcd4
7 changed files with 48 additions and 44 deletions

View File

@@ -32,4 +32,4 @@ A: 1. Start DOSBox like this: dosbox -startmapper
selected. selected.
Q: The colours are wrong and I'm using 64 bit windows 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

View File

@@ -74,7 +74,7 @@ public:
virtual void Get_Geometry(uint32_t * getHeads, uint32_t *getCyl, uint32_t *getSect, uint32_t *getSectSize); virtual void Get_Geometry(uint32_t * getHeads, uint32_t *getCyl, uint32_t *getSect, uint32_t *getSectSize);
virtual uint8_t GetBiosType(void); virtual uint8_t GetBiosType(void);
virtual uint32_t getSectSize(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); 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; } }; virtual ~imageDisk() { if(diskimg != NULL) { fclose(diskimg); diskimg=NULL; } };

View File

@@ -30,6 +30,7 @@ Commit#: Reason for skipping:
4229 Conflict 4229 Conflict
4235 Conflict 4235 Conflict
4245 Conflict 4245 Conflict
4267 IMGMOUNT rewrite part skipped due to conflict
(Status for commits in this interval needs to be added) (Status for commits in this interval needs to be added)

View File

@@ -723,6 +723,43 @@ void MenuBrowseProgramFile() {
class MOUNT : public Program { class MOUNT : public Program {
public: public:
std::vector<std::string> options; std::vector<std::string> 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) { void ListMounts(void) {
char name[DOS_NAMELENGTH_ASCII],lname[LFN_NAMELENGTH]; char name[DOS_NAMELENGTH_ASCII],lname[LFN_NAMELENGTH];
uint32_t size;uint16_t date;uint16_t time;uint8_t attr; uint32_t size;uint16_t date;uint16_t time;uint8_t attr;
@@ -816,41 +853,7 @@ public:
/* Check for moving Z: */ /* Check for moving Z: */
/* Only allowing moving it once. It is merely a convenience added for the wine team */ /* Only allowing moving it once. It is merely a convenience added for the wine team */
if (ZDRIVE_NUM == 25 && cmd->FindString("-z", newz,false)) { if (ZDRIVE_NUM == 25 && cmd->FindString("-z", newz,false)) {
newz[0] = toupper(newz[0]); Move_Z(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);
}
return; return;
} }
/* Show list of cdroms */ /* Show list of cdroms */
@@ -884,9 +887,9 @@ public:
std::transform(type.begin(), type.end(), type.begin(), ::tolower); std::transform(type.begin(), type.end(), type.begin(), ::tolower);
bool iscdrom = (type =="cdrom"); //Used for mscdex bug cdrom label name emulation bool iscdrom = (type =="cdrom"); //Used for mscdex bug cdrom label name emulation
if (type=="floppy" || type=="dir" || type=="cdrom" || type =="overlay") { if (type=="floppy" || type=="dir" || type=="cdrom" || type =="overlay") {
uint16_t sizes[4]; uint16_t sizes[4] = { 0 };
uint8_t mediaid; uint8_t mediaid;
std::string str_size; std::string str_size = "";
if (type=="floppy") { if (type=="floppy") {
str_size="512,1,2880,2880"; str_size="512,1,2880,2880";
mediaid=0xF0; /* Floppy 1.44 media */ mediaid=0xF0; /* Floppy 1.44 media */
@@ -1748,7 +1751,7 @@ public:
newDiskSwap[i] = new imageDiskNFD(usefile, (uint8_t *)fname, floppysize, false, 1); newDiskSwap[i] = new imageDiskNFD(usefile, (uint8_t *)fname, floppysize, false, 1);
} }
else { else {
newDiskSwap[i] = new imageDisk(usefile, (uint8_t *)fname, floppysize, false); newDiskSwap[i] = new imageDisk(usefile, fname, floppysize, false);
} }
newDiskSwap[i]->Addref(); newDiskSwap[i]->Addref();
if (newDiskSwap[i]->active && !newDiskSwap[i]->hardDrive) incrementFDD(); //moved from imageDisk constructor 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]; sectors = (uint64_t)ftello64(newDisk) / (uint64_t)sizes[0];
imagesize = (uint32_t)(sectors / 2); /* orig. code wants it in KBs */ imagesize = (uint32_t)(sectors / 2); /* orig. code wants it in KBs */
setbuf(newDisk, NULL); setbuf(newDisk, NULL);
newImage = new imageDisk(newDisk, (uint8_t *)fname, imagesize, (imagesize > 2880)); newImage = new imageDisk(newDisk, fname, imagesize, (imagesize > 2880));
} }
} }

View File

@@ -1287,7 +1287,7 @@ fatDrive::fatDrive(const char* sysFilename, uint32_t bytesector, uint32_t cylsec
else { else {
fseeko64(diskfile, 0L, SEEK_END); fseeko64(diskfile, 0L, SEEK_END);
filesize = (uint32_t)(ftello64(diskfile) / 1024L); filesize = (uint32_t)(ftello64(diskfile) / 1024L);
loadedDisk = new imageDisk(diskfile, (uint8_t *)fname, filesize, (filesize > 2880)); loadedDisk = new imageDisk(diskfile, fname, filesize, (filesize > 2880));
} }
} }

View File

@@ -428,7 +428,7 @@ typedef struct {
}NHD_FILE_HEAD,*LP_NHD_FILE_HEAD; }NHD_FILE_HEAD,*LP_NHD_FILE_HEAD;
#pragma pack(pop) #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) if (imgName != NULL)
diskname = (const char*)imgName; diskname = (const char*)imgName;

View File

@@ -433,7 +433,7 @@ using namespace std;
//Public Constructor. //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){
} }