/[projet1]/public/pc/tools/osdk/main/makedisk/FloppyBuilder.cpp
Defence Force logotype

Diff of /public/pc/tools/osdk/main/makedisk/FloppyBuilder.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1012 by dbug, Wed Dec 11 20:11:41 2013 UTC revision 1013 by dbug, Thu Dec 12 19:35:12 2013 UTC
# Line 19  void main(int argc, char *argv[]) Line 19  void main(int argc, char *argv[])
19    // Some initialization for the common library    // Some initialization for the common library
20    //    //
21    SetApplicationParameters(    SetApplicationParameters(
22      "MakeDisk",      "FloppyBuilder",
23      TOOL_VERSION_MAJOR,      TOOL_VERSION_MAJOR,
24      TOOL_VERSION_MINOR,      TOOL_VERSION_MINOR,
25      "{ApplicationName} - Version {ApplicationVersion} - This program is a part of the OSDK\r\n"      "{ApplicationName} - Version {ApplicationVersion} - This program is a part of the OSDK\r\n"
# Line 48  void main(int argc, char *argv[]) Line 48  void main(int argc, char *argv[])
48    }    }
49    
50    
51    if (argc!=4)    if (argc!=3)
52    {    {
53      ShowError(nullptr);      ShowError(nullptr);
54    }    }
# Line 62  void main(int argc, char *argv[]) Line 62  void main(int argc, char *argv[])
62    strcpy(description_name,argv[param]);    strcpy(description_name,argv[param]);
63    
64    char source_name[_MAX_PATH];    char source_name[_MAX_PATH];
   char dest_name[_MAX_PATH];  
65    param++;    param++;
66    strcpy(source_name,argv[param]);    strcpy(source_name,argv[param]);
   param++;  
   strcpy(dest_name,argv[param]);  
67    
   //char ligne[900];  
68    int start=0;    int start=0;
69    
70      //std::string templateFloppyDiskName;
71      std::string targetFloppyDiskName;
72    
73    //    //
74    // Open the description file    // Open the description file
# Line 78  void main(int argc, char *argv[]) Line 76  void main(int argc, char *argv[])
76    std::vector<std::string> script;    std::vector<std::string> script;
77    if (!LoadText(description_name,script))    if (!LoadText(description_name,script))
78    {    {
79      printf("Can't load script file '%s'\n",description_name);      ShowError("Can't load script file '%s'\n",description_name);
     exit(1);  
80    }    }
81    
82    //    //
# Line 88  void main(int argc, char *argv[]) Line 85  void main(int argc, char *argv[])
85    Floppy floppy;    Floppy floppy;
86    if (!floppy.LoadDisk(source_name))    if (!floppy.LoadDisk(source_name))
87    {    {
88      printf("FloppyBuilder: Can't load '%s'\n",source_name);      ShowError("FloppyBuilder: Can't load '%s'\n",source_name);
     exit(1);  
89    }    }
90    
91    std::string outputLayoutFileName;    std::string outputLayoutFileName;
# Line 106  void main(int argc, char *argv[]) Line 102  void main(int argc, char *argv[])
102    {    {
103      ++lineNumber;      ++lineNumber;
104    
105      const std::string currentLine(*it);      std::string currentLine(*it);
106    
107        std::size_t found = currentLine.find(";");
108        if (found!=std::string::npos)
109        {
110          // Comments, just skip them
111          currentLine=currentLine.substr(0,found);
112        }
113    
114      std::istringstream iss(currentLine);      std::istringstream iss(currentLine);
115    
116      std::string item;      std::string item;
117      std::vector<std::string> tokens;      std::vector<std::string> tokens;
118      while (std::getline(iss, item,' '))      while (std::getline(iss,item,' '))
119      {      {
120        if (!item.empty())        if (!item.empty())
121        {        {
# Line 122  void main(int argc, char *argv[]) Line 125  void main(int argc, char *argv[])
125    
126      if (!tokens.empty())      if (!tokens.empty())
127      {      {
128        if (tokens[0][0]==';')        if (tokens[0]=="OutputLayoutFile")
129        {        {
130          // Comments, just skip them          if (tokens.size()==2)
131            {
132              outputLayoutFileName=tokens[1];
133            }
134            else
135            {
136              ShowError("Syntax error line (%d), syntax is 'OutputLayoutFile FilePath' \n",lineNumber);
137            }
138        }        }
139        else        else
140        if (tokens[0]=="OutputLayoutFile")        if (tokens[0]=="OutputFloppyFile")
141        {        {
142          if (tokens.size()==2)          if (tokens.size()==2)
143          {          {
144            outputLayoutFileName=tokens[1];            targetFloppyDiskName=tokens[1];
145          }          }
146          else          else
147          {          {
148            printf("Syntax error line (%d), syntax is 'OutputLayoutFile FilePath' \n",lineNumber);            ShowError("Syntax error line (%d), syntax is 'targetFloppyDiskName FilePath' \n",lineNumber);
149          }          }
150        }        }
151        else        else
# Line 144  void main(int argc, char *argv[]) Line 154  void main(int argc, char *argv[])
154          if (tokens.size()==3)          if (tokens.size()==3)
155          {          {
156            currentTrack =std::atoi(tokens[1].c_str());            currentTrack =std::atoi(tokens[1].c_str());
157              if ( (currentTrack<0) || (currentTrack>41) )
158              {
159                ShowError("Syntax error line (%d), TrackNumber has to be between 0 and 41' \n",lineNumber);
160              }
161            currentSector=std::atoi(tokens[2].c_str());            currentSector=std::atoi(tokens[2].c_str());
162              if ( (currentSector<0) || (currentSector>41) )
163              {
164                ShowError("Syntax error line (%d), SectorNumber has to be between 1 and 17' \n",lineNumber);
165              }
166            floppy.SetOffset(currentTrack,currentSector);            floppy.SetOffset(currentTrack,currentSector);
167          }          }
168          else          else
169          {          {
170            printf("Syntax error line (%d), syntax is 'SetPosition TrackNumber SectorNumber' \n",lineNumber);            ShowError("Syntax error line (%d), syntax is 'SetPosition TrackNumber SectorNumber' \n",lineNumber);
171          }          }
172        }        }
173        else        else
# Line 169  void main(int argc, char *argv[]) Line 187  void main(int argc, char *argv[])
187            }            }
188            else            else
189            {            {
190              printf("Syntax error line (%d), syntax is 'SetBootSector Jasmin|Microdisc FilePath'. '%s' is not a valid type \n",lineNumber,tokens[1].c_str());              ShowError("Syntax error line (%d), syntax is 'SetBootSector Jasmin|Microdisc FilePath'. '%s' is not a valid type \n",lineNumber,tokens[1].c_str());
191            }            }
192          }          }
193          else          else
194          {          {
195            printf("Syntax error line (%d), syntax is 'SetBootSector Jasmin|Microdisc FilePath' \n",lineNumber);            ShowError("Syntax error line (%d), syntax is 'SetBootSector Jasmin|Microdisc FilePath' \n",lineNumber);
196          }          }
197        }        }
198        else        else
# Line 195  void main(int argc, char *argv[]) Line 213  void main(int argc, char *argv[])
213          }          }
214          else          else
215          {          {
216            printf("Syntax error line (%d), syntax is 'AddFile FilePath LoadAddress' \n",lineNumber);            ShowError("Syntax error line (%d), syntax is 'AddFile FilePath LoadAddress' \n",lineNumber);
217          }          }
218        }        }
219        else        else
# Line 207  void main(int argc, char *argv[]) Line 225  void main(int argc, char *argv[])
225          }          }
226          else          else
227          {          {
228            printf("Syntax error line (%d), syntax is 'AddDefine DefineName DefineValue' \n",lineNumber);            ShowError("Syntax error line (%d), syntax is 'AddDefine DefineName DefineValue' \n",lineNumber);
229          }          }
230        }        }
231        else        else
232        {        {
233          printf("Syntax error line (%d), unknown keyword '%s' \n",lineNumber,tokens[0].c_str());          ShowError("Syntax error line (%d), unknown keyword '%s' \n",lineNumber,tokens[0].c_str());
         exit(1);  
234        }        }
235      }      }
236    }    }
# Line 222  void main(int argc, char *argv[]) Line 239  void main(int argc, char *argv[])
239    
240    if (!floppy.SaveDescription(outputLayoutFileName.c_str()))    if (!floppy.SaveDescription(outputLayoutFileName.c_str()))
241    {    {
242      printf("Failed saving description '%s'\n",outputLayoutFileName.c_str());      ShowError("Failed saving description '%s'\n",outputLayoutFileName.c_str());
     exit(1);  
243    }    }
244    
245    if (!floppy.SaveDisk(dest_name))    if (!floppy.SaveDisk(targetFloppyDiskName.c_str()))
246    {    {
247      printf("Failed saving disk '%s'\n",dest_name);      ShowError("Failed saving disk '%s'\n",targetFloppyDiskName.c_str());
     exit(1);  
248    }    }
249    else    else
250    {    {
251      printf("Successfully created '%s'\n",dest_name);      printf("Successfully created '%s'\n",targetFloppyDiskName.c_str());
252    }    }
253  }  }

Legend:
Removed from v.1012  
changed lines
  Added in v.1013

  ViewVC Help
Powered by ViewVC 1.1.26