Formatting and review fixes
This commit is contained in:
		
							parent
							
								
									c7484ceaaa
								
							
						
					
					
						commit
						878959a0aa
					
				
					 7 changed files with 571 additions and 553 deletions
				
			
		| 
						 | 
				
			
			@ -624,7 +624,7 @@ bool CDROM_Interface_Image::ReadSectors(PhysPt buffer, bool raw, unsigned long s
 | 
			
		|||
	Bit8u* buf = new Bit8u[buflen];
 | 
			
		||||
 | 
			
		||||
	bool success = true; //Gobliiins reads 0 sectors
 | 
			
		||||
	for(unsigned long i = 0; i < num; i++) {
 | 
			
		||||
	for (unsigned long i = 0; i < num; i++) {
 | 
			
		||||
		success = ReadSector(&buf[i * sectorSize], raw, sector + i);
 | 
			
		||||
		if (!success) {
 | 
			
		||||
			break;
 | 
			
		||||
| 
						 | 
				
			
			@ -661,7 +661,7 @@ track_iter CDROM_Interface_Image::GetTrack(const int sector)
 | 
			
		|||
	// (start + length).
 | 
			
		||||
	track_iter track(tracks.begin());
 | 
			
		||||
	int lower_bound = track->start;
 | 
			
		||||
	while(track != tracks.end()) {
 | 
			
		||||
	while (track != tracks.end()) {
 | 
			
		||||
		const int upper_bound = track->start + track->length;
 | 
			
		||||
		if (lower_bound <= sector && sector < upper_bound) {
 | 
			
		||||
			break;
 | 
			
		||||
| 
						 | 
				
			
			@ -804,10 +804,10 @@ bool CDROM_Interface_Image::LoadIsoFile(char* filename)
 | 
			
		|||
	// try to detect iso type
 | 
			
		||||
	if (CanReadPVD(track.file.get(), BYTES_PER_COOKED_REDBOOK_FRAME, false)) {
 | 
			
		||||
		track.sectorSize = BYTES_PER_COOKED_REDBOOK_FRAME;
 | 
			
		||||
		// track.mode2 = false (comment only, because this is the default value)
 | 
			
		||||
		assert(track.mode2 == false);
 | 
			
		||||
	} else if (CanReadPVD(track.file.get(), BYTES_PER_RAW_REDBOOK_FRAME, false)) {
 | 
			
		||||
		track.sectorSize = BYTES_PER_RAW_REDBOOK_FRAME;
 | 
			
		||||
		// track.mode2 = false (comment only, because this is the default value)
 | 
			
		||||
		assert(track.mode2 == false);
 | 
			
		||||
	} else if (CanReadPVD(track.file.get(), 2336, true)) {
 | 
			
		||||
		track.sectorSize = 2336;
 | 
			
		||||
		track.mode2 = true;
 | 
			
		||||
| 
						 | 
				
			
			@ -888,7 +888,7 @@ bool CDROM_Interface_Image::LoadCueSheet(char *cuefile)
 | 
			
		|||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	while(!in.eof()) {
 | 
			
		||||
	while (!in.eof()) {
 | 
			
		||||
		// get next line
 | 
			
		||||
		char buf[MAX_LINE_LENGTH];
 | 
			
		||||
		in.getline(buf, MAX_LINE_LENGTH);
 | 
			
		||||
| 
						 | 
				
			
			@ -1071,7 +1071,7 @@ bool CDROM_Interface_Image::AddTrack(Track &curr, int &shift, const int prestart
 | 
			
		|||
bool CDROM_Interface_Image::HasDataTrack(void)
 | 
			
		||||
{
 | 
			
		||||
	//Data track has attribute 0x40
 | 
			
		||||
	for(const auto &track : tracks) {
 | 
			
		||||
	for (const auto &track : tracks) {
 | 
			
		||||
		if (track.attr == 0x40) {
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -1139,8 +1139,9 @@ bool CDROM_Interface_Image::GetRealFileName(string &filename, string &pathname)
 | 
			
		|||
bool CDROM_Interface_Image::GetCueKeyword(string &keyword, istream &in)
 | 
			
		||||
{
 | 
			
		||||
	in >> keyword;
 | 
			
		||||
	for(Bitu i = 0; i < keyword.size(); i++) keyword[i] = toupper(keyword[i]);
 | 
			
		||||
 | 
			
		||||
	for (Bitu i = 0; i < keyword.size(); i++) {
 | 
			
		||||
		keyword[i] = toupper(keyword[i]);
 | 
			
		||||
	}
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -103,7 +103,7 @@ public:
 | 
			
		|||
			std::string line = "";
 | 
			
		||||
			char ppp[2] = {newz_drive,0};
 | 
			
		||||
			std::string tempenv = ppp; tempenv += ":\\";
 | 
			
		||||
			if (first_shell->GetEnvStr("PATH",line)){
 | 
			
		||||
			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 ||
 | 
			
		||||
| 
						 | 
				
			
			@ -117,9 +117,9 @@ public:
 | 
			
		|||
			first_shell->SetEnv("COMSPEC",tempenv.c_str());
 | 
			
		||||
 | 
			
		||||
			/* Update batch file if running from Z: (very likely: autoexec) */
 | 
			
		||||
			if(first_shell->bf) {
 | 
			
		||||
			if (first_shell->bf) {
 | 
			
		||||
				std::string &name = first_shell->bf->filename;
 | 
			
		||||
				if(name.length() >2 &&  name[0] == 'Z' && name[1] == ':') name[0] = newz_drive;
 | 
			
		||||
				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);
 | 
			
		||||
| 
						 | 
				
			
			@ -134,7 +134,7 @@ public:
 | 
			
		|||
 | 
			
		||||
		WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_1"));
 | 
			
		||||
		WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_FORMAT"),"Drive","Type","Label");
 | 
			
		||||
		for(int p = 0;p < 8;p++) WriteOut("----------");
 | 
			
		||||
		for (int p = 0;p < 8;p++) WriteOut("----------");
 | 
			
		||||
 | 
			
		||||
		for (int d = 0; d < DOS_DRIVES; d++) {
 | 
			
		||||
			if (!Drives[d]) continue;
 | 
			
		||||
| 
						 | 
				
			
			@ -172,7 +172,7 @@ public:
 | 
			
		|||
 | 
			
		||||
		/* In secure mode don't allow people to change mount points.
 | 
			
		||||
		 * Neither mount nor unmount */
 | 
			
		||||
		if(control->SecureMode()) {
 | 
			
		||||
		if (control->SecureMode()) {
 | 
			
		||||
			WriteOut(MSG_Get("PROGRAM_CONFIG_SECURE_DISALLOW"));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -221,7 +221,7 @@ public:
 | 
			
		|||
			}
 | 
			
		||||
			/* Parse the free space in mb's (kb's for floppies) */
 | 
			
		||||
			std::string mb_size;
 | 
			
		||||
			if(cmd->FindString("-freesize",mb_size,true)) {
 | 
			
		||||
			if (cmd->FindString("-freesize",mb_size,true)) {
 | 
			
		||||
				char teststr[1024];
 | 
			
		||||
				Bit16u freesize = static_cast<Bit16u>(atoi(mb_size.c_str()));
 | 
			
		||||
				if (type=="floppy") {
 | 
			
		||||
| 
						 | 
				
			
			@ -257,7 +257,7 @@ public:
 | 
			
		|||
 | 
			
		||||
			// get the drive letter
 | 
			
		||||
			cmd->FindCommand(1,temp_line);
 | 
			
		||||
			if ((temp_line.size() > 2) || ((temp_line.size()>1) && (temp_line[1]!=':'))) goto showusage;
 | 
			
		||||
			if ((temp_line.size() > 2) || ((temp_line.size() > 1) && (temp_line[1]!=':'))) goto showusage;
 | 
			
		||||
			int i_drive = toupper(temp_line[0]);
 | 
			
		||||
 | 
			
		||||
			if (!isalpha(i_drive)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -284,10 +284,10 @@ public:
 | 
			
		|||
			if (!temp_line.size()) {
 | 
			
		||||
				goto showusage;
 | 
			
		||||
			}
 | 
			
		||||
			if(path_relative_to_last_config && control->configfiles.size() && !Cross::IsPathAbsolute(temp_line)) {
 | 
			
		||||
				std::string lastconfigdir(control->configfiles[control->configfiles.size()-1]);
 | 
			
		||||
			if (path_relative_to_last_config && control->configfiles.size() && !Cross::IsPathAbsolute(temp_line)) {
 | 
			
		||||
				std::string lastconfigdir(control->configfiles[control->configfiles.size() - 1]);
 | 
			
		||||
				std::string::size_type pos = lastconfigdir.rfind(CROSS_FILESPLIT);
 | 
			
		||||
				if(pos == std::string::npos) {
 | 
			
		||||
				if (pos == std::string::npos) {
 | 
			
		||||
					pos = 0; //No directory then erase string
 | 
			
		||||
				}
 | 
			
		||||
				lastconfigdir.erase(pos);
 | 
			
		||||
| 
						 | 
				
			
			@ -301,16 +301,16 @@ public:
 | 
			
		|||
			bool failed = false;
 | 
			
		||||
#if defined (WIN32)
 | 
			
		||||
			/* Removing trailing backslash if not root dir so stat will succeed */
 | 
			
		||||
			if(temp_line.size() > 3 && temp_line[temp_line.size()-1]=='\\') temp_line.erase(temp_line.size()-1,1);
 | 
			
		||||
			if (temp_line.size() > 3 && temp_line[temp_line.size() - 1]=='\\') temp_line.erase(temp_line.size() - 1, 1);
 | 
			
		||||
			if (stat(temp_line.c_str(),&test)) {
 | 
			
		||||
#else
 | 
			
		||||
			if (stat(temp_line.c_str(),&test)) {
 | 
			
		||||
				failed = true;
 | 
			
		||||
				Cross::ResolveHomedir(temp_line);
 | 
			
		||||
				//Try again after resolving ~
 | 
			
		||||
				if(!stat(temp_line.c_str(),&test)) failed = false;
 | 
			
		||||
				if (!stat(temp_line.c_str(),&test)) failed = false;
 | 
			
		||||
			}
 | 
			
		||||
			if(failed) {
 | 
			
		||||
			if (failed) {
 | 
			
		||||
#endif
 | 
			
		||||
				WriteOut(MSG_Get("PROGRAM_MOUNT_ERROR_1"),temp_line.c_str());
 | 
			
		||||
				return;
 | 
			
		||||
| 
						 | 
				
			
			@ -321,7 +321,7 @@ public:
 | 
			
		|||
				return;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if (temp_line[temp_line.size()-1]!=CROSS_FILESPLIT) temp_line+=CROSS_FILESPLIT;
 | 
			
		||||
			if (temp_line[temp_line.size() - 1] != CROSS_FILESPLIT) temp_line += CROSS_FILESPLIT;
 | 
			
		||||
			Bit8u bit8size=(Bit8u) sizes[1];
 | 
			
		||||
 | 
			
		||||
			if (type == "cdrom") {
 | 
			
		||||
| 
						 | 
				
			
			@ -350,13 +350,13 @@ public:
 | 
			
		|||
			} else {
 | 
			
		||||
				/* Give a warning when mount c:\ or the / */
 | 
			
		||||
#if defined (WIN32)
 | 
			
		||||
				if( (temp_line == "c:\\") || (temp_line == "C:\\") ||
 | 
			
		||||
				if ( (temp_line == "c:\\") || (temp_line == "C:\\") ||
 | 
			
		||||
				    (temp_line == "c:/") || (temp_line == "C:/")    )
 | 
			
		||||
					WriteOut(MSG_Get("PROGRAM_MOUNT_WARNING_WIN"));
 | 
			
		||||
#else
 | 
			
		||||
				if(temp_line == "/") WriteOut(MSG_Get("PROGRAM_MOUNT_WARNING_OTHER"));
 | 
			
		||||
				if (temp_line == "/") WriteOut(MSG_Get("PROGRAM_MOUNT_WARNING_OTHER"));
 | 
			
		||||
#endif
 | 
			
		||||
				if(type == "overlay") {
 | 
			
		||||
				if (type == "overlay") {
 | 
			
		||||
					localDrive* ldp = dynamic_cast<localDrive*>(Drives[drive - 'A']);
 | 
			
		||||
					cdromDrive* cdp = dynamic_cast<cdromDrive*>(Drives[drive - 'A']);
 | 
			
		||||
					if (!ldp || cdp) {
 | 
			
		||||
| 
						 | 
				
			
			@ -399,14 +399,14 @@ public:
 | 
			
		|||
		/* 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" || type == "overlay") {
 | 
			
		||||
		else if (type == "dir" || type == "overlay") {
 | 
			
		||||
			label = drive; label += "_DRIVE";
 | 
			
		||||
			newdrive->dirCache.SetLabel(label.c_str(),iscdrom,false);
 | 
			
		||||
		} else if(type == "floppy") {
 | 
			
		||||
		} else if (type == "floppy") {
 | 
			
		||||
			label = drive; label += "_FLOPPY";
 | 
			
		||||
			newdrive->dirCache.SetLabel(label.c_str(),iscdrom,true);
 | 
			
		||||
		}
 | 
			
		||||
		if(type == "floppy") incrementFDD();
 | 
			
		||||
		if (type == "floppy") incrementFDD();
 | 
			
		||||
		return;
 | 
			
		||||
showusage:
 | 
			
		||||
#if defined (WIN32)
 | 
			
		||||
| 
						 | 
				
			
			@ -508,10 +508,10 @@ private:
 | 
			
		|||
 | 
			
		||||
		try {
 | 
			
		||||
			ldp=dynamic_cast<localDrive*>(Drives[drive]);
 | 
			
		||||
			if(!ldp) return NULL;
 | 
			
		||||
			if (!ldp) return NULL;
 | 
			
		||||
 | 
			
		||||
			tmpfile = ldp->GetSystemFilePtr(fullname, "rb");
 | 
			
		||||
			if(tmpfile == NULL) {
 | 
			
		||||
			if (tmpfile == NULL) {
 | 
			
		||||
				if (!tryload) *error=1;
 | 
			
		||||
				return NULL;
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			@ -523,12 +523,12 @@ private:
 | 
			
		|||
			fclose(tmpfile);
 | 
			
		||||
 | 
			
		||||
			tmpfile = ldp->GetSystemFilePtr(fullname, "rb+");
 | 
			
		||||
			if(tmpfile == NULL) {
 | 
			
		||||
			if (tmpfile == NULL) {
 | 
			
		||||
//				if (!tryload) *error=2;
 | 
			
		||||
//				return NULL;
 | 
			
		||||
				WriteOut(MSG_Get("PROGRAM_BOOT_WRITE_PROTECTED"));
 | 
			
		||||
				tmpfile = ldp->GetSystemFilePtr(fullname, "rb");
 | 
			
		||||
				if(tmpfile == NULL) {
 | 
			
		||||
				if (tmpfile == NULL) {
 | 
			
		||||
					if (!tryload) *error=1;
 | 
			
		||||
					return NULL;
 | 
			
		||||
				}
 | 
			
		||||
| 
						 | 
				
			
			@ -544,16 +544,16 @@ private:
 | 
			
		|||
	FILE *getFSFile(char const * filename, Bit32u *ksize, Bit32u *bsize,bool tryload=false) {
 | 
			
		||||
		Bit8u error = tryload?1:0;
 | 
			
		||||
		FILE* tmpfile = getFSFile_mounted(filename,ksize,bsize,&error);
 | 
			
		||||
		if(tmpfile) return tmpfile;
 | 
			
		||||
		if (tmpfile) return tmpfile;
 | 
			
		||||
		//File not found on mounted filesystem. Try regular filesystem
 | 
			
		||||
		std::string filename_s(filename);
 | 
			
		||||
		Cross::ResolveHomedir(filename_s);
 | 
			
		||||
		tmpfile = fopen_wrap(filename_s.c_str(),"rb+");
 | 
			
		||||
		if(!tmpfile) {
 | 
			
		||||
			if( (tmpfile = fopen_wrap(filename_s.c_str(),"rb")) ) {
 | 
			
		||||
		if (!tmpfile) {
 | 
			
		||||
			if ( (tmpfile = fopen_wrap(filename_s.c_str(),"rb")) ) {
 | 
			
		||||
				//File exists; So can't be opened in correct mode => error 2
 | 
			
		||||
//				fclose(tmpfile);
 | 
			
		||||
//				if(tryload) error = 2;
 | 
			
		||||
//				if (tryload) error = 2;
 | 
			
		||||
				WriteOut(MSG_Get("PROGRAM_BOOT_WRITE_PROTECTED"));
 | 
			
		||||
				fseek(tmpfile,0L, SEEK_END);
 | 
			
		||||
				*ksize = (ftell(tmpfile) / 1024);
 | 
			
		||||
| 
						 | 
				
			
			@ -561,8 +561,8 @@ private:
 | 
			
		|||
				return tmpfile;
 | 
			
		||||
			}
 | 
			
		||||
			// Give the delayed errormessages from the mounted variant (or from above)
 | 
			
		||||
			if(error == 1) WriteOut(MSG_Get("PROGRAM_BOOT_NOT_EXIST"));
 | 
			
		||||
			if(error == 2) WriteOut(MSG_Get("PROGRAM_BOOT_NOT_OPEN"));
 | 
			
		||||
			if (error == 1) WriteOut(MSG_Get("PROGRAM_BOOT_NOT_EXIST"));
 | 
			
		||||
			if (error == 2) WriteOut(MSG_Get("PROGRAM_BOOT_NOT_OPEN"));
 | 
			
		||||
			return NULL;
 | 
			
		||||
		}
 | 
			
		||||
		fseek(tmpfile,0L, SEEK_END);
 | 
			
		||||
| 
						 | 
				
			
			@ -595,7 +595,7 @@ public:
 | 
			
		|||
		ChangeToLongCmd();
 | 
			
		||||
		/* In secure mode don't allow people to boot stuff.
 | 
			
		||||
		 * They might try to corrupt the data on it */
 | 
			
		||||
		if(control->SecureMode()) {
 | 
			
		||||
		if (control->SecureMode()) {
 | 
			
		||||
			WriteOut(MSG_Get("PROGRAM_CONFIG_SECURE_DISALLOW"));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -609,16 +609,16 @@ public:
 | 
			
		|||
		Bit8u drive = 'A';
 | 
			
		||||
		std::string cart_cmd="";
 | 
			
		||||
 | 
			
		||||
		if(!cmd->GetCount()) {
 | 
			
		||||
		if (!cmd->GetCount()) {
 | 
			
		||||
			printError();
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		while(i<cmd->GetCount()) {
 | 
			
		||||
			if(cmd->FindCommand(i+1, temp_line)) {
 | 
			
		||||
				if((temp_line == "-l") || (temp_line == "-L")) {
 | 
			
		||||
		while (i<cmd->GetCount()) {
 | 
			
		||||
			if (cmd->FindCommand(i+1, temp_line)) {
 | 
			
		||||
				if ((temp_line == "-l") || (temp_line == "-L")) {
 | 
			
		||||
					/* Specifying drive... next argument then is the drive */
 | 
			
		||||
					i++;
 | 
			
		||||
					if(cmd->FindCommand(i+1, temp_line)) {
 | 
			
		||||
					if (cmd->FindCommand(i+1, temp_line)) {
 | 
			
		||||
						drive=toupper(temp_line[0]);
 | 
			
		||||
						if ((drive != 'A') && (drive != 'C') && (drive != 'D')) {
 | 
			
		||||
							printError();
 | 
			
		||||
| 
						 | 
				
			
			@ -633,11 +633,11 @@ public:
 | 
			
		|||
					continue;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if((temp_line == "-e") || (temp_line == "-E")) {
 | 
			
		||||
				if ((temp_line == "-e") || (temp_line == "-E")) {
 | 
			
		||||
					/* Command mode for PCJr cartridges */
 | 
			
		||||
					i++;
 | 
			
		||||
					if(cmd->FindCommand(i + 1, temp_line)) {
 | 
			
		||||
						for(size_t ct = 0;ct < temp_line.size();ct++) temp_line[ct] = toupper(temp_line[ct]);
 | 
			
		||||
					if (cmd->FindCommand(i + 1, temp_line)) {
 | 
			
		||||
						for (size_t ct = 0;ct < temp_line.size();ct++) temp_line[ct] = toupper(temp_line[ct]);
 | 
			
		||||
						cart_cmd = temp_line;
 | 
			
		||||
					} else {
 | 
			
		||||
						printError();
 | 
			
		||||
| 
						 | 
				
			
			@ -653,7 +653,7 @@ public:
 | 
			
		|||
				WriteOut(MSG_Get("PROGRAM_BOOT_IMAGE_OPEN"), temp_line.c_str());
 | 
			
		||||
				Bit32u rombytesize;
 | 
			
		||||
				FILE *usefile = getFSFile(temp_line.c_str(), &floppysize, &rombytesize);
 | 
			
		||||
				if(usefile != NULL) {
 | 
			
		||||
				if (usefile != NULL) {
 | 
			
		||||
					diskSwap[i].reset(new imageDisk(usefile, temp_line.c_str(), floppysize, false));
 | 
			
		||||
					if (usefile_1==NULL) {
 | 
			
		||||
						usefile_1=usefile;
 | 
			
		||||
| 
						 | 
				
			
			@ -762,7 +762,7 @@ public:
 | 
			
		|||
					fseek(tfile, 0x3000L, SEEK_SET);
 | 
			
		||||
					Bit32u drd=(Bit32u) fread(rombuf, 1, 0xb000, tfile);
 | 
			
		||||
					if (drd==0xb000) {
 | 
			
		||||
						for(i=0;i<0xb000;i++) phys_writeb(0xf3000+i,rombuf[i]);
 | 
			
		||||
						for ( i = 0; i < 0xb000; i++) phys_writeb(0xf3000 + i, rombuf[i]);
 | 
			
		||||
					}
 | 
			
		||||
					fclose(tfile);
 | 
			
		||||
				}
 | 
			
		||||
| 
						 | 
				
			
			@ -788,7 +788,7 @@ public:
 | 
			
		|||
					//fclose(usefile_2); //usefile_2 is in diskSwap structure which should be deleted to close the file
 | 
			
		||||
 | 
			
		||||
					/* write cartridge data into ROM */
 | 
			
		||||
					for(i=0;i<rombytesize_2-0x200;i++) phys_writeb(romseg_pt+i,rombuf[i]);
 | 
			
		||||
					for (i = 0; i < rombytesize_2 - 0x200; i++) phys_writeb(romseg_pt + i, rombuf[i]);
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				fseek(usefile_1, 0x0L, SEEK_SET);
 | 
			
		||||
| 
						 | 
				
			
			@ -810,7 +810,7 @@ public:
 | 
			
		|||
				//fclose(usefile_1); //usefile_1 is in diskSwap structure which should be deleted to close the file
 | 
			
		||||
 | 
			
		||||
				/* write cartridge data into ROM */
 | 
			
		||||
				for(i=0;i<rombytesize_1-0x200;i++) phys_writeb((romseg<<4)+i,rombuf[i]);
 | 
			
		||||
				for (i = 0; i < rombytesize_1 - 0x200; i++) phys_writeb((romseg << 4) + i, rombuf[i]);
 | 
			
		||||
 | 
			
		||||
				//Close cardridges
 | 
			
		||||
				for (auto &disk : diskSwap)
 | 
			
		||||
| 
						 | 
				
			
			@ -845,7 +845,7 @@ public:
 | 
			
		|||
			void RemoveEMSPageFrame(void);
 | 
			
		||||
			RemoveEMSPageFrame();
 | 
			
		||||
			WriteOut(MSG_Get("PROGRAM_BOOT_BOOT"), drive);
 | 
			
		||||
			for(i=0;i<512;i++) real_writeb(0, 0x7c00 + i, bootarea.rawdata[i]);
 | 
			
		||||
			for (i = 0; i < 512; i++) real_writeb(0, 0x7c00 + i, bootarea.rawdata[i]);
 | 
			
		||||
 | 
			
		||||
			/* create appearance of floppy drive DMA usage (Demon's Forge) */
 | 
			
		||||
			if (!IS_TANDY_ARCH && floppysize!=0) GetDMAChannel(2)->tcount=true;
 | 
			
		||||
| 
						 | 
				
			
			@ -892,10 +892,10 @@ public:
 | 
			
		|||
		try {
 | 
			
		||||
			/* try to read ROM file into buffer */
 | 
			
		||||
			ldp=dynamic_cast<localDrive*>(Drives[drive]);
 | 
			
		||||
			if(!ldp) return;
 | 
			
		||||
			if (!ldp) return;
 | 
			
		||||
 | 
			
		||||
			FILE *tmpfile = ldp->GetSystemFilePtr(fullname, "rb");
 | 
			
		||||
			if(tmpfile == NULL) {
 | 
			
		||||
			if (tmpfile == NULL) {
 | 
			
		||||
				WriteOut(MSG_Get("PROGRAM_LOADROM_CANT_OPEN"));
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			@ -1056,7 +1056,7 @@ void LOADFIX::Run(void)
 | 
			
		|||
			args[0] = 0;
 | 
			
		||||
			do {
 | 
			
		||||
				ok = cmd->FindCommand(commandNr++,temp_line);
 | 
			
		||||
				if(sizeof(args)-strlen(args)-1 < temp_line.length()+1)
 | 
			
		||||
				if (sizeof(args) - strlen(args) - 1 < temp_line.length() + 1)
 | 
			
		||||
					break;
 | 
			
		||||
				strcat(args,temp_line.c_str());
 | 
			
		||||
				strcat(args," ");
 | 
			
		||||
| 
						 | 
				
			
			@ -1089,7 +1089,7 @@ void RESCAN::Run(void)
 | 
			
		|||
 | 
			
		||||
	Bit8u drive = DOS_GetDefaultDrive();
 | 
			
		||||
 | 
			
		||||
	if(cmd->FindCommand(1,temp_line)) {
 | 
			
		||||
	if (cmd->FindCommand(1,temp_line)) {
 | 
			
		||||
		//-A -All /A /All
 | 
			
		||||
		if (temp_line.size() >= 2
 | 
			
		||||
			&& (temp_line[0] == '-' ||
 | 
			
		||||
| 
						 | 
				
			
			@ -1098,14 +1098,14 @@ void RESCAN::Run(void)
 | 
			
		|||
			    temp_line[1] == 'A') ) {
 | 
			
		||||
	 		all = true;
 | 
			
		||||
		}
 | 
			
		||||
		else if(temp_line.size() == 2 && temp_line[1] == ':') {
 | 
			
		||||
		else if (temp_line.size() == 2 && temp_line[1] == ':') {
 | 
			
		||||
			lowcase(temp_line);
 | 
			
		||||
			drive  = temp_line[0] - 'a';
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	// Get current drive
 | 
			
		||||
	if (all) {
 | 
			
		||||
		for(Bitu i =0; i<DOS_DRIVES;i++) {
 | 
			
		||||
		for (Bitu i =0; i<DOS_DRIVES; i++) {
 | 
			
		||||
			if (Drives[i]) Drives[i]->EmptyCache();
 | 
			
		||||
		}
 | 
			
		||||
		WriteOut(MSG_Get("PROGRAM_RESCAN_SUCCESS"));
 | 
			
		||||
| 
						 | 
				
			
			@ -1137,17 +1137,17 @@ public:
 | 
			
		|||
 | 
			
		||||
	void Run(void) {
 | 
			
		||||
		/* Only run if called from the first shell (Xcom TFTD runs any intro file in the path) */
 | 
			
		||||
		if(DOS_PSP(dos.psp()).GetParent() != DOS_PSP(DOS_PSP(dos.psp()).GetParent()).GetParent()) return;
 | 
			
		||||
		if(cmd->FindExist("cdrom",false)) {
 | 
			
		||||
		if (DOS_PSP(dos.psp()).GetParent() != DOS_PSP(DOS_PSP(dos.psp()).GetParent()).GetParent()) return;
 | 
			
		||||
		if (cmd->FindExist("cdrom",false)) {
 | 
			
		||||
			WriteOut(MSG_Get("PROGRAM_INTRO_CDROM"));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		if(cmd->FindExist("mount",false)) {
 | 
			
		||||
		if (cmd->FindExist("mount",false)) {
 | 
			
		||||
			WriteOut("\033[2J");//Clear screen before printing
 | 
			
		||||
			DisplayMount();
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		if(cmd->FindExist("special",false)) {
 | 
			
		||||
		if (cmd->FindExist("special",false)) {
 | 
			
		||||
			WriteOut(MSG_Get("PROGRAM_INTRO_SPECIAL"));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -1174,7 +1174,7 @@ public:
 | 
			
		|||
		ChangeToLongCmd();
 | 
			
		||||
		/* In secure mode don't allow people to change imgmount points.
 | 
			
		||||
		 * Neither mount nor unmount */
 | 
			
		||||
		if(control->SecureMode()) {
 | 
			
		||||
		if (control->SecureMode()) {
 | 
			
		||||
			WriteOut(MSG_Get("PROGRAM_CONFIG_SECURE_DISALLOW"));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -1194,7 +1194,7 @@ public:
 | 
			
		|||
		std::string fstype = "fat";
 | 
			
		||||
		cmd->FindString("-t",type,true);
 | 
			
		||||
		cmd->FindString("-fs",fstype,true);
 | 
			
		||||
		if(type == "cdrom") type = "iso"; //Tiny hack for people who like to type -t cdrom
 | 
			
		||||
		if (type == "cdrom") type = "iso"; //Tiny hack for people who like to type -t cdrom
 | 
			
		||||
 | 
			
		||||
		//Check type and exit early.
 | 
			
		||||
		if (type != "floppy" && type != "hdd" && type != "iso") {
 | 
			
		||||
| 
						 | 
				
			
			@ -1237,9 +1237,9 @@ public:
 | 
			
		|||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if(fstype=="fat" || fstype=="iso") {
 | 
			
		||||
		if (fstype=="fat" || fstype=="iso") {
 | 
			
		||||
			// get the drive letter
 | 
			
		||||
			if (!cmd->FindCommand(1,temp_line) || (temp_line.size() > 2) || ((temp_line.size()>1) && (temp_line[1]!=':'))) {
 | 
			
		||||
			if (!cmd->FindCommand(1,temp_line) || (temp_line.size() > 2) || ((temp_line.size() > 1) && (temp_line[1]!=':'))) {
 | 
			
		||||
				WriteOut_NoParsing(MSG_Get("PROGRAM_IMGMOUNT_SPECIFY_DRIVE"));
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			@ -1266,14 +1266,14 @@ public:
 | 
			
		|||
		}
 | 
			
		||||
 | 
			
		||||
		// find all file parameters, assuming that all option parameters have been removed
 | 
			
		||||
		while(cmd->FindCommand((unsigned int)(paths.size() + 2), temp_line) && temp_line.size()) {
 | 
			
		||||
		while (cmd->FindCommand((unsigned int)(paths.size() + 2), temp_line) && temp_line.size()) {
 | 
			
		||||
 | 
			
		||||
			struct stat test;
 | 
			
		||||
			if (stat(temp_line.c_str(),&test)) {
 | 
			
		||||
				//See if it works if the ~ are written out
 | 
			
		||||
				std::string homedir(temp_line);
 | 
			
		||||
				Cross::ResolveHomedir(homedir);
 | 
			
		||||
				if(!stat(homedir.c_str(),&test)) {
 | 
			
		||||
				if (!stat(homedir.c_str(),&test)) {
 | 
			
		||||
					temp_line = homedir;
 | 
			
		||||
				} else {
 | 
			
		||||
					// convert dosbox filename to system filename
 | 
			
		||||
| 
						 | 
				
			
			@ -1314,7 +1314,7 @@ public:
 | 
			
		|||
		if (paths.size() == 1)
 | 
			
		||||
			temp_line = paths[0];
 | 
			
		||||
 | 
			
		||||
		if(fstype=="fat") {
 | 
			
		||||
		if (fstype=="fat") {
 | 
			
		||||
			if (imgsizedetect) {
 | 
			
		||||
				FILE * diskfile = fopen_wrap(temp_line.c_str(), "rb+");
 | 
			
		||||
				if (!diskfile) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1363,7 +1363,7 @@ public:
 | 
			
		|||
				} else {
 | 
			
		||||
					// Tear-down all prior drives when we hit a problem
 | 
			
		||||
					WriteOut(MSG_Get("PROGRAM_IMGMOUNT_CANT_CREATE"));
 | 
			
		||||
					for(auto pImgDisk : imgDisks) {
 | 
			
		||||
					for (auto pImgDisk : imgDisks) {
 | 
			
		||||
						if (pImgDisk) {
 | 
			
		||||
							delete pImgDisk;
 | 
			
		||||
						}
 | 
			
		||||
| 
						 | 
				
			
			@ -1373,7 +1373,7 @@ public:
 | 
			
		|||
			}
 | 
			
		||||
 | 
			
		||||
			// Update DriveManager
 | 
			
		||||
			for(ct = 0; ct < imgDisks.size(); ct++) {
 | 
			
		||||
			for (ct = 0; ct < imgDisks.size(); ct++) {
 | 
			
		||||
				DriveManager::AppendDisk(drive - 'A', imgDisks[ct]);
 | 
			
		||||
			}
 | 
			
		||||
			DriveManager::InitializeDrive(drive - 'A');
 | 
			
		||||
| 
						 | 
				
			
			@ -1385,7 +1385,7 @@ public:
 | 
			
		|||
			RealPt save_dta = dos.dta();
 | 
			
		||||
			dos.dta(dos.tables.tempdta);
 | 
			
		||||
 | 
			
		||||
			for(ct = 0; ct < imgDisks.size(); ct++) {
 | 
			
		||||
			for (ct = 0; ct < imgDisks.size(); ct++) {
 | 
			
		||||
				DriveManager::CycleDisks(drive - 'A', (ct == (imgDisks.size() - 1)));
 | 
			
		||||
 | 
			
		||||
				char root[7] = {drive,':','\\','*','.','*',0};
 | 
			
		||||
| 
						 | 
				
			
			@ -1434,14 +1434,14 @@ public:
 | 
			
		|||
				}
 | 
			
		||||
				// error: clean up and leave
 | 
			
		||||
				if (error) {
 | 
			
		||||
					for(ct = 0; ct < isoDisks.size(); ct++) {
 | 
			
		||||
					for (ct = 0; ct < isoDisks.size(); ct++) {
 | 
			
		||||
						delete isoDisks[ct];
 | 
			
		||||
					}
 | 
			
		||||
					return;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			// Update DriveManager
 | 
			
		||||
			for(ct = 0; ct < isoDisks.size(); ct++) {
 | 
			
		||||
			for (ct = 0; ct < isoDisks.size(); ct++) {
 | 
			
		||||
				DriveManager::AppendDisk(drive - 'A', isoDisks[ct]);
 | 
			
		||||
			}
 | 
			
		||||
			DriveManager::InitializeDrive(drive - 'A');
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -106,7 +106,7 @@ Revision History:
 | 
			
		|||
#define SIN_BITS        10
 | 
			
		||||
#define SIN_LEN         (1<<SIN_BITS)
 | 
			
		||||
#define SIN_MASK        (SIN_LEN-1)
 | 
			
		||||
#define DV				(0.1875 / 2.0 )
 | 
			
		||||
#define DV				(0.1875 / 2.0)
 | 
			
		||||
 | 
			
		||||
#define TL_RES_LEN      (256)   /* 8 bits addressing (real chip) */
 | 
			
		||||
#define TL_TAB_LEN		(12 * 2 * TL_RES_LEN)
 | 
			
		||||
| 
						 | 
				
			
			@ -118,7 +118,7 @@ Revision History:
 | 
			
		|||
*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define ENV_QUIET      ( TL_TAB_LEN >> 4 )
 | 
			
		||||
#define ENV_QUIET      (TL_TAB_LEN >> 4)
 | 
			
		||||
#define LFO_AM_TAB_ELEMENTS 210
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -257,7 +257,7 @@ struct OPL_SLOT
 | 
			
		|||
 | 
			
		||||
	void KEYON(uint32_t key_set)
 | 
			
		||||
	{
 | 
			
		||||
		if( !key )
 | 
			
		||||
		if(!key)
 | 
			
		||||
		{
 | 
			
		||||
			/* restart Phase Generator */
 | 
			
		||||
			Cnt = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -269,11 +269,11 @@ struct OPL_SLOT
 | 
			
		|||
 | 
			
		||||
	void KEYOFF(uint32_t key_clr)
 | 
			
		||||
	{
 | 
			
		||||
		if( key )
 | 
			
		||||
		if(key)
 | 
			
		||||
		{
 | 
			
		||||
			key &= key_clr;
 | 
			
		||||
 | 
			
		||||
			if( !key )
 | 
			
		||||
			if(!key)
 | 
			
		||||
			{
 | 
			
		||||
				/* phase -> Release */
 | 
			
		||||
				if (state>EG_REL)
 | 
			
		||||
| 
						 | 
				
			
			@ -300,7 +300,7 @@ struct OPL_CH
 | 
			
		|||
		SLOT.Incr = fc * SLOT.mul;
 | 
			
		||||
		int const ksr = kcode >> SLOT.KSR;
 | 
			
		||||
 | 
			
		||||
		if( SLOT.ksr != ksr )
 | 
			
		||||
		if(SLOT.ksr != ksr)
 | 
			
		||||
		{
 | 
			
		||||
			SLOT.ksr = ksr;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -424,7 +424,7 @@ struct FM_OPL
 | 
			
		|||
		status &=~flag;
 | 
			
		||||
		if(status & 0x80)
 | 
			
		||||
		{
 | 
			
		||||
			if (!(status & statusmask) )
 | 
			
		||||
			if (!(status & statusmask))
 | 
			
		||||
			{
 | 
			
		||||
				status &= 0x7f;
 | 
			
		||||
				/* callback user interrupt handler (IRQ is ON to OFF) */
 | 
			
		||||
| 
						 | 
				
			
			@ -479,7 +479,7 @@ struct FM_OPL
 | 
			
		|||
				switch(op.state)
 | 
			
		||||
				{
 | 
			
		||||
				case EG_ATT:        /* attack phase */
 | 
			
		||||
					if ( !(eg_cnt & ((1<<op.eg_sh_ar)-1) ) )
 | 
			
		||||
					if (!(eg_cnt & ((1<<op.eg_sh_ar)-1)))
 | 
			
		||||
					{
 | 
			
		||||
						op.volume += (~op.volume *
 | 
			
		||||
													(eg_inc[op.eg_sel_ar + ((eg_cnt>>op.eg_sh_ar)&7)])
 | 
			
		||||
| 
						 | 
				
			
			@ -495,11 +495,11 @@ struct FM_OPL
 | 
			
		|||
					break;
 | 
			
		||||
 | 
			
		||||
				case EG_DEC:    /* decay phase */
 | 
			
		||||
					if ( !(eg_cnt & ((1<<op.eg_sh_dr)-1) ) )
 | 
			
		||||
					if (!(eg_cnt & ((1<<op.eg_sh_dr)-1)))
 | 
			
		||||
					{
 | 
			
		||||
						op.volume += eg_inc[op.eg_sel_dr + ((eg_cnt>>op.eg_sh_dr)&7)];
 | 
			
		||||
 | 
			
		||||
						if ( op.volume >= op.sl )
 | 
			
		||||
						if (op.volume >= op.sl)
 | 
			
		||||
							op.state = EG_SUS;
 | 
			
		||||
 | 
			
		||||
					}
 | 
			
		||||
| 
						 | 
				
			
			@ -518,11 +518,11 @@ struct FM_OPL
 | 
			
		|||
					else                /* percussive mode */
 | 
			
		||||
					{
 | 
			
		||||
						/* during sustain phase chip adds Release Rate (in percussive mode) */
 | 
			
		||||
						if ( !(eg_cnt & ((1<<op.eg_sh_rr)-1) ) )
 | 
			
		||||
						if (!(eg_cnt & ((1<<op.eg_sh_rr)-1)))
 | 
			
		||||
						{
 | 
			
		||||
							op.volume += eg_inc[op.eg_sel_rr + ((eg_cnt>>op.eg_sh_rr)&7)];
 | 
			
		||||
 | 
			
		||||
							if ( op.volume >= MAX_ATT_INDEX )
 | 
			
		||||
							if (op.volume >= MAX_ATT_INDEX)
 | 
			
		||||
								op.volume = MAX_ATT_INDEX;
 | 
			
		||||
						}
 | 
			
		||||
						/* else do nothing in sustain phase */
 | 
			
		||||
| 
						 | 
				
			
			@ -530,11 +530,11 @@ struct FM_OPL
 | 
			
		|||
					break;
 | 
			
		||||
 | 
			
		||||
				case EG_REL:    /* release phase */
 | 
			
		||||
					if ( !(eg_cnt & ((1<<op.eg_sh_rr)-1) ) )
 | 
			
		||||
					if (!(eg_cnt & ((1<<op.eg_sh_rr)-1)))
 | 
			
		||||
					{
 | 
			
		||||
						op.volume += eg_inc[op.eg_sel_rr + ((eg_cnt>>op.eg_sh_rr)&7)];
 | 
			
		||||
 | 
			
		||||
						if ( op.volume >= MAX_ATT_INDEX )
 | 
			
		||||
						if (op.volume >= MAX_ATT_INDEX)
 | 
			
		||||
						{
 | 
			
		||||
							op.volume = MAX_ATT_INDEX;
 | 
			
		||||
							op.state = EG_OFF;
 | 
			
		||||
| 
						 | 
				
			
			@ -597,7 +597,7 @@ struct FM_OPL
 | 
			
		|||
		{
 | 
			
		||||
			/*
 | 
			
		||||
			uint32_t j;
 | 
			
		||||
			j = ( (noise_rng) ^ (noise_rng>>14) ^ (noise_rng>>15) ^ (noise_rng>>22) ) & 1;
 | 
			
		||||
			j = ((noise_rng) ^ (noise_rng>>14) ^ (noise_rng>>15) ^ (noise_rng>>22)) & 1;
 | 
			
		||||
			noise_rng = (j<<22) | (noise_rng>>1);
 | 
			
		||||
			*/
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -632,17 +632,17 @@ struct FM_OPL
 | 
			
		|||
		SLOT->op1_out[0] = SLOT->op1_out[1];
 | 
			
		||||
		*SLOT->connect1 += SLOT->op1_out[0];
 | 
			
		||||
		SLOT->op1_out[1] = 0;
 | 
			
		||||
		if( env < ENV_QUIET )
 | 
			
		||||
		if(env < ENV_QUIET)
 | 
			
		||||
		{
 | 
			
		||||
			if (!SLOT->FB)
 | 
			
		||||
				out = 0;
 | 
			
		||||
			SLOT->op1_out[1] = op_calc1(SLOT->Cnt, env, (out<<SLOT->FB), SLOT->wavetable );
 | 
			
		||||
			SLOT->op1_out[1] = op_calc1(SLOT->Cnt, env, (out<<SLOT->FB), SLOT->wavetable);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* SLOT 2 */
 | 
			
		||||
		SLOT++;
 | 
			
		||||
		env = volume_calc(*SLOT);
 | 
			
		||||
		if( env < ENV_QUIET )
 | 
			
		||||
		if(env < ENV_QUIET)
 | 
			
		||||
			output[0] += op_calc(SLOT->Cnt, env, phase_modulation, SLOT->wavetable);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -712,17 +712,17 @@ struct FM_OPL
 | 
			
		|||
		/* else ignore output of operator 1 */
 | 
			
		||||
 | 
			
		||||
		SLOT->op1_out[1] = 0;
 | 
			
		||||
		if( env < ENV_QUIET )
 | 
			
		||||
		if(env < ENV_QUIET)
 | 
			
		||||
		{
 | 
			
		||||
			if (!SLOT->FB)
 | 
			
		||||
				out = 0;
 | 
			
		||||
			SLOT->op1_out[1] = op_calc1(SLOT->Cnt, env, (out<<SLOT->FB), SLOT->wavetable );
 | 
			
		||||
			SLOT->op1_out[1] = op_calc1(SLOT->Cnt, env, (out<<SLOT->FB), SLOT->wavetable);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* SLOT 2 */
 | 
			
		||||
		SLOT++;
 | 
			
		||||
		env = volume_calc(*SLOT);
 | 
			
		||||
		if( env < ENV_QUIET )
 | 
			
		||||
		if(env < ENV_QUIET)
 | 
			
		||||
			output[0] += op_calc(SLOT->Cnt, env, phase_modulation, SLOT->wavetable) * 2;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -747,7 +747,7 @@ struct FM_OPL
 | 
			
		|||
		OPL_SLOT const &SLOT7_1 = P_CH[7].SLOT[SLOT1];
 | 
			
		||||
		OPL_SLOT const &SLOT8_2 = P_CH[8].SLOT[SLOT2];
 | 
			
		||||
		env = volume_calc(SLOT7_1);
 | 
			
		||||
		if( env < ENV_QUIET )
 | 
			
		||||
		if(env < ENV_QUIET)
 | 
			
		||||
		{
 | 
			
		||||
			/* high hat phase generation:
 | 
			
		||||
			    phase = d0 or 234 (based on frequency only)
 | 
			
		||||
| 
						 | 
				
			
			@ -798,7 +798,7 @@ struct FM_OPL
 | 
			
		|||
		/* Snare Drum (verified on real YM3812) */
 | 
			
		||||
		OPL_SLOT const &SLOT7_2 = P_CH[7].SLOT[SLOT2];
 | 
			
		||||
		env = volume_calc(SLOT7_2);
 | 
			
		||||
		if( env < ENV_QUIET )
 | 
			
		||||
		if(env < ENV_QUIET)
 | 
			
		||||
		{
 | 
			
		||||
			/* base frequency derived from operator 1 in channel 7 */
 | 
			
		||||
			unsigned char const bit8 = BIT(SLOT7_1.Cnt >> FREQ_SH, 8);
 | 
			
		||||
| 
						 | 
				
			
			@ -820,12 +820,12 @@ struct FM_OPL
 | 
			
		|||
		/* Tom Tom (verified on real YM3812) */
 | 
			
		||||
		OPL_SLOT const &SLOT8_1 = P_CH[8].SLOT[SLOT1];
 | 
			
		||||
		env = volume_calc(SLOT8_1);
 | 
			
		||||
		if( env < ENV_QUIET )
 | 
			
		||||
		if(env < ENV_QUIET)
 | 
			
		||||
			output[0] += op_calc(SLOT8_1.Cnt, env, 0, SLOT8_1.wavetable) * 2;
 | 
			
		||||
 | 
			
		||||
		/* Top Cymbal (verified on real YM3812) */
 | 
			
		||||
		env = volume_calc(SLOT8_2);
 | 
			
		||||
		if( env < ENV_QUIET )
 | 
			
		||||
		if(env < ENV_QUIET)
 | 
			
		||||
		{
 | 
			
		||||
			/* base frequency derived from operator 1 in channel 7 */
 | 
			
		||||
			unsigned char const bit7 = BIT(SLOT7_1.Cnt >> FREQ_SH, 7);
 | 
			
		||||
| 
						 | 
				
			
			@ -934,7 +934,7 @@ struct FM_OPL
 | 
			
		|||
		/* first time */
 | 
			
		||||
 | 
			
		||||
		/* allocate total level table (128kb space) */
 | 
			
		||||
		if( !init_tables() )
 | 
			
		||||
		if(!init_tables())
 | 
			
		||||
		{
 | 
			
		||||
			num_lock--;
 | 
			
		||||
			return -1;
 | 
			
		||||
| 
						 | 
				
			
			@ -960,14 +960,14 @@ private:
 | 
			
		|||
 | 
			
		||||
	static inline signed int op_calc(uint32_t phase, unsigned int env, signed int pm, unsigned int wave_tab)
 | 
			
		||||
	{
 | 
			
		||||
		uint32_t const p = (env<<4) + sin_tab[wave_tab + ((((signed int)((phase & ~FREQ_MASK) + (pm<<16))) >> FREQ_SH ) & SIN_MASK) ];
 | 
			
		||||
		uint32_t const p = (env<<4) + sin_tab[wave_tab + ((((signed int)((phase & ~FREQ_MASK) + (pm<<16))) >> FREQ_SH) & SIN_MASK) ];
 | 
			
		||||
 | 
			
		||||
		return (p >= TL_TAB_LEN) ? 0 : tl_tab[p];
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	static inline signed int op_calc1(uint32_t phase, unsigned int env, signed int pm, unsigned int wave_tab)
 | 
			
		||||
	{
 | 
			
		||||
		uint32_t const p = (env<<4) + sin_tab[wave_tab + ((((signed int)((phase & ~FREQ_MASK) + pm      )) >> FREQ_SH ) & SIN_MASK) ];
 | 
			
		||||
		uint32_t const p = (env<<4) + sin_tab[wave_tab + ((((signed int)((phase & ~FREQ_MASK) + pm     )) >> FREQ_SH) & SIN_MASK) ];
 | 
			
		||||
 | 
			
		||||
		return (p >= TL_TAB_LEN) ? 0 : tl_tab[p];
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -1063,8 +1063,8 @@ const uint32_t FM_OPL::ksl_shift[4] = { 31, 1, 2, 0 };
 | 
			
		|||
/* 0 - 15: 0, 3, 6, 9,12,15,18,21,24,27,30,33,36,39,42,93 (dB)*/
 | 
			
		||||
#define SC(db)			int32_t(db * (2.0 / ENV_STEP))
 | 
			
		||||
const int32_t FM_OPL::sl_tab[16]={
 | 
			
		||||
	SC( 0),SC( 1),SC( 2),SC( 3),SC( 4),SC( 5),SC( 6),SC( 7),
 | 
			
		||||
	SC( 8),SC( 9),SC(10),SC(11),SC(12),SC(13),SC(14),SC(31)
 | 
			
		||||
	SC(0),SC(1),SC(2),SC(3),SC(4),SC(5),SC(6),SC(7),
 | 
			
		||||
	SC(8),SC(9),SC(10),SC(11),SC(12),SC(13),SC(14),SC(31)
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1101,25 +1101,25 @@ O(14),O(14),O(14),O(14),O(14),O(14),O(14),O(14),
 | 
			
		|||
O(14),O(14),O(14),O(14),O(14),O(14),O(14),O(14),
 | 
			
		||||
 | 
			
		||||
/* rates 00-12 */
 | 
			
		||||
O( 0),O( 1),O( 2),O( 3),
 | 
			
		||||
O( 0),O( 1),O( 2),O( 3),
 | 
			
		||||
O( 0),O( 1),O( 2),O( 3),
 | 
			
		||||
O( 0),O( 1),O( 2),O( 3),
 | 
			
		||||
O( 0),O( 1),O( 2),O( 3),
 | 
			
		||||
O( 0),O( 1),O( 2),O( 3),
 | 
			
		||||
O( 0),O( 1),O( 2),O( 3),
 | 
			
		||||
O( 0),O( 1),O( 2),O( 3),
 | 
			
		||||
O( 0),O( 1),O( 2),O( 3),
 | 
			
		||||
O( 0),O( 1),O( 2),O( 3),
 | 
			
		||||
O( 0),O( 1),O( 2),O( 3),
 | 
			
		||||
O( 0),O( 1),O( 2),O( 3),
 | 
			
		||||
O( 0),O( 1),O( 2),O( 3),
 | 
			
		||||
O(0),O(1),O(2),O(3),
 | 
			
		||||
O(0),O(1),O(2),O(3),
 | 
			
		||||
O(0),O(1),O(2),O(3),
 | 
			
		||||
O(0),O(1),O(2),O(3),
 | 
			
		||||
O(0),O(1),O(2),O(3),
 | 
			
		||||
O(0),O(1),O(2),O(3),
 | 
			
		||||
O(0),O(1),O(2),O(3),
 | 
			
		||||
O(0),O(1),O(2),O(3),
 | 
			
		||||
O(0),O(1),O(2),O(3),
 | 
			
		||||
O(0),O(1),O(2),O(3),
 | 
			
		||||
O(0),O(1),O(2),O(3),
 | 
			
		||||
O(0),O(1),O(2),O(3),
 | 
			
		||||
O(0),O(1),O(2),O(3),
 | 
			
		||||
 | 
			
		||||
/* rate 13 */
 | 
			
		||||
O( 4),O( 5),O( 6),O( 7),
 | 
			
		||||
O(4),O(5),O(6),O(7),
 | 
			
		||||
 | 
			
		||||
/* rate 14 */
 | 
			
		||||
O( 8),O( 9),O(10),O(11),
 | 
			
		||||
O(8),O(9),O(10),O(11),
 | 
			
		||||
 | 
			
		||||
/* rate 15 */
 | 
			
		||||
O(12),O(12),O(12),O(12),
 | 
			
		||||
| 
						 | 
				
			
			@ -1145,29 +1145,29 @@ O(0),O(0),O(0),O(0),O(0),O(0),O(0),O(0),
 | 
			
		|||
O(12),O(12),O(12),O(12),
 | 
			
		||||
O(11),O(11),O(11),O(11),
 | 
			
		||||
O(10),O(10),O(10),O(10),
 | 
			
		||||
O( 9),O( 9),O( 9),O( 9),
 | 
			
		||||
O( 8),O( 8),O( 8),O( 8),
 | 
			
		||||
O( 7),O( 7),O( 7),O( 7),
 | 
			
		||||
O( 6),O( 6),O( 6),O( 6),
 | 
			
		||||
O( 5),O( 5),O( 5),O( 5),
 | 
			
		||||
O( 4),O( 4),O( 4),O( 4),
 | 
			
		||||
O( 3),O( 3),O( 3),O( 3),
 | 
			
		||||
O( 2),O( 2),O( 2),O( 2),
 | 
			
		||||
O( 1),O( 1),O( 1),O( 1),
 | 
			
		||||
O( 0),O( 0),O( 0),O( 0),
 | 
			
		||||
O(9),O(9),O(9),O(9),
 | 
			
		||||
O(8),O(8),O(8),O(8),
 | 
			
		||||
O(7),O(7),O(7),O(7),
 | 
			
		||||
O(6),O(6),O(6),O(6),
 | 
			
		||||
O(5),O(5),O(5),O(5),
 | 
			
		||||
O(4),O(4),O(4),O(4),
 | 
			
		||||
O(3),O(3),O(3),O(3),
 | 
			
		||||
O(2),O(2),O(2),O(2),
 | 
			
		||||
O(1),O(1),O(1),O(1),
 | 
			
		||||
O(0),O(0),O(0),O(0),
 | 
			
		||||
 | 
			
		||||
/* rate 13 */
 | 
			
		||||
O( 0),O( 0),O( 0),O( 0),
 | 
			
		||||
O(0),O(0),O(0),O(0),
 | 
			
		||||
 | 
			
		||||
/* rate 14 */
 | 
			
		||||
O( 0),O( 0),O( 0),O( 0),
 | 
			
		||||
O(0),O(0),O(0),O(0),
 | 
			
		||||
 | 
			
		||||
/* rate 15 */
 | 
			
		||||
O( 0),O( 0),O( 0),O( 0),
 | 
			
		||||
O(0),O(0),O(0),O(0),
 | 
			
		||||
 | 
			
		||||
/* 16 dummy rates (same as 15 3) */
 | 
			
		||||
O( 0),O( 0),O( 0),O( 0),O( 0),O( 0),O( 0),O( 0),
 | 
			
		||||
O( 0),O( 0),O( 0),O( 0),O( 0),O( 0),O( 0),O( 0),
 | 
			
		||||
O(0),O(0),O(0),O(0),O(0),O(0),O(0),O(0),
 | 
			
		||||
O(0),O(0),O(0),O(0),O(0),O(0),O(0),O(0),
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
#undef O
 | 
			
		||||
| 
						 | 
				
			
			@ -1298,10 +1298,10 @@ int FM_OPL::num_lock = 0;
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static inline int limit( int val, int max, int min ) {
 | 
			
		||||
	if ( val > max )
 | 
			
		||||
static inline int limit(int val, int max, int min) {
 | 
			
		||||
	if (val > max)
 | 
			
		||||
		val = max;
 | 
			
		||||
	else if ( val < min )
 | 
			
		||||
	else if (val < min)
 | 
			
		||||
		val = min;
 | 
			
		||||
 | 
			
		||||
	return val;
 | 
			
		||||
| 
						 | 
				
			
			@ -1343,7 +1343,7 @@ int FM_OPL::init_tables()
 | 
			
		|||
	#if 0
 | 
			
		||||
			logerror("tl %04i", x*2);
 | 
			
		||||
			for (i=0; i<12; i++)
 | 
			
		||||
				logerror(", [%02i] %5i", i*2, tl_tab[ x*2 /*+1*/ + i*2*TL_RES_LEN ] );
 | 
			
		||||
				logerror(", [%02i] %5i", i*2, tl_tab[ x*2 /*+1*/ + i*2*TL_RES_LEN ]);
 | 
			
		||||
			logerror("\n");
 | 
			
		||||
	#endif
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -1353,7 +1353,7 @@ int FM_OPL::init_tables()
 | 
			
		|||
	for (i=0; i<SIN_LEN; i++)
 | 
			
		||||
	{
 | 
			
		||||
		/* non-standard sinus */
 | 
			
		||||
		m = sin( ((i*2)+1) * M_PI / SIN_LEN ); /* checked against the real chip */
 | 
			
		||||
		m = sin(((i*2)+1) * M_PI / SIN_LEN); /* checked against the real chip */
 | 
			
		||||
 | 
			
		||||
		/* we never reach zero here due to ((i*2)+1) */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1370,9 +1370,9 @@ int FM_OPL::init_tables()
 | 
			
		|||
		else
 | 
			
		||||
			n = n>>1;
 | 
			
		||||
 | 
			
		||||
		sin_tab[ i ] = n*2 + (m>=0.0? 0: 1 );
 | 
			
		||||
		sin_tab[ i ] = n*2 + (m>=0.0? 0: 1);
 | 
			
		||||
 | 
			
		||||
		/*logerror("FMOPL.C: sin [%4i (hex=%03x)]= %4i (tl_tab value=%5i)\n", i, i, sin_tab[i], tl_tab[sin_tab[i]] );*/
 | 
			
		||||
		/*logerror("FMOPL.C: sin [%4i (hex=%03x)]= %4i (tl_tab value=%5i)\n", i, i, sin_tab[i], tl_tab[sin_tab[i]]);*/
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for (i=0; i<SIN_LEN; i++)
 | 
			
		||||
| 
						 | 
				
			
			@ -1381,7 +1381,7 @@ int FM_OPL::init_tables()
 | 
			
		|||
		/*             /  \____/  \____*/
 | 
			
		||||
		/* output only first half of the sinus waveform (positive one) */
 | 
			
		||||
 | 
			
		||||
		if (i & (1<<(SIN_BITS-1)) )
 | 
			
		||||
		if (i & (1<<(SIN_BITS-1)))
 | 
			
		||||
			sin_tab[1*SIN_LEN+i] = TL_TAB_LEN;
 | 
			
		||||
		else
 | 
			
		||||
			sin_tab[1*SIN_LEN+i] = sin_tab[i];
 | 
			
		||||
| 
						 | 
				
			
			@ -1396,16 +1396,16 @@ int FM_OPL::init_tables()
 | 
			
		|||
		/*             / |_/ |_/ |_/ |_*/
 | 
			
		||||
		/* abs(output only first quarter of the sinus waveform) */
 | 
			
		||||
 | 
			
		||||
		if (i & (1<<(SIN_BITS-2)) )
 | 
			
		||||
		if (i & (1<<(SIN_BITS-2)))
 | 
			
		||||
			sin_tab[3*SIN_LEN+i] = TL_TAB_LEN;
 | 
			
		||||
		else
 | 
			
		||||
			sin_tab[3*SIN_LEN+i] = sin_tab[i & (SIN_MASK>>2)];
 | 
			
		||||
 | 
			
		||||
		/*logerror("FMOPL.C: sin1[%4i]= %4i (tl_tab value=%5i)\n", i, sin_tab[1*SIN_LEN+i], tl_tab[sin_tab[1*SIN_LEN+i]] );
 | 
			
		||||
		logerror("FMOPL.C: sin2[%4i]= %4i (tl_tab value=%5i)\n", i, sin_tab[2*SIN_LEN+i], tl_tab[sin_tab[2*SIN_LEN+i]] );
 | 
			
		||||
		logerror("FMOPL.C: sin3[%4i]= %4i (tl_tab value=%5i)\n", i, sin_tab[3*SIN_LEN+i], tl_tab[sin_tab[3*SIN_LEN+i]] );*/
 | 
			
		||||
		/*logerror("FMOPL.C: sin1[%4i]= %4i (tl_tab value=%5i)\n", i, sin_tab[1*SIN_LEN+i], tl_tab[sin_tab[1*SIN_LEN+i]]);
 | 
			
		||||
		logerror("FMOPL.C: sin2[%4i]= %4i (tl_tab value=%5i)\n", i, sin_tab[2*SIN_LEN+i], tl_tab[sin_tab[2*SIN_LEN+i]]);
 | 
			
		||||
		logerror("FMOPL.C: sin3[%4i]= %4i (tl_tab value=%5i)\n", i, sin_tab[3*SIN_LEN+i], tl_tab[sin_tab[3*SIN_LEN+i]]);*/
 | 
			
		||||
	}
 | 
			
		||||
	/*logerror("FMOPL.C: ENV_QUIET= %08x (dec*8=%i)\n", ENV_QUIET, ENV_QUIET*8 );*/
 | 
			
		||||
	/*logerror("FMOPL.C: ENV_QUIET= %08x (dec*8=%i)\n", ENV_QUIET, ENV_QUIET*8);*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef SAVE_SAMPLE
 | 
			
		||||
| 
						 | 
				
			
			@ -1433,29 +1433,29 @@ void FM_OPL::initialize()
 | 
			
		|||
	//TimerBase = attotime::from_hz(clock) * 72;
 | 
			
		||||
 | 
			
		||||
	/* make fnumber -> increment counter table */
 | 
			
		||||
	for( i=0 ; i < 1024 ; i++ )
 | 
			
		||||
	for(i=0 ; i < 1024 ; i++)
 | 
			
		||||
	{
 | 
			
		||||
		/* opn phase increment counter = 20bit */
 | 
			
		||||
		fn_tab[i] = (uint32_t)( (double)i * 64 * freqbase * (1<<(FREQ_SH-10)) ); /* -10 because chip works with 10.10 fixed point, while we use 16.16 */
 | 
			
		||||
		fn_tab[i] = (uint32_t)((double)i * 64 * freqbase * (1<<(FREQ_SH-10))); /* -10 because chip works with 10.10 fixed point, while we use 16.16 */
 | 
			
		||||
#if 0
 | 
			
		||||
		logerror("FMOPL.C: fn_tab[%4i] = %08x (dec=%8i)\n",
 | 
			
		||||
					i, fn_tab[i]>>6, fn_tab[i]>>6 );
 | 
			
		||||
					i, fn_tab[i]>>6, fn_tab[i]>>6);
 | 
			
		||||
#endif
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
	for( i=0 ; i < 16 ; i++ )
 | 
			
		||||
	for(i=0 ; i < 16 ; i++)
 | 
			
		||||
	{
 | 
			
		||||
		logerror("FMOPL.C: sl_tab[%i] = %08x\n",
 | 
			
		||||
			i, sl_tab[i] );
 | 
			
		||||
			i, sl_tab[i]);
 | 
			
		||||
	}
 | 
			
		||||
	for( i=0 ; i < 8 ; i++ )
 | 
			
		||||
	for(i=0 ; i < 8 ; i++)
 | 
			
		||||
	{
 | 
			
		||||
		int j;
 | 
			
		||||
		logerror("FMOPL.C: ksl_tab[oct=%2i] =",i);
 | 
			
		||||
		for (j=0; j<16; j++)
 | 
			
		||||
		{
 | 
			
		||||
			logerror("%08x ", static_cast<uint32_t>(ksl_tab[i*16+j]) );
 | 
			
		||||
			logerror("%08x ", static_cast<uint32_t>(ksl_tab[i*16+j]));
 | 
			
		||||
		}
 | 
			
		||||
		logerror("\n");
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -1464,7 +1464,7 @@ void FM_OPL::initialize()
 | 
			
		|||
 | 
			
		||||
	/* Amplitude modulation: 27 output levels (triangle waveform); 1 level takes one of: 192, 256 or 448 samples */
 | 
			
		||||
	/* One entry from LFO_AM_TABLE lasts for 64 samples */
 | 
			
		||||
	lfo_am_inc = (1.0 / 64.0 ) * (1<<LFO_SH) * freqbase;
 | 
			
		||||
	lfo_am_inc = (1.0 / 64.0) * (1<<LFO_SH) * freqbase;
 | 
			
		||||
 | 
			
		||||
	/* Vibrato: 8 output levels (triangle waveform); 1 level takes 1024 samples */
 | 
			
		||||
	lfo_pm_inc = (1.0 / 1024.0) * (1<<LFO_SH) * freqbase;
 | 
			
		||||
| 
						 | 
				
			
			@ -1475,7 +1475,7 @@ void FM_OPL::initialize()
 | 
			
		|||
	noise_f = (1.0 / 1.0) * (1<<FREQ_SH) * freqbase;
 | 
			
		||||
 | 
			
		||||
	eg_timer_add  = (1<<EG_SH)  * freqbase;
 | 
			
		||||
	eg_timer_overflow = ( 1 ) * (1<<EG_SH);
 | 
			
		||||
	eg_timer_overflow = (1) * (1<<EG_SH);
 | 
			
		||||
	/*logerror("OPLinit eg_timer_add=%8x eg_timer_overflow=%8x\n", eg_timer_add, eg_timer_overflow);*/
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1646,16 +1646,16 @@ void FM_OPL::WriteReg(int r, int v)
 | 
			
		|||
					P_CH[6].SLOT[SLOT2].KEYOFF(~2);
 | 
			
		||||
				}
 | 
			
		||||
				/* HH key on/off */
 | 
			
		||||
				if(v&0x01) P_CH[7].SLOT[SLOT1].KEYON ( 2);
 | 
			
		||||
				if(v&0x01) P_CH[7].SLOT[SLOT1].KEYON (2);
 | 
			
		||||
				else       P_CH[7].SLOT[SLOT1].KEYOFF(~2);
 | 
			
		||||
				/* SD key on/off */
 | 
			
		||||
				if(v&0x08) P_CH[7].SLOT[SLOT2].KEYON ( 2);
 | 
			
		||||
				if(v&0x08) P_CH[7].SLOT[SLOT2].KEYON (2);
 | 
			
		||||
				else       P_CH[7].SLOT[SLOT2].KEYOFF(~2);
 | 
			
		||||
				/* TOM key on/off */
 | 
			
		||||
				if(v&0x04) P_CH[8].SLOT[SLOT1].KEYON ( 2);
 | 
			
		||||
				if(v&0x04) P_CH[8].SLOT[SLOT1].KEYON (2);
 | 
			
		||||
				else       P_CH[8].SLOT[SLOT1].KEYOFF(~2);
 | 
			
		||||
				/* TOP-CY key on/off */
 | 
			
		||||
				if(v&0x02) P_CH[8].SLOT[SLOT2].KEYON ( 2);
 | 
			
		||||
				if(v&0x02) P_CH[8].SLOT[SLOT2].KEYON (2);
 | 
			
		||||
				else       P_CH[8].SLOT[SLOT2].KEYOFF(~2);
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
| 
						 | 
				
			
			@ -1675,7 +1675,7 @@ void FM_OPL::WriteReg(int r, int v)
 | 
			
		|||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		/* keyon,block,fnum */
 | 
			
		||||
		if( (r&0x0f) > 8) return;
 | 
			
		||||
		if((r&0x0f) > 8) return;
 | 
			
		||||
		CH = &P_CH[r&0x0f];
 | 
			
		||||
		if(!(r&0x10))
 | 
			
		||||
		{   /* a0-a8 */
 | 
			
		||||
| 
						 | 
				
			
			@ -1687,8 +1687,8 @@ void FM_OPL::WriteReg(int r, int v)
 | 
			
		|||
 | 
			
		||||
			if(v&0x20)
 | 
			
		||||
			{
 | 
			
		||||
				CH->SLOT[SLOT1].KEYON ( 1);
 | 
			
		||||
				CH->SLOT[SLOT2].KEYON ( 1);
 | 
			
		||||
				CH->SLOT[SLOT1].KEYON (1);
 | 
			
		||||
				CH->SLOT[SLOT2].KEYON (1);
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
| 
						 | 
				
			
			@ -1728,7 +1728,7 @@ void FM_OPL::WriteReg(int r, int v)
 | 
			
		|||
		break;
 | 
			
		||||
	case 0xc0:
 | 
			
		||||
		/* FB,C */
 | 
			
		||||
		if( (r&0x0f) > 8) return;
 | 
			
		||||
		if((r&0x0f) > 8) return;
 | 
			
		||||
		CH = &P_CH[r&0x0f];
 | 
			
		||||
		CH->SLOT[SLOT1].FB  = (v>>1)&7 ? ((v>>1)&7) + 7 : 0;
 | 
			
		||||
		CH->SLOT[SLOT1].CON = v&1;
 | 
			
		||||
| 
						 | 
				
			
			@ -1763,15 +1763,15 @@ void FM_OPL::ResetChip()
 | 
			
		|||
	WriteReg(0x02,0); /* Timer1 */
 | 
			
		||||
	WriteReg(0x03,0); /* Timer2 */
 | 
			
		||||
	WriteReg(0x04,0); /* IRQ mask clear */
 | 
			
		||||
	for(int i = 0xff ; i >= 0x20 ; i-- ) WriteReg(i,0);
 | 
			
		||||
	for(int i = 0xff ; i >= 0x20 ; i--) WriteReg(i,0);
 | 
			
		||||
 | 
			
		||||
	/* reset operator parameters */
 | 
			
		||||
//	for(OPL_CH &CH : P_CH)
 | 
			
		||||
	for(int ch = 0; ch < sizeof( P_CH )/ sizeof(P_CH[0]); ch++)
 | 
			
		||||
	for(int ch = 0; ch < sizeof(P_CH)/ sizeof(P_CH[0]); ch++)
 | 
			
		||||
	{
 | 
			
		||||
		OPL_CH &CH = P_CH[ch];
 | 
			
		||||
//		for(OPL_SLOT &SLOT : CH.SLOT)
 | 
			
		||||
		for(int slot = 0; slot < sizeof( CH.SLOT ) / sizeof( CH.SLOT[0]); slot++)
 | 
			
		||||
		for(int slot = 0; slot < sizeof(CH.SLOT) / sizeof(CH.SLOT[0]); slot++)
 | 
			
		||||
		{
 | 
			
		||||
		    
 | 
			
		||||
			OPL_SLOT &SLOT = CH.SLOT[slot];
 | 
			
		||||
| 
						 | 
				
			
			@ -1798,7 +1798,7 @@ void FM_OPL::ResetChip()
 | 
			
		|||
 | 
			
		||||
void FM_OPL::postload()
 | 
			
		||||
{
 | 
			
		||||
	for(int ch = 0; ch < sizeof( P_CH )/ sizeof(P_CH[0]); ch++)
 | 
			
		||||
	for(int ch = 0; ch < sizeof(P_CH)/ sizeof(P_CH[0]); ch++)
 | 
			
		||||
	{
 | 
			
		||||
		OPL_CH &CH = P_CH[ch];
 | 
			
		||||
		/* Look up key scale level */
 | 
			
		||||
| 
						 | 
				
			
			@ -1806,7 +1806,7 @@ void FM_OPL::postload()
 | 
			
		|||
		CH.ksl_base = static_cast<uint32_t>(ksl_tab[block_fnum >> 6]);
 | 
			
		||||
		CH.fc       = fn_tab[block_fnum & 0x03ff] >> (7 - (block_fnum >> 10));
 | 
			
		||||
 | 
			
		||||
		for(int slot = 0; slot < sizeof( CH.SLOT ) / sizeof( CH.SLOT[0]); slot++)
 | 
			
		||||
		for(int slot = 0; slot < sizeof(CH.SLOT) / sizeof(CH.SLOT[0]); slot++)
 | 
			
		||||
		{
 | 
			
		||||
			OPL_SLOT &SLOT = CH.SLOT[slot];
 | 
			
		||||
			/* Calculate key scale rate */
 | 
			
		||||
| 
						 | 
				
			
			@ -1839,7 +1839,7 @@ void FM_OPL::postload()
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
#if BUILD_Y8950
 | 
			
		||||
	if ( (type & OPL_TYPE_ADPCM) && (deltat) )
 | 
			
		||||
	if ((type & OPL_TYPE_ADPCM) && (deltat))
 | 
			
		||||
	{
 | 
			
		||||
		// We really should call the postlod function for the YM_DELTAT, but it's hard without registers
 | 
			
		||||
		// (see the way the YM2610 does it)
 | 
			
		||||
| 
						 | 
				
			
			@ -1856,13 +1856,13 @@ static void OPLsave_state_channel(device_t *device, OPL_CH *CH)
 | 
			
		|||
{
 | 
			
		||||
	int slot, ch;
 | 
			
		||||
 | 
			
		||||
	for( ch=0 ; ch < 9 ; ch++, CH++ )
 | 
			
		||||
	for(ch=0 ; ch < 9 ; ch++, CH++)
 | 
			
		||||
	{
 | 
			
		||||
		/* channel */
 | 
			
		||||
		device->save_item(NAME(CH->block_fnum), ch);
 | 
			
		||||
		device->save_item(NAME(CH->kcode), ch);
 | 
			
		||||
		/* slots */
 | 
			
		||||
		for( slot=0 ; slot < 2 ; slot++ )
 | 
			
		||||
		for(slot=0 ; slot < 2 ; slot++)
 | 
			
		||||
		{
 | 
			
		||||
			OPL_SLOT *SLOT = &CH->SLOT[slot];
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1912,7 +1912,7 @@ static void OPL_save_state(FM_OPL *OPL, device_t *device)
 | 
			
		|||
	device->save_item(NAME(OPL->noise_rng));
 | 
			
		||||
	device->save_item(NAME(OPL->noise_p));
 | 
			
		||||
 | 
			
		||||
	if( OPL->type & OPL_TYPE_WAVESEL )
 | 
			
		||||
	if(OPL->type & OPL_TYPE_WAVESEL)
 | 
			
		||||
	{
 | 
			
		||||
		device->save_item(NAME(OPL->wavesel));
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -1921,12 +1921,12 @@ static void OPL_save_state(FM_OPL *OPL, device_t *device)
 | 
			
		|||
	device->save_item(NAME(OPL->st));
 | 
			
		||||
 | 
			
		||||
#if BUILD_Y8950
 | 
			
		||||
	if ( (OPL->type & OPL_TYPE_ADPCM) && (OPL->deltat) )
 | 
			
		||||
	if ((OPL->type & OPL_TYPE_ADPCM) && (OPL->deltat))
 | 
			
		||||
	{
 | 
			
		||||
		OPL->deltat->savestate(device);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ( OPL->type & OPL_TYPE_IO )
 | 
			
		||||
	if (OPL->type & OPL_TYPE_IO)
 | 
			
		||||
	{
 | 
			
		||||
		device->save_item(NAME(OPL->portDirection));
 | 
			
		||||
		device->save_item(NAME(OPL->portLatch));
 | 
			
		||||
| 
						 | 
				
			
			@ -1961,10 +1961,10 @@ static FM_OPL *OPLCreate(device_t *device, uint32_t clock, uint32_t rate, int ty
 | 
			
		|||
	if (FM_OPL::LockTable(device) == -1) return 0;
 | 
			
		||||
 | 
			
		||||
	/* calculate OPL state size */
 | 
			
		||||
	int state_size  = sizeof(FM_OPL);
 | 
			
		||||
	int state_size = sizeof(FM_OPL);
 | 
			
		||||
 | 
			
		||||
#if BUILD_Y8950
 | 
			
		||||
	if (type&OPL_TYPE_ADPCM) state_size+= sizeof(YM_DELTAT);
 | 
			
		||||
	if (type & OPL_TYPE_ADPCM) state_size += sizeof(YM_DELTAT);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	/* allocate memory block */
 | 
			
		||||
| 
						 | 
				
			
			@ -2020,7 +2020,7 @@ static void OPLSetUpdateHandler(FM_OPL *OPL,OPL_UPDATEHANDLER UpdateHandler,devi
 | 
			
		|||
 | 
			
		||||
static int OPLWrite(FM_OPL *OPL,int a,int v)
 | 
			
		||||
{
 | 
			
		||||
	if( !(a&1) )
 | 
			
		||||
	if(!(a&1))
 | 
			
		||||
	{   /* address port */
 | 
			
		||||
		OPL->address = v & 0xff;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -2034,7 +2034,7 @@ static int OPLWrite(FM_OPL *OPL,int a,int v)
 | 
			
		|||
 | 
			
		||||
static unsigned char OPLRead(FM_OPL *OPL,int a)
 | 
			
		||||
{
 | 
			
		||||
	if( !(a&1) )
 | 
			
		||||
	if(!(a&1))
 | 
			
		||||
	{
 | 
			
		||||
		/* status port */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -2112,7 +2112,7 @@ static inline void CSMKeyControll(OPL_CH *CH)
 | 
			
		|||
 | 
			
		||||
static int OPLTimerOver(FM_OPL *OPL,int c)
 | 
			
		||||
{
 | 
			
		||||
	if( c )
 | 
			
		||||
	if(c)
 | 
			
		||||
	{   /* Timer B */
 | 
			
		||||
		OPL->STATUS_SET(0x20);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -2120,12 +2120,12 @@ static int OPLTimerOver(FM_OPL *OPL,int c)
 | 
			
		|||
	{   /* Timer A */
 | 
			
		||||
		OPL->STATUS_SET(0x40);
 | 
			
		||||
		/* CSM mode key,TL controll */
 | 
			
		||||
		if( OPL->mode & 0x80 )
 | 
			
		||||
		if(OPL->mode & 0x80)
 | 
			
		||||
		{   /* CSM mode total level latch and auto key on */
 | 
			
		||||
			int ch;
 | 
			
		||||
			if(OPL->UpdateHandler) OPL->UpdateHandler(OPL->UpdateParam,0);
 | 
			
		||||
			for(ch=0; ch<9; ch++)
 | 
			
		||||
				CSMKeyControll( &OPL->P_CH[ch] );
 | 
			
		||||
				CSMKeyControll(&OPL->P_CH[ch]);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	/* reload timer */
 | 
			
		||||
| 
						 | 
				
			
			@ -2216,7 +2216,7 @@ void ym3812_update_one(void *chip, OPLSAMPLE *buffer, int length)
 | 
			
		|||
	OPLSAMPLE   *buf = buffer;
 | 
			
		||||
	int i;
 | 
			
		||||
 | 
			
		||||
	for( i=0; i < length ; i++ )
 | 
			
		||||
	for(i=0; i < length ; i++)
 | 
			
		||||
	{
 | 
			
		||||
		int lt;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -2248,7 +2248,7 @@ void ym3812_update_one(void *chip, OPLSAMPLE *buffer, int length)
 | 
			
		|||
		lt >>= FINAL_SH;
 | 
			
		||||
 | 
			
		||||
		/* limit check */
 | 
			
		||||
		lt = limit( lt , MAXOUT, MINOUT );
 | 
			
		||||
		lt = limit(lt , MAXOUT, MINOUT);
 | 
			
		||||
 | 
			
		||||
		#ifdef SAVE_SAMPLE
 | 
			
		||||
		if (which==0)
 | 
			
		||||
| 
						 | 
				
			
			@ -2348,7 +2348,7 @@ void ym3526_update_one(void *chip, OPLSAMPLE *buffer, int length)
 | 
			
		|||
	OPLSAMPLE   *buf = buffer;
 | 
			
		||||
	int i;
 | 
			
		||||
 | 
			
		||||
	for( i=0; i < length ; i++ )
 | 
			
		||||
	for(i=0; i < length ; i++)
 | 
			
		||||
	{
 | 
			
		||||
		int lt;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -2380,7 +2380,7 @@ void ym3526_update_one(void *chip, OPLSAMPLE *buffer, int length)
 | 
			
		|||
		lt >>= FINAL_SH;
 | 
			
		||||
 | 
			
		||||
		/* limit check */
 | 
			
		||||
		lt = limit( lt , MAXOUT, MINOUT );
 | 
			
		||||
		lt = limit(lt , MAXOUT, MINOUT);
 | 
			
		||||
 | 
			
		||||
		#ifdef SAVE_SAMPLE
 | 
			
		||||
		if (which==0)
 | 
			
		||||
| 
						 | 
				
			
			@ -2481,7 +2481,7 @@ void y8950_set_update_handler(void *chip,OPL_UPDATEHANDLER UpdateHandler,device_
 | 
			
		|||
	OPLSetUpdateHandler(Y8950, UpdateHandler, device);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void y8950_set_delta_t_memory(void *chip, void * deltat_mem_ptr, int deltat_mem_size )
 | 
			
		||||
void y8950_set_delta_t_memory(void *chip, void * deltat_mem_ptr, int deltat_mem_size)
 | 
			
		||||
{
 | 
			
		||||
	FM_OPL      *OPL = (FM_OPL *)chip;
 | 
			
		||||
	OPL->deltat->memory = (uint8_t *)(deltat_mem_ptr);
 | 
			
		||||
| 
						 | 
				
			
			@ -2503,7 +2503,7 @@ void y8950_update_one(void *chip, OPLSAMPLE *buffer, int length)
 | 
			
		|||
	YM_DELTAT   *DELTAT = OPL->deltat;
 | 
			
		||||
	OPLSAMPLE   *buf    = buffer;
 | 
			
		||||
 | 
			
		||||
	for( i=0; i < length ; i++ )
 | 
			
		||||
	for(i=0; i < length ; i++)
 | 
			
		||||
	{
 | 
			
		||||
		int lt;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -2513,7 +2513,7 @@ void y8950_update_one(void *chip, OPLSAMPLE *buffer, int length)
 | 
			
		|||
		OPL->advance_lfo();
 | 
			
		||||
 | 
			
		||||
		/* deltaT ADPCM */
 | 
			
		||||
		if( DELTAT->portstate&0x80 )
 | 
			
		||||
		if(DELTAT->portstate&0x80)
 | 
			
		||||
			DELTAT->ADPCM_CALC();
 | 
			
		||||
 | 
			
		||||
		/* FM part */
 | 
			
		||||
| 
						 | 
				
			
			@ -2540,7 +2540,7 @@ void y8950_update_one(void *chip, OPLSAMPLE *buffer, int length)
 | 
			
		|||
		lt >>= FINAL_SH;
 | 
			
		||||
 | 
			
		||||
		/* limit check */
 | 
			
		||||
		lt = limit( lt , MAXOUT, MINOUT );
 | 
			
		||||
		lt = limit(lt , MAXOUT, MINOUT);
 | 
			
		||||
 | 
			
		||||
		#ifdef SAVE_SAMPLE
 | 
			
		||||
		if (which==0)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| 
						 | 
				
			
			@ -551,25 +551,39 @@ public:
 | 
			
		|||
		Section_prop * section=static_cast<Section_prop *>(configuration);
 | 
			
		||||
	
 | 
			
		||||
		/* Setup the Physical Page Links */
 | 
			
		||||
		Bitu memsize=section->Get_int("memsize");
 | 
			
		||||
		uint16_t memsize = section->Get_int("memsize");
 | 
			
		||||
	
 | 
			
		||||
		if (memsize < 1) memsize = 1;
 | 
			
		||||
		/* max 63 to solve problems with certain xms handlers */
 | 
			
		||||
		if (memsize > MAX_MEMORY-1) {
 | 
			
		||||
		if (memsize > MAX_MEMORY - 1) {
 | 
			
		||||
			LOG_MSG("Maximum memory size is %d MB",MAX_MEMORY - 1);
 | 
			
		||||
			memsize = MAX_MEMORY-1;
 | 
			
		||||
			memsize = MAX_MEMORY - 1;
 | 
			
		||||
		}
 | 
			
		||||
		if (memsize > SAFE_MEMORY-1) {
 | 
			
		||||
		if (memsize > SAFE_MEMORY - 1) {
 | 
			
		||||
			LOG_MSG("Memory sizes above %d MB are NOT recommended.",SAFE_MEMORY - 1);
 | 
			
		||||
			LOG_MSG("Stick with the default values unless you are absolutely certain.");
 | 
			
		||||
		}
 | 
			
		||||
		MemBase = new Bit8u[memsize*1024*1024];
 | 
			
		||||
		memset((void*)MemBase,0,memsize*1024*1024);
 | 
			
		||||
		memory.pages = (memsize*1024*1024)/4096;
 | 
			
		||||
		MemBase = new (std::nothrow) Bit8u[memsize * 1024 * 1024];
 | 
			
		||||
		if (!MemBase) {
 | 
			
		||||
			E_Exit("Can't allocate main memory of %u MB", memsize);
 | 
			
		||||
		}
 | 
			
		||||
		memset((void*)MemBase, 0, memsize * 1024 * 1024);
 | 
			
		||||
		memory.pages = (memsize * 1024 * 1024) / 4096;
 | 
			
		||||
 | 
			
		||||
		/* Allocate the data for the different page information blocks */
 | 
			
		||||
		memory.phandlers=new  PageHandler * [memory.pages];
 | 
			
		||||
		memory.mhandles=new MemHandle [memory.pages];
 | 
			
		||||
		for (i = 0;i < memory.pages;i++) {
 | 
			
		||||
		memory.phandlers = new (std::nothrow) PageHandler * [memory.pages];
 | 
			
		||||
		if (!memory.phandlers) {
 | 
			
		||||
			E_Exit("Can't allocate %" PRIuPTR " bytes for the PageHandler array",
 | 
			
		||||
			       sizeof(PageHandler*) * memory.pages);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		memory.mhandles = new (std::nothrow) MemHandle [memory.pages];
 | 
			
		||||
		if (!memory.mhandles) {
 | 
			
		||||
			E_Exit("Can't allocate %" PRIuPTR " bytes worth of memory handles",
 | 
			
		||||
			       sizeof(MemHandle) * memory.pages);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for (i = 0; i < memory.pages; i++) {
 | 
			
		||||
			memory.phandlers[i] = &ram_page_handler;
 | 
			
		||||
			memory.mhandles[i] = 0;				//Set to 0 for memory allocation
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -63,7 +63,7 @@ void PROGRAMS_MakeFile(char const * const name,PROGRAMS_Main * main) {
 | 
			
		|||
	comdata[CB_POS+1]=(Bit8u)((call_program>>8)&0xff);
 | 
			
		||||
 | 
			
		||||
	/* Copy save the pointer in the vector and save it's index */
 | 
			
		||||
	if (internal_progs.size()>255) E_Exit("PROGRAMS_MakeFile program size too large (%d)",static_cast<int>(internal_progs.size()));
 | 
			
		||||
	if (internal_progs.size() > 255) E_Exit("PROGRAMS_MakeFile program size too large (%d)",static_cast<int>(internal_progs.size()));
 | 
			
		||||
	Bit8u index = (Bit8u)internal_progs.size();
 | 
			
		||||
	internal_progs.push_back(main);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -144,7 +144,7 @@ void Program::WriteOut(const char * format,...) {
 | 
			
		|||
 | 
			
		||||
	Bit16u size = (Bit16u)strlen(buf);
 | 
			
		||||
	dos.internal_output=true;
 | 
			
		||||
	for(Bit16u i = 0; i < size;i++) {
 | 
			
		||||
	for (Bit16u i = 0; i < size; i++) {
 | 
			
		||||
		Bit8u out;Bit16u s=1;
 | 
			
		||||
		if (buf[i] == 0xA && last_written_character != 0xD) {
 | 
			
		||||
			out = 0xD;DOS_WriteFile(STDOUT,&out,&s);
 | 
			
		||||
| 
						 | 
				
			
			@ -161,7 +161,7 @@ void Program::WriteOut_NoParsing(const char * format) {
 | 
			
		|||
	Bit16u size = (Bit16u)strlen(format);
 | 
			
		||||
	char const* buf = format;
 | 
			
		||||
	dos.internal_output=true;
 | 
			
		||||
	for(Bit16u i = 0; i < size;i++) {
 | 
			
		||||
	for (Bit16u i = 0; i < size; i++) {
 | 
			
		||||
		Bit8u out;Bit16u s=1;
 | 
			
		||||
		if (buf[i] == 0xA && last_written_character != 0xD) {
 | 
			
		||||
			out = 0xD;DOS_WriteFile(STDOUT,&out,&s);
 | 
			
		||||
| 
						 | 
				
			
			@ -228,7 +228,7 @@ bool Program::SetEnv(const char * entry,const char * new_string) {
 | 
			
		|||
	PhysPt env_read = PhysMake(psp->GetEnvironment(),0);
 | 
			
		||||
	
 | 
			
		||||
	//Get size of environment.
 | 
			
		||||
	DOS_MCB mcb(psp->GetEnvironment()-1);
 | 
			
		||||
	DOS_MCB mcb(psp->GetEnvironment() - 1);
 | 
			
		||||
	Bit16u envsize = mcb.GetSize()*16;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -315,7 +315,7 @@ void CONFIG::Run(void) {
 | 
			
		|||
	bool first = true;
 | 
			
		||||
	std::vector<std::string> pvars;
 | 
			
		||||
	// Loop through the passed parameters
 | 
			
		||||
	while(presult != P_NOPARAMS) {
 | 
			
		||||
	while (presult != P_NOPARAMS) {
 | 
			
		||||
		presult = (enum prs)cmd->GetParameterFromList(params, pvars);
 | 
			
		||||
		switch(presult) {
 | 
			
		||||
		
 | 
			
		||||
| 
						 | 
				
			
			@ -325,7 +325,7 @@ void CONFIG::Run(void) {
 | 
			
		|||
			else {
 | 
			
		||||
				std::vector<std::string> restart_params;
 | 
			
		||||
				restart_params.push_back(control->cmdline->GetFileName());
 | 
			
		||||
				for(size_t i = 0; i < pvars.size(); i++) {
 | 
			
		||||
				for (size_t i = 0; i < pvars.size(); i++) {
 | 
			
		||||
					restart_params.push_back(pvars[i]);
 | 
			
		||||
					if (pvars[i].find(' ') != std::string::npos) {
 | 
			
		||||
						pvars[i] = "\""+pvars[i]+"\""; // add back spaces
 | 
			
		||||
| 
						 | 
				
			
			@ -347,13 +347,13 @@ void CONFIG::Run(void) {
 | 
			
		|||
				WriteOut(MSG_Get("PROGRAM_CONFIG_PRIMARY_CONF"),control->configfiles.front().c_str());
 | 
			
		||||
				if (size > 1) {
 | 
			
		||||
					WriteOut(MSG_Get("PROGRAM_CONFIG_ADDITIONAL_CONF"));
 | 
			
		||||
					for(Bitu i = 1; i < size; i++)
 | 
			
		||||
					for (Bitu i = 1; i < size; i++)
 | 
			
		||||
						WriteOut("%s\n",control->configfiles[i].c_str());
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			if (control->startup_params.size() > 0) {
 | 
			
		||||
				std::string test;
 | 
			
		||||
				for(size_t k = 0; k < control->startup_params.size(); k++)
 | 
			
		||||
				for (size_t k = 0; k < control->startup_params.size(); k++)
 | 
			
		||||
					test += control->startup_params[k] + " ";
 | 
			
		||||
				WriteOut(MSG_Get("PROGRAM_CONFIG_PRINT_STARTUP"), test.c_str());
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			@ -410,7 +410,7 @@ void CONFIG::Run(void) {
 | 
			
		|||
					// list the sections
 | 
			
		||||
					WriteOut(MSG_Get("PROGRAM_CONFIG_HLP_SECTLIST"));
 | 
			
		||||
					Bitu i = 0;
 | 
			
		||||
					while(true) {
 | 
			
		||||
					while (true) {
 | 
			
		||||
						Section* sec = control->GetSection(i++);
 | 
			
		||||
						if (!sec) break;
 | 
			
		||||
						WriteOut("%s\n",sec->GetName());
 | 
			
		||||
| 
						 | 
				
			
			@ -466,7 +466,7 @@ void CONFIG::Run(void) {
 | 
			
		|||
			if (pvars.size()==1) {
 | 
			
		||||
				size_t i = 0;
 | 
			
		||||
				WriteOut(MSG_Get("PROGRAM_CONFIG_HLP_SECTHLP"),pvars[0].c_str());
 | 
			
		||||
				while(true) {
 | 
			
		||||
				while (true) {
 | 
			
		||||
					// list the properties
 | 
			
		||||
					Property* p = psec->Get_prop(i++);
 | 
			
		||||
					if (p==NULL) break;
 | 
			
		||||
| 
						 | 
				
			
			@ -498,7 +498,7 @@ void CONFIG::Run(void) {
 | 
			
		|||
								propvalues += oss.str();
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
						for(Bitu k = 0; k < pv.size(); k++) {
 | 
			
		||||
						for (Bitu k = 0; k < pv.size(); k++) {
 | 
			
		||||
							if (pv[k].ToString() =="%u")
 | 
			
		||||
								propvalues += MSG_Get("PROGRAM_CONFIG_HLP_POSINT");
 | 
			
		||||
							else propvalues += pv[k].ToString();
 | 
			
		||||
| 
						 | 
				
			
			@ -543,7 +543,7 @@ void CONFIG::Run(void) {
 | 
			
		|||
				WriteOut(MSG_Get("PROGRAM_CONFIG_SECTION_ERROR"));
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			for(Bitu i = 0; i < pvars.size(); i++) {
 | 
			
		||||
			for (Bitu i = 0; i < pvars.size(); i++) {
 | 
			
		||||
				sec->HandleInputline(pvars[i]);
 | 
			
		||||
			}
 | 
			
		||||
			break;
 | 
			
		||||
| 
						 | 
				
			
			@ -590,7 +590,7 @@ void CONFIG::Run(void) {
 | 
			
		|||
						WriteOut("%s",pline->data.c_str());
 | 
			
		||||
						break;
 | 
			
		||||
					}
 | 
			
		||||
					while(true) {
 | 
			
		||||
					while (true) {
 | 
			
		||||
						// list the properties
 | 
			
		||||
						Property* p = psec->Get_prop(i++);
 | 
			
		||||
						if (p==NULL) break;
 | 
			
		||||
| 
						 | 
				
			
			@ -723,7 +723,7 @@ void CONFIG::Run(void) {
 | 
			
		|||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			if(pvars.size() < 3) {
 | 
			
		||||
			if (pvars.size() < 3) {
 | 
			
		||||
				WriteOut(MSG_Get("PROGRAM_CONFIG_SET_SYNTAX"));
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			@ -740,7 +740,7 @@ void CONFIG::Run(void) {
 | 
			
		|||
			std::string value(pvars[2]);
 | 
			
		||||
			//Due to parsing there can be a = at the start of value.
 | 
			
		||||
			while (value.size() && (value.at(0) ==' ' ||value.at(0) =='=') ) value.erase(0,1);
 | 
			
		||||
			for(Bitu i = 3; i < pvars.size(); i++) value += (std::string(" ") + pvars[i]);
 | 
			
		||||
			for (Bitu i = 3; i < pvars.size(); i++) value += (std::string(" ") + pvars[i]);
 | 
			
		||||
			if (value.empty() ) {
 | 
			
		||||
				WriteOut(MSG_Get("PROGRAM_CONFIG_SET_SYNTAX"));
 | 
			
		||||
				return;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -48,7 +48,7 @@ static SHELL_Cmd cmd_list[]={
 | 
			
		|||
{	"DELETE",	1,			&DOS_Shell::CMD_DELETE,		"SHELL_CMD_DELETE_HELP"},
 | 
			
		||||
{	"ERASE",	1,			&DOS_Shell::CMD_DELETE,		"SHELL_CMD_DELETE_HELP"},
 | 
			
		||||
{	"ECHO",		1,			&DOS_Shell::CMD_ECHO,		"SHELL_CMD_ECHO_HELP"},
 | 
			
		||||
{	"EXIT",		0,			&DOS_Shell::CMD_EXIT,		"SHELL_CMD_EXIT_HELP"},	
 | 
			
		||||
{	"EXIT",		0,			&DOS_Shell::CMD_EXIT,		"SHELL_CMD_EXIT_HELP"},
 | 
			
		||||
{	"GOTO",		1,			&DOS_Shell::CMD_GOTO,		"SHELL_CMD_GOTO_HELP"},
 | 
			
		||||
{	"HELP",		1,			&DOS_Shell::CMD_HELP,		"SHELL_CMD_HELP_HELP"},
 | 
			
		||||
{	"IF",		1,			&DOS_Shell::CMD_IF,			"SHELL_CMD_IF_HELP"},
 | 
			
		||||
| 
						 | 
				
			
			@ -70,28 +70,28 @@ static SHELL_Cmd cmd_list[]={
 | 
			
		|||
{	"TYPE",		0,			&DOS_Shell::CMD_TYPE,		"SHELL_CMD_TYPE_HELP"},
 | 
			
		||||
{	"VER",		0,			&DOS_Shell::CMD_VER,		"SHELL_CMD_VER_HELP"},
 | 
			
		||||
{0,0,0,0}
 | 
			
		||||
}; 
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* support functions */
 | 
			
		||||
static char empty_char = 0;
 | 
			
		||||
static char* empty_string = &empty_char;
 | 
			
		||||
static void StripSpaces(char*&args) {
 | 
			
		||||
	while(args && *args && isspace(*reinterpret_cast<unsigned char*>(args)))
 | 
			
		||||
	while (args && *args && isspace(*reinterpret_cast<unsigned char*>(args)))
 | 
			
		||||
		args++;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void StripSpaces(char*&args,char also) {
 | 
			
		||||
	while(args && *args && (isspace(*reinterpret_cast<unsigned char*>(args)) || (*args == also)))
 | 
			
		||||
	while (args && *args && (isspace(*reinterpret_cast<unsigned char*>(args)) || (*args == also)))
 | 
			
		||||
		args++;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static char* ExpandDot(char*args, char* buffer , size_t bufsize) {
 | 
			
		||||
	if(*args == '.') {
 | 
			
		||||
		if(*(args+1) == 0){
 | 
			
		||||
	if (*args == '.') {
 | 
			
		||||
		if (*(args+1) == 0){
 | 
			
		||||
			safe_strncpy(buffer, "*.*", bufsize);
 | 
			
		||||
			return buffer;
 | 
			
		||||
		}
 | 
			
		||||
		if( (*(args+1) != '.') && (*(args+1) != '\\') ) {
 | 
			
		||||
		if ( (*(args+1) != '.') && (*(args+1) != '\\') ) {
 | 
			
		||||
			buffer[0] = '*';
 | 
			
		||||
			buffer[1] = 0;
 | 
			
		||||
			if (bufsize > 2) strncat(buffer,args,bufsize - 1 /*used buffer portion*/ - 1 /*trailing zero*/  );
 | 
			
		||||
| 
						 | 
				
			
			@ -135,12 +135,12 @@ void DOS_Shell::DoCommand(char * line) {
 | 
			
		|||
		if (*line == '/') break;
 | 
			
		||||
		if (*line == '\t') break;
 | 
			
		||||
		if (*line == '=') break;
 | 
			
		||||
//		if (*line == ':') break; //This breaks drive switching as that is handled at a later stage. 
 | 
			
		||||
//		if (*line == ':') break; //This breaks drive switching as that is handled at a later stage.
 | 
			
		||||
		if ((*line == '.') ||(*line == '\\')) {  //allow stuff like cd.. and dir.exe cd\kees
 | 
			
		||||
			*cmd_write=0;
 | 
			
		||||
			Bit32u cmd_index=0;
 | 
			
		||||
			while (cmd_list[cmd_index].name) {
 | 
			
		||||
				if (strcasecmp(cmd_list[cmd_index].name,cmd_buffer)==0) {
 | 
			
		||||
				if (strcasecmp(cmd_list[cmd_index].name,cmd_buffer) == 0) {
 | 
			
		||||
					(this->*(cmd_list[cmd_index].handler))(line);
 | 
			
		||||
			 		return;
 | 
			
		||||
				}
 | 
			
		||||
| 
						 | 
				
			
			@ -150,19 +150,19 @@ void DOS_Shell::DoCommand(char * line) {
 | 
			
		|||
		*cmd_write++=*line++;
 | 
			
		||||
	}
 | 
			
		||||
	*cmd_write=0;
 | 
			
		||||
	if (strlen(cmd_buffer)==0) return;
 | 
			
		||||
	if (strlen(cmd_buffer) == 0) return;
 | 
			
		||||
/* Check the internal list */
 | 
			
		||||
	Bit32u cmd_index=0;
 | 
			
		||||
	while (cmd_list[cmd_index].name) {
 | 
			
		||||
		if (strcasecmp(cmd_list[cmd_index].name,cmd_buffer)==0) {
 | 
			
		||||
		if (strcasecmp(cmd_list[cmd_index].name,cmd_buffer) == 0) {
 | 
			
		||||
			(this->*(cmd_list[cmd_index].handler))(line);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		cmd_index++;
 | 
			
		||||
	}
 | 
			
		||||
/* This isn't an internal command execute it */
 | 
			
		||||
	if(Execute(cmd_buffer,line)) return;
 | 
			
		||||
	if(CheckConfig(cmd_buffer,line)) return;
 | 
			
		||||
	if (Execute(cmd_buffer,line)) return;
 | 
			
		||||
	if (CheckConfig(cmd_buffer,line)) return;
 | 
			
		||||
	WriteOut(MSG_Get("SHELL_EXECUTE_ILLEGAL_COMMAND"),cmd_buffer);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -171,7 +171,7 @@ void DOS_Shell::DoCommand(char * line) {
 | 
			
		|||
		WriteOut(MSG_Get("SHELL_CMD_" command "_HELP")); \
 | 
			
		||||
		const char* long_m = MSG_Get("SHELL_CMD_" command "_HELP_LONG"); \
 | 
			
		||||
		WriteOut("\n"); \
 | 
			
		||||
		if(strcmp("Message not Found!\n",long_m)) WriteOut(long_m); \
 | 
			
		||||
		if (strcmp("Message not Found!\n",long_m)) WriteOut(long_m); \
 | 
			
		||||
		else WriteOut(command "\n"); \
 | 
			
		||||
		return; \
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -193,14 +193,14 @@ void DOS_Shell::CMD_DELETE(char * args) {
 | 
			
		|||
		WriteOut(MSG_Get("SHELL_ILLEGAL_SWITCH"),rem);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	/* If delete accept switches mind the space infront of them. See the dir /p code */ 
 | 
			
		||||
	/* If delete accept switches mind the space infront of them. See the dir /p code */
 | 
			
		||||
 | 
			
		||||
	char full[DOS_PATHLENGTH];
 | 
			
		||||
	char buffer[CROSS_LEN];
 | 
			
		||||
	args = ExpandDot(args,buffer, CROSS_LEN);
 | 
			
		||||
	StripSpaces(args);
 | 
			
		||||
	if (!DOS_Canonicalize(args,full)) { WriteOut(MSG_Get("SHELL_ILLEGAL_PATH"));return; }
 | 
			
		||||
//TODO Maybe support confirmation for *.* like dos does.	
 | 
			
		||||
//TODO Maybe support confirmation for *.* like dos does.
 | 
			
		||||
	bool res=DOS_FindFirst(args,0xffff & ~DOS_ATTR_VOLUME);
 | 
			
		||||
	if (!res) {
 | 
			
		||||
		WriteOut(MSG_Get("SHELL_CMD_DEL_ERROR"),args);
 | 
			
		||||
| 
						 | 
				
			
			@ -212,7 +212,7 @@ void DOS_Shell::CMD_DELETE(char * args) {
 | 
			
		|||
	char name[DOS_NAMELENGTH_ASCII];Bit32u size;Bit16u time,date;Bit8u attr;
 | 
			
		||||
	DOS_DTA dta(dos.dta());
 | 
			
		||||
	while (res) {
 | 
			
		||||
		dta.GetResult(name,size,date,time,attr);	
 | 
			
		||||
		dta.GetResult(name,size,date,time,attr);
 | 
			
		||||
		if (!(attr & (DOS_ATTR_DIRECTORY|DOS_ATTR_READ_ONLY))) {
 | 
			
		||||
			strcpy(end,name);
 | 
			
		||||
			if (!DOS_UnlinkFile(full)) WriteOut(MSG_Get("SHELL_CMD_DEL_ERROR"),full);
 | 
			
		||||
| 
						 | 
				
			
			@ -226,7 +226,7 @@ void DOS_Shell::CMD_HELP(char * args){
 | 
			
		|||
	HELP("HELP");
 | 
			
		||||
	bool optall=ScanCMDBool(args,"ALL");
 | 
			
		||||
	/* Print the help */
 | 
			
		||||
	if(!optall) WriteOut(MSG_Get("SHELL_CMD_HELP"));
 | 
			
		||||
	if (!optall) WriteOut(MSG_Get("SHELL_CMD_HELP"));
 | 
			
		||||
	Bit32u cmd_index=0,write_count=0;
 | 
			
		||||
	while (cmd_list[cmd_index].name) {
 | 
			
		||||
		if (optall || !cmd_list[cmd_index].flags) {
 | 
			
		||||
| 
						 | 
				
			
			@ -247,12 +247,12 @@ void DOS_Shell::CMD_RENAME(char * args){
 | 
			
		|||
	StripSpaces(args);
 | 
			
		||||
	if (!*args) {SyntaxError();return;}
 | 
			
		||||
	char* slash = strrchr(arg1,'\\');
 | 
			
		||||
	if (slash) { 
 | 
			
		||||
	if (slash) {
 | 
			
		||||
		/* If directory specified (crystal caves installer)
 | 
			
		||||
		 * rename from c:\X : rename c:\abc.exe abc.shr. 
 | 
			
		||||
		 * File must appear in C:\ 
 | 
			
		||||
		 * Ren X:\A\B C => ren X:\A\B X:\A\C */ 
 | 
			
		||||
		
 | 
			
		||||
		 * rename from c:\X : rename c:\abc.exe abc.shr.
 | 
			
		||||
		 * File must appear in C:\
 | 
			
		||||
		 * Ren X:\A\B C => ren X:\A\B X:\A\C */
 | 
			
		||||
 | 
			
		||||
		char dir_source[DOS_PATHLENGTH + 4] = {0}; //not sure if drive portion is included in pathlength
 | 
			
		||||
		//Copy first and then modify, makes GCC happy
 | 
			
		||||
		safe_strncpy(dir_source,arg1,DOS_PATHLENGTH + 4);
 | 
			
		||||
| 
						 | 
				
			
			@ -288,19 +288,19 @@ void DOS_Shell::CMD_ECHO(char * args){
 | 
			
		|||
	char* pbuffer = buffer;
 | 
			
		||||
	safe_strncpy(buffer,args,512);
 | 
			
		||||
	StripSpaces(pbuffer);
 | 
			
		||||
	if (strcasecmp(pbuffer,"OFF")==0) {
 | 
			
		||||
		echo=false;		
 | 
			
		||||
	if (strcasecmp(pbuffer,"OFF") == 0) {
 | 
			
		||||
		echo=false;
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	if (strcasecmp(pbuffer,"ON")==0) {
 | 
			
		||||
		echo=true;		
 | 
			
		||||
	if (strcasecmp(pbuffer,"ON") == 0) {
 | 
			
		||||
		echo=true;
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	if(strcasecmp(pbuffer,"/?")==0) { HELP("ECHO"); }
 | 
			
		||||
	if (strcasecmp(pbuffer,"/?") == 0) { HELP("ECHO"); }
 | 
			
		||||
 | 
			
		||||
	args++;//skip first character. either a slash or dot or space
 | 
			
		||||
	size_t len = strlen(args); //TODO check input of else ook nodig is.
 | 
			
		||||
	if(len && args[len - 1] == '\r') {
 | 
			
		||||
	if (len && args[len - 1] == '\r') {
 | 
			
		||||
		LOG(LOG_MISC,LOG_WARN)("Hu ? carriage return already present. Is this possible?");
 | 
			
		||||
		WriteOut("%s\n",args);
 | 
			
		||||
	} else WriteOut("%s\r\n",args);
 | 
			
		||||
| 
						 | 
				
			
			@ -320,11 +320,11 @@ void DOS_Shell::CMD_CHDIR(char * args) {
 | 
			
		|||
	if (!*args) {
 | 
			
		||||
		DOS_GetCurrentDir(0,dir);
 | 
			
		||||
		WriteOut("%c:\\%s\n",drive,dir);
 | 
			
		||||
	} else if(strlen(args) == 2 && args[1]==':') {
 | 
			
		||||
		Bit8u targetdrive = (args[0] | 0x20)-'a' + 1;
 | 
			
		||||
	} else if (strlen(args) == 2 && args[1] == ':') {
 | 
			
		||||
		Bit8u targetdrive = (args[0] | 0x20) - 'a' + 1;
 | 
			
		||||
		unsigned char targetdisplay = *reinterpret_cast<unsigned char*>(&args[0]);
 | 
			
		||||
		if(!DOS_GetCurrentDir(targetdrive,dir)) {
 | 
			
		||||
			if(drive == 'Z') {
 | 
			
		||||
		if (!DOS_GetCurrentDir(targetdrive,dir)) {
 | 
			
		||||
			if (drive == 'Z') {
 | 
			
		||||
				WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_NOT_FOUND"),toupper(targetdisplay));
 | 
			
		||||
			} else {
 | 
			
		||||
				WriteOut(MSG_Get("SHELL_ILLEGAL_PATH"));
 | 
			
		||||
| 
						 | 
				
			
			@ -332,25 +332,25 @@ void DOS_Shell::CMD_CHDIR(char * args) {
 | 
			
		|||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		WriteOut("%c:\\%s\n",toupper(targetdisplay),dir);
 | 
			
		||||
		if(drive == 'Z')
 | 
			
		||||
		if (drive == 'Z')
 | 
			
		||||
			WriteOut(MSG_Get("SHELL_CMD_CHDIR_HINT"),toupper(targetdisplay));
 | 
			
		||||
	} else 	if (!DOS_ChangeDir(args)) {
 | 
			
		||||
		/* Changedir failed. Check if the filename is longer then 8 and/or contains spaces */
 | 
			
		||||
	   
 | 
			
		||||
 | 
			
		||||
		std::string temps(args),slashpart;
 | 
			
		||||
		std::string::size_type separator = temps.find_first_of("\\/");
 | 
			
		||||
		if(!separator) {
 | 
			
		||||
		if (!separator) {
 | 
			
		||||
			slashpart = temps.substr(0,1);
 | 
			
		||||
			temps.erase(0,1);
 | 
			
		||||
		}
 | 
			
		||||
		separator = temps.find_first_of("\\/");
 | 
			
		||||
		if(separator != std::string::npos) temps.erase(separator);
 | 
			
		||||
		if (separator != std::string::npos) temps.erase(separator);
 | 
			
		||||
		separator = temps.rfind('.');
 | 
			
		||||
		if(separator != std::string::npos) temps.erase(separator);
 | 
			
		||||
		if (separator != std::string::npos) temps.erase(separator);
 | 
			
		||||
		separator = temps.find(' ');
 | 
			
		||||
		if(separator != std::string::npos) {/* Contains spaces */
 | 
			
		||||
		if (separator != std::string::npos) {/* Contains spaces */
 | 
			
		||||
			temps.erase(separator);
 | 
			
		||||
			if(temps.size() >6) temps.erase(6);
 | 
			
		||||
			if (temps.size() >6) temps.erase(6);
 | 
			
		||||
			temps += "~1";
 | 
			
		||||
			WriteOut(MSG_Get("SHELL_CMD_CHDIR_HINT_2"),temps.insert(0,slashpart).c_str());
 | 
			
		||||
		} else if (temps.size()>8) {
 | 
			
		||||
| 
						 | 
				
			
			@ -447,7 +447,7 @@ void DOS_Shell::CMD_DIR(char * args) {
 | 
			
		|||
	char path[DOS_PATHLENGTH];
 | 
			
		||||
 | 
			
		||||
	std::string line;
 | 
			
		||||
	if(GetEnvStr("DIRCMD",line)){
 | 
			
		||||
	if (GetEnvStr("DIRCMD",line)){
 | 
			
		||||
		std::string::size_type idx = line.find('=');
 | 
			
		||||
		std::string value=line.substr(idx +1 , std::string::npos);
 | 
			
		||||
		line = std::string(args) + " " + value;
 | 
			
		||||
| 
						 | 
				
			
			@ -511,7 +511,7 @@ void DOS_Shell::CMD_DIR(char * args) {
 | 
			
		|||
 | 
			
		||||
	if (!strrchr(args,'*') && !strrchr(args,'?')) {
 | 
			
		||||
		Bit16u attribute=0;
 | 
			
		||||
		if(DOS_GetFileAttr(args,&attribute) && (attribute&DOS_ATTR_DIRECTORY) ) {
 | 
			
		||||
		if (DOS_GetFileAttr(args,&attribute) && (attribute&DOS_ATTR_DIRECTORY) ) {
 | 
			
		||||
			strcat(args,"\\*.*");	// if no wildcard and a directory, get its files
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -585,8 +585,8 @@ void DOS_Shell::CMD_DIR(char * args) {
 | 
			
		|||
		dta.GetResult(result.name,result.size,result.date,result.time,result.attr);
 | 
			
		||||
 | 
			
		||||
		/* Skip non-directories if option AD is present, or skip dirs in case of A-D */
 | 
			
		||||
		if(optAD && !(result.attr&DOS_ATTR_DIRECTORY) ) continue;
 | 
			
		||||
		else if(optAminusD && (result.attr&DOS_ATTR_DIRECTORY) ) continue;
 | 
			
		||||
		if (optAD && !(result.attr&DOS_ATTR_DIRECTORY) ) continue;
 | 
			
		||||
		else if (optAminusD && (result.attr&DOS_ATTR_DIRECTORY) ) continue;
 | 
			
		||||
 | 
			
		||||
		results.push_back(result);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -745,9 +745,9 @@ void DOS_Shell::CMD_COPY(char * args) {
 | 
			
		|||
	char name[DOS_NAMELENGTH_ASCII];
 | 
			
		||||
	std::vector<copysource> sources;
 | 
			
		||||
	// ignore /b and /t switches: always copy binary
 | 
			
		||||
	while(ScanCMDBool(args,"B")) ;
 | 
			
		||||
	while(ScanCMDBool(args,"T")) ; //Shouldn't this be A ?
 | 
			
		||||
	while(ScanCMDBool(args,"A")) ;
 | 
			
		||||
	while (ScanCMDBool(args,"B")) ;
 | 
			
		||||
	while (ScanCMDBool(args,"T")) ; //Shouldn't this be A ?
 | 
			
		||||
	while (ScanCMDBool(args,"A")) ;
 | 
			
		||||
	ScanCMDBool(args,"Y");
 | 
			
		||||
	ScanCMDBool(args,"-Y");
 | 
			
		||||
	ScanCMDBool(args,"V");
 | 
			
		||||
| 
						 | 
				
			
			@ -769,9 +769,9 @@ void DOS_Shell::CMD_COPY(char * args) {
 | 
			
		|||
			// If StripWord() previously cut at a space before a plus then
 | 
			
		||||
			// set concatenate flag on last source and remove leading plus.
 | 
			
		||||
			if (plus == source_p && sources.size()) {
 | 
			
		||||
				sources[sources.size()-1].concat = true;
 | 
			
		||||
				sources[sources.size() - 1].concat = true;
 | 
			
		||||
				// If spaces also followed plus then item is only a plus.
 | 
			
		||||
				if (strlen(++source_p)==0) break;
 | 
			
		||||
				if (strlen(++source_p) == 0) break;
 | 
			
		||||
				plus = strchr(source_p,'+');
 | 
			
		||||
			}
 | 
			
		||||
			if (plus) *plus++ = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -779,7 +779,7 @@ void DOS_Shell::CMD_COPY(char * args) {
 | 
			
		|||
			bool has_drive_spec = false;
 | 
			
		||||
			size_t source_x_len = strlen(source_x);
 | 
			
		||||
			if (source_x_len>0) {
 | 
			
		||||
				if (source_x[source_x_len-1]==':') has_drive_spec = true;
 | 
			
		||||
				if (source_x[source_x_len-1] == ':') has_drive_spec = true;
 | 
			
		||||
			}
 | 
			
		||||
			if (!has_drive_spec  && !strpbrk(source_p,"*?") ) { //doubt that fu*\*.* is valid
 | 
			
		||||
				if (DOS_FindFirst(source_p,0xffff & ~DOS_ATTR_VOLUME)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -790,7 +790,7 @@ void DOS_Shell::CMD_COPY(char * args) {
 | 
			
		|||
			}
 | 
			
		||||
			sources.push_back(copysource(source_x,(plus)?true:false));
 | 
			
		||||
			source_p = plus;
 | 
			
		||||
		} while(source_p && *source_p);
 | 
			
		||||
		} while (source_p && *source_p);
 | 
			
		||||
	}
 | 
			
		||||
	// At least one source has to be there
 | 
			
		||||
	if (!sources.size() || !sources[0].filename.size()) {
 | 
			
		||||
| 
						 | 
				
			
			@ -800,26 +800,26 @@ void DOS_Shell::CMD_COPY(char * args) {
 | 
			
		|||
	};
 | 
			
		||||
 | 
			
		||||
	copysource target;
 | 
			
		||||
	// If more then one object exists and last target is not part of a 
 | 
			
		||||
	// If more then one object exists and last target is not part of a
 | 
			
		||||
	// concat sequence then make it the target.
 | 
			
		||||
	if(sources.size()>1 && !sources[sources.size()-2].concat){
 | 
			
		||||
	if (sources.size() > 1 && !sources[sources.size() - 2].concat){
 | 
			
		||||
		target = sources.back();
 | 
			
		||||
		sources.pop_back();
 | 
			
		||||
	}
 | 
			
		||||
	//If no target => default target with concat flag true to detect a+b+c
 | 
			
		||||
	if(target.filename.size() == 0) target = copysource(defaulttarget,true);
 | 
			
		||||
	if (target.filename.size() == 0) target = copysource(defaulttarget,true);
 | 
			
		||||
 | 
			
		||||
	copysource oldsource;
 | 
			
		||||
	copysource source;
 | 
			
		||||
	Bit32u count = 0;
 | 
			
		||||
	while(sources.size()) {
 | 
			
		||||
	while (sources.size()) {
 | 
			
		||||
		/* Get next source item and keep track of old source for concat start end */
 | 
			
		||||
		oldsource = source;
 | 
			
		||||
		source = sources[0];
 | 
			
		||||
		sources.erase(sources.begin());
 | 
			
		||||
 | 
			
		||||
		//Skip first file if doing a+b+c. Set target to first file
 | 
			
		||||
		if(!oldsource.concat && source.concat && target.concat) {
 | 
			
		||||
		if (!oldsource.concat && source.concat && target.concat) {
 | 
			
		||||
			target = source;
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -843,11 +843,11 @@ void DOS_Shell::CMD_COPY(char * args) {
 | 
			
		|||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		char* temp = strstr(pathTarget,"*.*");
 | 
			
		||||
		if(temp) *temp = 0;//strip off *.* from target
 | 
			
		||||
	
 | 
			
		||||
		if (temp) *temp = 0;//strip off *.* from target
 | 
			
		||||
 | 
			
		||||
		// add '\\' if target is a directory
 | 
			
		||||
		bool target_is_file = true;
 | 
			
		||||
		if (pathTarget[strlen(pathTarget)-1]!='\\') {
 | 
			
		||||
		if (pathTarget[strlen(pathTarget) - 1]!='\\') {
 | 
			
		||||
			if (DOS_FindFirst(pathTarget,0xffff & ~DOS_ATTR_VOLUME)) {
 | 
			
		||||
				dta.GetResult(name,size,date,time,attr);
 | 
			
		||||
				if (attr & DOS_ATTR_DIRECTORY) {
 | 
			
		||||
| 
						 | 
				
			
			@ -868,42 +868,42 @@ void DOS_Shell::CMD_COPY(char * args) {
 | 
			
		|||
		Bit16u sourceHandle,targetHandle;
 | 
			
		||||
		char nameTarget[DOS_PATHLENGTH];
 | 
			
		||||
		char nameSource[DOS_PATHLENGTH];
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
		bool second_file_of_current_source = false;
 | 
			
		||||
		while (ret) {
 | 
			
		||||
			dta.GetResult(name,size,date,time,attr);
 | 
			
		||||
 | 
			
		||||
			if ((attr & DOS_ATTR_DIRECTORY)==0) {
 | 
			
		||||
			if ((attr & DOS_ATTR_DIRECTORY) == 0) {
 | 
			
		||||
				strcpy(nameSource,pathSource);
 | 
			
		||||
				strcat(nameSource,name);
 | 
			
		||||
				// Open Source
 | 
			
		||||
				if (DOS_OpenFile(nameSource,0,&sourceHandle)) {
 | 
			
		||||
					// Create Target or open it if in concat mode
 | 
			
		||||
					strcpy(nameTarget,pathTarget);
 | 
			
		||||
					if (nameTarget[strlen(nameTarget)-1]=='\\') strcat(nameTarget,name);
 | 
			
		||||
					if (nameTarget[strlen(nameTarget) - 1] == '\\') strcat(nameTarget,name);
 | 
			
		||||
 | 
			
		||||
					//Special variable to ensure that copy * a_file, where a_file is not a directory concats.
 | 
			
		||||
					bool special = second_file_of_current_source && target_is_file;
 | 
			
		||||
					second_file_of_current_source = true; 
 | 
			
		||||
					second_file_of_current_source = true;
 | 
			
		||||
					if (special) oldsource.concat = true;
 | 
			
		||||
					//Don't create a new file when in concat mode
 | 
			
		||||
					if (oldsource.concat || DOS_CreateFile(nameTarget,0,&targetHandle)) {
 | 
			
		||||
						Bit32u dummy=0;
 | 
			
		||||
						//In concat mode. Open the target and seek to the eof
 | 
			
		||||
						if (!oldsource.concat || (DOS_OpenFile(nameTarget,OPEN_READWRITE,&targetHandle) && 
 | 
			
		||||
						if (!oldsource.concat || (DOS_OpenFile(nameTarget,OPEN_READWRITE,&targetHandle) &&
 | 
			
		||||
					        	                  DOS_SeekFile(targetHandle,&dummy,DOS_SEEK_END))) {
 | 
			
		||||
							// Copy 
 | 
			
		||||
							// Copy
 | 
			
		||||
							static Bit8u buffer[0x8000]; // static, otherwise stack overflow possible.
 | 
			
		||||
							bool	failed = false;
 | 
			
		||||
							Bit16u	toread = 0x8000;
 | 
			
		||||
							do {
 | 
			
		||||
								failed |= DOS_ReadFile(sourceHandle,buffer,&toread);
 | 
			
		||||
								failed |= DOS_WriteFile(targetHandle,buffer,&toread);
 | 
			
		||||
							} while (toread==0x8000);
 | 
			
		||||
							} while (toread == 0x8000);
 | 
			
		||||
							failed |= DOS_CloseFile(sourceHandle);
 | 
			
		||||
							failed |= DOS_CloseFile(targetHandle);
 | 
			
		||||
							WriteOut(" %s\n",name);
 | 
			
		||||
							if(!source.concat && !special) count++; //Only count concat files once
 | 
			
		||||
							if (!source.concat && !special) count++; //Only count concat files once
 | 
			
		||||
						} else {
 | 
			
		||||
							DOS_CloseFile(sourceHandle);
 | 
			
		||||
							WriteOut(MSG_Get("SHELL_CMD_COPY_FAILURE"),const_cast<char*>(target.filename.c_str()));
 | 
			
		||||
| 
						 | 
				
			
			@ -929,10 +929,10 @@ void DOS_Shell::CMD_SET(char * args) {
 | 
			
		|||
	StripSpaces(args);
 | 
			
		||||
	std::string line;
 | 
			
		||||
	if (!*args) {
 | 
			
		||||
		/* No command line show all environment lines */	
 | 
			
		||||
		/* No command line show all environment lines */
 | 
			
		||||
		Bitu count=GetEnvCount();
 | 
			
		||||
		for (Bitu a=0;a<count;a++) {
 | 
			
		||||
			if (GetEnvNum(a,line)) WriteOut("%s\n",line.c_str());			
 | 
			
		||||
			if (GetEnvNum(a,line)) WriteOut("%s\n",line.c_str());
 | 
			
		||||
		}
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -950,10 +950,10 @@ void DOS_Shell::CMD_SET(char * args) {
 | 
			
		|||
		/* parse p for envirionment variables */
 | 
			
		||||
		char parsed[CMD_MAXLINE];
 | 
			
		||||
		char* p_parsed = parsed;
 | 
			
		||||
		while(*p) {
 | 
			
		||||
			if(*p != '%') *p_parsed++ = *p++; //Just add it (most likely path)
 | 
			
		||||
			else if( *(p+1) == '%') {
 | 
			
		||||
				*p_parsed++ = '%'; p += 2; //%% => % 
 | 
			
		||||
		while (*p) {
 | 
			
		||||
			if (*p != '%') *p_parsed++ = *p++; //Just add it (most likely path)
 | 
			
		||||
			else if ( *(p+1) == '%') {
 | 
			
		||||
				*p_parsed++ = '%'; p += 2; //%% => %
 | 
			
		||||
			} else {
 | 
			
		||||
				char * second = strchr(++p,'%');
 | 
			
		||||
				if (!second) continue;
 | 
			
		||||
| 
						 | 
				
			
			@ -989,12 +989,12 @@ void DOS_Shell::CMD_IF(char * args) {
 | 
			
		|||
		has_not = !has_not;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(strncasecmp(args,"ERRORLEVEL",10) == 0) {
 | 
			
		||||
	if (strncasecmp(args,"ERRORLEVEL",10) == 0) {
 | 
			
		||||
		args += 10;	//skip text
 | 
			
		||||
		//Strip spaces and ==
 | 
			
		||||
		StripSpaces(args,'=');
 | 
			
		||||
		char* word = StripWord(args);
 | 
			
		||||
		if(!isdigit(*word)) {
 | 
			
		||||
		if (!isdigit(*word)) {
 | 
			
		||||
			WriteOut(MSG_Get("SHELL_CMD_IF_ERRORLEVEL_MISSING_NUMBER"));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -1002,7 +1002,7 @@ void DOS_Shell::CMD_IF(char * args) {
 | 
			
		|||
		Bit8u n = 0;
 | 
			
		||||
		do n = n * 10 + (*word - '0');
 | 
			
		||||
		while (isdigit(*++word));
 | 
			
		||||
		if(*word && !isspace(*word)) {
 | 
			
		||||
		if (*word && !isspace(*word)) {
 | 
			
		||||
			WriteOut(MSG_Get("SHELL_CMD_IF_ERRORLEVEL_INVALID_NUMBER"));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -1011,7 +1011,7 @@ void DOS_Shell::CMD_IF(char * args) {
 | 
			
		|||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(strncasecmp(args,"EXIST ",6) == 0) {
 | 
			
		||||
	if (strncasecmp(args,"EXIST ",6) == 0) {
 | 
			
		||||
		args += 6; //Skip text
 | 
			
		||||
		StripSpaces(args);
 | 
			
		||||
		char* word = StripWord(args);
 | 
			
		||||
| 
						 | 
				
			
			@ -1025,7 +1025,7 @@ void DOS_Shell::CMD_IF(char * args) {
 | 
			
		|||
			dos.dta(dos.tables.tempdta);
 | 
			
		||||
			bool ret=DOS_FindFirst(word,0xffff & ~DOS_ATTR_VOLUME);
 | 
			
		||||
			dos.dta(save_dta);
 | 
			
		||||
			if (ret==(!has_not)) DoCommand(args);
 | 
			
		||||
			if (ret == (!has_not)) DoCommand(args);
 | 
			
		||||
		}
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -1042,7 +1042,7 @@ void DOS_Shell::CMD_IF(char * args) {
 | 
			
		|||
	while (*args && (*args != '='))
 | 
			
		||||
		args++;
 | 
			
		||||
	// check for ==
 | 
			
		||||
	if ((*args==0) || (args[1] != '=')) {
 | 
			
		||||
	if ((*args == 0) || (args[1] != '=')) {
 | 
			
		||||
		SyntaxError();
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -1059,7 +1059,7 @@ void DOS_Shell::CMD_IF(char * args) {
 | 
			
		|||
		*args++ = 0;		// mark end of second word
 | 
			
		||||
		StripSpaces(args,'=');
 | 
			
		||||
 | 
			
		||||
		if ((strcmp(word1,word2)==0)==(!has_not)) DoCommand(args);
 | 
			
		||||
		if ((strcmp(word1,word2) == 0) == (!has_not)) DoCommand(args);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1067,12 +1067,12 @@ void DOS_Shell::CMD_GOTO(char * args) {
 | 
			
		|||
	HELP("GOTO");
 | 
			
		||||
	StripSpaces(args);
 | 
			
		||||
	if (!bf) return;
 | 
			
		||||
	if (*args &&(*args==':')) args++;
 | 
			
		||||
	if (*args &&(*args == ':')) args++;
 | 
			
		||||
	//label ends at the first space
 | 
			
		||||
	char* non_space = args;
 | 
			
		||||
	while (*non_space) {
 | 
			
		||||
		if((*non_space == ' ') || (*non_space == '\t')) 
 | 
			
		||||
			*non_space = 0; 
 | 
			
		||||
		if ((*non_space == ' ') || (*non_space == '\t'))
 | 
			
		||||
			*non_space = 0;
 | 
			
		||||
		else non_space++;
 | 
			
		||||
	}
 | 
			
		||||
	if (!*args) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1087,7 +1087,7 @@ void DOS_Shell::CMD_GOTO(char * args) {
 | 
			
		|||
 | 
			
		||||
void DOS_Shell::CMD_SHIFT(char * args ) {
 | 
			
		||||
	HELP("SHIFT");
 | 
			
		||||
	if(bf) bf->Shift();
 | 
			
		||||
	if (bf) bf->Shift();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DOS_Shell::CMD_TYPE(char * args) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1109,7 +1109,7 @@ nextfile:
 | 
			
		|||
	do {
 | 
			
		||||
		n=1;
 | 
			
		||||
		DOS_ReadFile(handle,&c,&n);
 | 
			
		||||
		if (c==0x1a) break; // stop at EOF
 | 
			
		||||
		if (c == 0x1a) break; // stop at EOF
 | 
			
		||||
		DOS_WriteFile(STDOUT,&c,&n);
 | 
			
		||||
	} while (n);
 | 
			
		||||
	DOS_CloseFile(handle);
 | 
			
		||||
| 
						 | 
				
			
			@ -1139,14 +1139,14 @@ void DOS_Shell::CMD_CALL(char * args){
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
void DOS_Shell::CMD_DATE(char * args) {
 | 
			
		||||
	HELP("DATE");	
 | 
			
		||||
	if(ScanCMDBool(args,"H")) {
 | 
			
		||||
	HELP("DATE");
 | 
			
		||||
	if (ScanCMDBool(args,"H")) {
 | 
			
		||||
		// synchronize date with host parameter
 | 
			
		||||
		time_t curtime;
 | 
			
		||||
		struct tm *loctime;
 | 
			
		||||
		curtime = time (NULL);
 | 
			
		||||
		loctime = localtime (&curtime);
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
		reg_cx = loctime->tm_year+1900;
 | 
			
		||||
		reg_dh = loctime->tm_mon+1;
 | 
			
		||||
		reg_dl = loctime->tm_mday;
 | 
			
		||||
| 
						 | 
				
			
			@ -1157,14 +1157,14 @@ void DOS_Shell::CMD_DATE(char * args) {
 | 
			
		|||
	}
 | 
			
		||||
	// check if a date was passed in command line
 | 
			
		||||
	Bit32u newday,newmonth,newyear;
 | 
			
		||||
	if(sscanf(args,"%u-%u-%u",&newmonth,&newday,&newyear)==3) {
 | 
			
		||||
	if (sscanf(args,"%u-%u-%u",&newmonth,&newday,&newyear) == 3) {
 | 
			
		||||
		reg_cx = static_cast<Bit16u>(newyear);
 | 
			
		||||
		reg_dh = static_cast<Bit8u>(newmonth);
 | 
			
		||||
		reg_dl = static_cast<Bit8u>(newday);
 | 
			
		||||
 | 
			
		||||
		reg_ah=0x2b; // set system date
 | 
			
		||||
		CALLBACK_RunRealInt(0x21);
 | 
			
		||||
		if(reg_al==0xff) WriteOut(MSG_Get("SHELL_CMD_DATE_ERROR"));
 | 
			
		||||
		if (reg_al == 0xff) WriteOut(MSG_Get("SHELL_CMD_DATE_ERROR"));
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	// display the current date
 | 
			
		||||
| 
						 | 
				
			
			@ -1174,47 +1174,47 @@ void DOS_Shell::CMD_DATE(char * args) {
 | 
			
		|||
	const char* datestring = MSG_Get("SHELL_CMD_DATE_DAYS");
 | 
			
		||||
	Bit32u length;
 | 
			
		||||
	char day[6] = {0};
 | 
			
		||||
	if(sscanf(datestring,"%u",&length) && (length<5) && (strlen(datestring)==(length*7+1))) {
 | 
			
		||||
	if (sscanf(datestring,"%u",&length) && (length<5) && (strlen(datestring) == (length*7+1))) {
 | 
			
		||||
		// date string appears valid
 | 
			
		||||
		for(Bit32u i = 0; i < length; i++) day[i] = datestring[reg_al*length+1+i];
 | 
			
		||||
		for (Bit32u i = 0; i < length; i++) day[i] = datestring[reg_al*length+1+i];
 | 
			
		||||
	}
 | 
			
		||||
	bool dateonly = ScanCMDBool(args,"T");
 | 
			
		||||
	if(!dateonly) WriteOut(MSG_Get("SHELL_CMD_DATE_NOW"));
 | 
			
		||||
	if (!dateonly) WriteOut(MSG_Get("SHELL_CMD_DATE_NOW"));
 | 
			
		||||
 | 
			
		||||
	const char* formatstring = MSG_Get("SHELL_CMD_DATE_FORMAT");
 | 
			
		||||
	if(strlen(formatstring)!=5) return;
 | 
			
		||||
	if (strlen(formatstring)!=5) return;
 | 
			
		||||
	char buffer[15] = {0};
 | 
			
		||||
	Bitu bufferptr=0;
 | 
			
		||||
	for(Bitu i = 0; i < 5; i++) {
 | 
			
		||||
		if(i==1 || i==3) {
 | 
			
		||||
	for (Bitu i = 0; i < 5; i++) {
 | 
			
		||||
		if (i == 1 || i == 3) {
 | 
			
		||||
			buffer[bufferptr] = formatstring[i];
 | 
			
		||||
			bufferptr++;
 | 
			
		||||
		} else {
 | 
			
		||||
			if(formatstring[i]=='M') bufferptr += sprintf(buffer+bufferptr,"%02u",(Bit8u) reg_dh);
 | 
			
		||||
			if(formatstring[i]=='D') bufferptr += sprintf(buffer+bufferptr,"%02u",(Bit8u) reg_dl);
 | 
			
		||||
			if(formatstring[i]=='Y') bufferptr += sprintf(buffer+bufferptr,"%04u",(Bit16u) reg_cx);
 | 
			
		||||
			if (formatstring[i] == 'M') bufferptr += sprintf(buffer+bufferptr,"%02u",(Bit8u) reg_dh);
 | 
			
		||||
			if (formatstring[i] == 'D') bufferptr += sprintf(buffer+bufferptr,"%02u",(Bit8u) reg_dl);
 | 
			
		||||
			if (formatstring[i] == 'Y') bufferptr += sprintf(buffer+bufferptr,"%04u",(Bit16u) reg_cx);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	WriteOut("%s %s\n",day, buffer);
 | 
			
		||||
	if(!dateonly) WriteOut(MSG_Get("SHELL_CMD_DATE_SETHLP"));
 | 
			
		||||
	if (!dateonly) WriteOut(MSG_Get("SHELL_CMD_DATE_SETHLP"));
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
void DOS_Shell::CMD_TIME(char * args) {
 | 
			
		||||
	HELP("TIME");
 | 
			
		||||
	if(ScanCMDBool(args,"H")) {
 | 
			
		||||
	if (ScanCMDBool(args,"H")) {
 | 
			
		||||
		// synchronize time with host parameter
 | 
			
		||||
		time_t curtime;
 | 
			
		||||
		struct tm *loctime;
 | 
			
		||||
		curtime = time (NULL);
 | 
			
		||||
		loctime = localtime (&curtime);
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
		//reg_cx = loctime->;
 | 
			
		||||
		//reg_dh = loctime->;
 | 
			
		||||
		//reg_dl = loctime->;
 | 
			
		||||
 | 
			
		||||
		// reg_ah=0x2d; // set system time TODO
 | 
			
		||||
		// CALLBACK_RunRealInt(0x21);
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
		Bit32u ticks=(Bit32u)(((double)(loctime->tm_hour*3600+
 | 
			
		||||
										loctime->tm_min*60+
 | 
			
		||||
										loctime->tm_sec))*18.206481481);
 | 
			
		||||
| 
						 | 
				
			
			@ -1231,7 +1231,7 @@ void DOS_Shell::CMD_TIME(char * args) {
 | 
			
		|||
		reg_cl= // minutes
 | 
			
		||||
		reg_ch= // hours
 | 
			
		||||
*/
 | 
			
		||||
	if(timeonly) {
 | 
			
		||||
	if (timeonly) {
 | 
			
		||||
		WriteOut("%2u:%02u\n",reg_ch,reg_cl);
 | 
			
		||||
	} else {
 | 
			
		||||
		WriteOut(MSG_Get("SHELL_CMD_TIME_NOW"));
 | 
			
		||||
| 
						 | 
				
			
			@ -1240,7 +1240,7 @@ void DOS_Shell::CMD_TIME(char * args) {
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
void DOS_Shell::CMD_SUBST (char * args) {
 | 
			
		||||
/* If more that one type can be substed think of something else 
 | 
			
		||||
/* If more that one type can be substed think of something else
 | 
			
		||||
 * E.g. make basedir member dos_drive instead of localdrive
 | 
			
		||||
 */
 | 
			
		||||
	HELP("SUBST");
 | 
			
		||||
| 
						 | 
				
			
			@ -1254,38 +1254,38 @@ void DOS_Shell::CMD_SUBST (char * args) {
 | 
			
		|||
		CommandLine command(0,args);
 | 
			
		||||
 | 
			
		||||
		if (command.GetCount() != 2) throw 0 ;
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
		command.FindCommand(1,arg);
 | 
			
		||||
		if( (arg.size()>1) && arg[1] !=':')  throw(0);
 | 
			
		||||
		if ( (arg.size() > 1) && arg[1] !=':')  throw(0);
 | 
			
		||||
		temp_str[0]=(char)toupper(args[0]);
 | 
			
		||||
		command.FindCommand(2,arg);
 | 
			
		||||
		if((arg=="/D") || (arg=="/d")) {
 | 
			
		||||
			if(!Drives[temp_str[0]-'A'] ) throw 1; //targetdrive not in use
 | 
			
		||||
		if ((arg == "/D") || (arg == "/d")) {
 | 
			
		||||
			if (!Drives[temp_str[0]-'A'] ) throw 1; //targetdrive not in use
 | 
			
		||||
			strcat(mountstring,"-u ");
 | 
			
		||||
			strcat(mountstring,temp_str);
 | 
			
		||||
			this->ParseLine(mountstring);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		if(Drives[temp_str[0]-'A'] ) throw 0; //targetdrive in use
 | 
			
		||||
		if (Drives[temp_str[0]-'A'] ) throw 0; //targetdrive in use
 | 
			
		||||
		strcat(mountstring,temp_str);
 | 
			
		||||
		strcat(mountstring," ");
 | 
			
		||||
 | 
			
		||||
   		Bit8u drive;char fulldir[DOS_PATHLENGTH];
 | 
			
		||||
		if (!DOS_MakeName(const_cast<char*>(arg.c_str()),fulldir,&drive)) throw 0;
 | 
			
		||||
	
 | 
			
		||||
		if( ( ldp=dynamic_cast<localDrive*>(Drives[drive])) == 0 ) throw 0;
 | 
			
		||||
		char newname[CROSS_LEN];   
 | 
			
		||||
 | 
			
		||||
		if ( ( ldp=dynamic_cast<localDrive*>(Drives[drive])) == 0 ) throw 0;
 | 
			
		||||
		char newname[CROSS_LEN];
 | 
			
		||||
		strcpy(newname, ldp->getBasedir());
 | 
			
		||||
		strcat(newname,fulldir);
 | 
			
		||||
		CROSS_FILENAME(newname);
 | 
			
		||||
		ldp->dirCache.ExpandName(newname);
 | 
			
		||||
		strcat(mountstring,"\"");	   
 | 
			
		||||
		strcat(mountstring,"\"");
 | 
			
		||||
		strcat(mountstring, newname);
 | 
			
		||||
		strcat(mountstring,"\"");	   
 | 
			
		||||
		strcat(mountstring,"\"");
 | 
			
		||||
		this->ParseLine(mountstring);
 | 
			
		||||
	}
 | 
			
		||||
	catch(int a){
 | 
			
		||||
		if(a == 0) {
 | 
			
		||||
		if (a == 0) {
 | 
			
		||||
			WriteOut(MSG_Get("SHELL_CMD_SUBST_FAILURE"));
 | 
			
		||||
		} else {
 | 
			
		||||
		       	WriteOut(MSG_Get("SHELL_CMD_SUBST_NO_REMOVE"));
 | 
			
		||||
| 
						 | 
				
			
			@ -1296,7 +1296,7 @@ void DOS_Shell::CMD_SUBST (char * args) {
 | 
			
		|||
		WriteOut(MSG_Get("SHELL_CMD_SUBST_FAILURE"));
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
   
 | 
			
		||||
 | 
			
		||||
	return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1305,8 +1305,8 @@ void DOS_Shell::CMD_LOADHIGH(char *args){
 | 
			
		|||
	Bit16u umb_start=dos_infoblock.GetStartOfUMBChain();
 | 
			
		||||
	Bit8u umb_flag=dos_infoblock.GetUMBChainState();
 | 
			
		||||
	Bit8u old_memstrat=(Bit8u)(DOS_GetMemAllocStrategy()&0xff);
 | 
			
		||||
	if (umb_start==0x9fff) {
 | 
			
		||||
		if ((umb_flag&1)==0) DOS_LinkUMBsToMemChain(1);
 | 
			
		||||
	if (umb_start == 0x9fff) {
 | 
			
		||||
		if ((umb_flag&1) == 0) DOS_LinkUMBsToMemChain(1);
 | 
			
		||||
		DOS_SetMemAllocStrategy(0x80);	// search in UMBs first
 | 
			
		||||
		this->ParseLine(args);
 | 
			
		||||
		Bit8u current_umb_flag=dos_infoblock.GetUMBChainState();
 | 
			
		||||
| 
						 | 
				
			
			@ -1340,17 +1340,17 @@ void DOS_Shell::CMD_CHOICE(char * args){
 | 
			
		|||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if (rem) rem += 2;
 | 
			
		||||
		if(rem && rem[0]==':') rem++; /* optional : after /c */
 | 
			
		||||
		if (rem && rem[0] == ':') rem++; /* optional : after /c */
 | 
			
		||||
		if (args > last) args = NULL;
 | 
			
		||||
	}
 | 
			
		||||
	if (!rem || !*rem) rem = defchoice; /* No choices specified use YN */
 | 
			
		||||
	ptr = rem;
 | 
			
		||||
	Bit8u c;
 | 
			
		||||
	if(!optS) while ((c = *ptr)) *ptr++ = (char)toupper(c); /* When in no case-sensitive mode. make everything upcase */
 | 
			
		||||
	if(args && *args ) {
 | 
			
		||||
	if (!optS) while ((c = *ptr)) *ptr++ = (char)toupper(c); /* When in no case-sensitive mode. make everything upcase */
 | 
			
		||||
	if (args && *args ) {
 | 
			
		||||
		StripSpaces(args);
 | 
			
		||||
		size_t argslen = strlen(args);
 | 
			
		||||
		if(argslen>1 && args[0] == '"' && args[argslen-1] =='"') {
 | 
			
		||||
		if (argslen > 1 && args[0] == '"' && args[argslen-1] == '"') {
 | 
			
		||||
			args[argslen-1] = 0; //Remove quotes
 | 
			
		||||
			args++;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -1358,10 +1358,10 @@ void DOS_Shell::CMD_CHOICE(char * args){
 | 
			
		|||
	}
 | 
			
		||||
	/* Show question prompt of the form [a,b]? where a b are the choice values */
 | 
			
		||||
	if (!optN) {
 | 
			
		||||
		if(args && *args) WriteOut(" ");
 | 
			
		||||
		if (args && *args) WriteOut(" ");
 | 
			
		||||
		WriteOut("[");
 | 
			
		||||
		size_t len = strlen(rem);
 | 
			
		||||
		for(size_t t = 1; t < len; t++) {
 | 
			
		||||
		for (size_t t = 1; t < len; t++) {
 | 
			
		||||
			WriteOut("%c,",rem[t-1]);
 | 
			
		||||
		}
 | 
			
		||||
		WriteOut("%c]?",rem[len-1]);
 | 
			
		||||
| 
						 | 
				
			
			@ -1384,10 +1384,10 @@ void DOS_Shell::CMD_ATTRIB(char *args){
 | 
			
		|||
 | 
			
		||||
void DOS_Shell::CMD_PATH(char *args){
 | 
			
		||||
	HELP("PATH");
 | 
			
		||||
	if(args && strlen(args)){
 | 
			
		||||
	if (args && strlen(args)){
 | 
			
		||||
		char pathstring[DOS_PATHLENGTH+CROSS_LEN+20]={ 0 };
 | 
			
		||||
		strcpy(pathstring,"set PATH=");
 | 
			
		||||
		while(args && *args && (*args=='='|| *args==' '))
 | 
			
		||||
		while (args && *args && (*args == '='|| *args == ' '))
 | 
			
		||||
		     args++;
 | 
			
		||||
		strcat(pathstring,args);
 | 
			
		||||
		this->ParseLine(pathstring);
 | 
			
		||||
| 
						 | 
				
			
			@ -1403,9 +1403,9 @@ void DOS_Shell::CMD_PATH(char *args){
 | 
			
		|||
 | 
			
		||||
void DOS_Shell::CMD_VER(char *args) {
 | 
			
		||||
	HELP("VER");
 | 
			
		||||
	if(args && strlen(args)) {
 | 
			
		||||
	if (args && strlen(args)) {
 | 
			
		||||
		char* word = StripWord(args);
 | 
			
		||||
		if(strcasecmp(word,"set")) return;
 | 
			
		||||
		if (strcasecmp(word,"set")) return;
 | 
			
		||||
		word = StripWord(args);
 | 
			
		||||
		if (!*args && !*word) { //Reset
 | 
			
		||||
			dos.version.major = 5;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue