Пример #1
0
Link data and create a .z80 file";

int main (int argc, char **argv)
{
	try
	{
		int i;
		COptionParser optParser(appliOption, appliName, appliUsageShort, appliUsageLong, authorName, authorMail);
		
		optParser.PrintHeader(std::cout);

		if (!optParser.ParseCommandLine(&argc, &argv, 0, true))
		{
			optParser.PrintError(std::cout);
			optParser.PrintUsage(std::cout);
			return -1;
		}
	
		i=0;
		while (optParser.GetOptionI(i) != 0)
		{
			switch(optParser.GetOptionI(i))
			{
			case 'd' :
				{
					SDataLinker file;
					std::string name = optParser.GetStringOptionI(i, 0);
					std::string label = optParser.GetStringOptionI(i, 1);
					unsigned int mask = optParser.GetIntOptionI(i, 2);
					file.data = CDataLink(name, label, mask);
					file.data.loadFile();
					file.adr = -1;
					linkerDataTable.push_back(file);
					break;
				}
			case 'z':
				{
					SDataZone zone;
					zone.name = optParser.GetStringOptionI(i, 0);
					zone.bank = optParser.GetIntOptionI(i, 1);
					zone.start = optParser.GetIntOptionI(i, 2);
					zone.end = optParser.GetIntOptionI(i, 3);
					linkerZoneTable.push_back(zone);
					break;
				}
			case 'o' : 
				{
					linkerOutASM = new std::ofstream(optParser.GetStringOptionI(i, 0).c_str());
					break;
				}
			case 'c' : {break;}
			default :
				{
					std::cerr << "Unknow option ! " << optParser.GetOptionI(i) << std::endl;
					return -1;
				}
			}
			i++;
		}
	
		linkData();
	
		saveFile();
	}
	catch(tools::CException &e)
	{
		std::cerr << e << std::endl;
		return -1;
	}

	return 0;
}
Пример #2
0
int main(int argc, char* argv[])
{
	try
	{
		COptionParser optParser(appliOption, appliName, appliUsageShort, appliUsageLong, authorName, authorMail);
		
		optParser.PrintHeader(std::cout);

		if (!optParser.ParseCommandLine(&argc, &argv, 2, false))
		{
			optParser.PrintError(std::cout);
			optParser.PrintUsage(std::cout);
			return -1;
		}
	
		bool headerCheck = !optParser.FindOption('n');		
		
		std::ifstream inFile;
		inFile.open(argv[1],std::ios::in | std::ios::binary);
		
		TOOLS_ASSERTMSG(inFile.good(),"Unable to open " << argv[1]);
		
		std::ofstream outFile;
		outFile.open(argv[2]);
		
		TOOLS_ASSERTMSG(outFile.good(),"Unable to open " << argv[2]);

		if (headerCheck)
		{
			if (hasHeader(inFile))
			{
				inFile.seekg(0x80,std::ios::beg);
			}
		}

		unsigned char c;
		c = (unsigned char)inFile.get();
		while (!inFile.eof() && c!=0)
		{
			if (c == 0xff)
			{
				// Commentaire ligne
				outFile << ";";
				c = (unsigned char)inFile.get();
				while (c != 0xd)
				{
					outFile << c;
					c = (unsigned char)inFile.get();
				}
				outFile << std::endl;
			}
			else
			{
				if (c >= 0x80 && c!= 0x0d)
				{
					// Mnemonique sans label
					// ENT
					if (c == 0xc9)
						outFile << ";";
					outFile << "\t" << damsMnemonique[c-0x80] << "\t";
					// DS ?,?
					if (c == 0xc6)
					{
						c = (unsigned char)inFile.get();
						// Fin de ligne
						while (c != 0x0d)
						{
							if (c == ',')
							{
								while (c != 0x0d && c != 0xff)
									c = (unsigned char)inFile.get();
							}
							if (c != 0x0d)
							{
								if (c == 0xff)
									outFile << "\t;";
								else		  
									outFile << c;
								c = (unsigned char)inFile.get();
							}
						}
					}
					else
					{
						c = (unsigned char)inFile.get();
						// Fin de ligne
						while (c != 0x0d)
						{
							if (c == 0xff)
								outFile << "\t;";
							else		  
								outFile << c;
							c = (unsigned char)inFile.get();
						}
					}
					outFile << std::endl;

				}
				else
				{
					// Label
					while (c < 0x80 && c != 0x0d)
					{
						outFile << c;
						c = (unsigned char)inFile.get();
					}
					if (c != 0x0d)
					{
						// Mnemonique apres label
						// ENT
						if (c == 0xc9)
							outFile << ";";
						if (c != 0xff)
							outFile << "\t" << damsMnemonique[c-0x80] << "\t";
						else
							outFile << "\t\t\t;";
						// DS ?,?
						if (c == 0xc6)
						{
							c = (unsigned char)inFile.get();
							// Fin de ligne
							while (c != 0x0d)
							{
								if (c == ',')
								{
									while (c != 0x0d && c != 0xff)
										c = (unsigned char)inFile.get();
								}
								if (c != 0x0d)
								{
									if (c == 0xff)
										outFile << "\t;";
									else		  
										outFile << c;
									c = (unsigned char)inFile.get();
								}
							}
						}
						else
						{
							c = (unsigned char)inFile.get();
							// Fin de ligne
							while (c != 0x0d)
							{
								if (c == 0xff)
									outFile << "\t;";
								else		  
									outFile << c;
								c = (unsigned char)inFile.get();
							}
						}
						outFile << std::endl;
					}
					else
					{
						outFile << std::endl;
					}
				}
			}
			if (!inFile.eof())
				c = (unsigned char)inFile.get();
		}
	}
	catch(tools::CException &e)
	{
		std::cerr << e << std::endl;
		return -1;
	}
	return 0;
}
Пример #3
0
int main(int argc, char *argv[])
{
	try
	{
		COptionParser optParser(appliOption, appliName, appliUsageShort, appliUsageLong, authorName, authorMail);
		
		optParser.PrintHeader(std::cout);

		if (!optParser.ParseCommandLine(&argc, &argv, 0, false))
		{
			optParser.PrintError(std::cout);
			optParser.PrintUsage(std::cout);
			return -1;
		}

		bool noLoop = false;
		std::string COMport = defaultComPort();
		std::string filename = "";
		std::string dir = "";
		int baudrate = 115200;

		
		int i=0;
		while (optParser.GetOptionI(i) != 0)
		{
			switch(optParser.GetOptionI(i))
			{
			case 'p':
				{
					COMport = optParser.GetStringOptionI(i);
					break;
				}
			case 'b':
				{
					baudrate = optParser.GetIntOptionI(i);
					break;
				}
			case 'f':
				{
					filename = optParser.GetStringOptionI(i);
					noLoop = true;
					break;
				}
			case 'd':
				{
					dir = optParser.GetStringOptionI(i);
					break;
				}
			case 'n':
				{
					noLoop = true;
					break;
				}
			default:
				{
					break;
				}
			}

			i++;
		}

		for(unsigned int i = 0; i < sizeof(devicePrefixes) / sizeof(devicePrefixes[0]); i++)
		{
			std::string device = devicePrefixes[i] + COMport;
			CAksFileTransfert transfert(device, baudrate);

			if (!transfert.IsOpen())
				continue;
			else
				std::cout << "AFT now listening on " << device << std::endl;

			if (filename.size() != 0)
				transfert.SetForceFilename(filename);

			if (dir.size() != 0)
				transfert.SetFilepath(dir);

			while (!noLoop || (noLoop && (transfert.GetNbTransfertDone() != 1)))
				transfert.Run();

			return 0;
		}

		std::cout << "Unable to open COM port " << COMport << std::endl;
		return -1;
	}
	catch(tools::CException &e)
	{
		std::cerr << e << std::endl;
		return -1;
	}
}