1 /*****************************************************************************/
5 /* sim65 main program */
9 /* (C) 2002 Ullrich von Bassewitz */
11 /* D-70597 Stuttgart */
12 /* EMail: uz@cc65.org */
15 /* This software is provided 'as-is', without any expressed or implied */
16 /* warranty. In no event will the authors be held liable for any damages */
17 /* arising from the use of this software. */
19 /* Permission is granted to anyone to use this software for any purpose, */
20 /* including commercial applications, and to alter it and redistribute it */
21 /* freely, subject to the following restrictions: */
23 /* 1. The origin of this software must not be misrepresented; you must not */
24 /* claim that you wrote the original software. If you use this software */
25 /* in a product, an acknowledgment in the product documentation would be */
26 /* appreciated but is not required. */
27 /* 2. Altered source versions must be plainly marked as such, and must not */
28 /* be misrepresented as being the original software. */
29 /* 3. This notice may not be removed or altered from any source */
32 /*****************************************************************************/
61 /*****************************************************************************/
63 /*****************************************************************************/
67 static void Usage (void)
70 "Usage: %s [options] file\n"
72 " -C name\t\tUse simulator config file\n"
73 " -L dir\t\tSet a chip directory search path\n"
74 " -V\t\t\tPrint the simulator version number\n"
75 " -d\t\t\tDebug mode\n"
76 " -h\t\t\tHelp (this text)\n"
77 " -v\t\t\tIncrease verbosity\n"
80 " --chipdir dir\t\tSet a chip directory search path\n"
81 " --config name\t\tUse simulator config file\n"
82 " --cpu type\t\tSet cpu type\n"
83 " --debug\t\tDebug mode\n"
84 " --help\t\tHelp (this text)\n"
85 " --verbose\t\tIncrease verbosity\n"
86 " --version\t\tPrint the simulator version number\n",
92 static void OptChipDir (const char* Opt attribute ((unused)), const char* Arg)
93 /* Handle the --chipdir option */
100 static void OptCPU (const char* Opt, const char* Arg)
101 /* Handle the --cpu option */
103 if (strcmp (Arg, "6502") == 0) {
105 } else if (strcmp (Arg, "65C02") == 0) {
108 AbEnd ("Invalid argument for %s: `%s'", Opt, Arg);
114 static void OptConfig (const char* Opt attribute ((unused)), const char* Arg)
115 /* Define the config file */
118 Error ("Cannot use -C twice");
125 static void OptDebug (const char* Opt attribute ((unused)),
126 const char* Arg attribute ((unused)))
127 /* Simulator debug mode */
134 static void OptHelp (const char* Opt attribute ((unused)),
135 const char* Arg attribute ((unused)))
136 /* Print usage information and exit */
144 static void OptVerbose (const char* Opt attribute ((unused)),
145 const char* Arg attribute ((unused)))
146 /* Increase verbosity */
153 static void OptVersion (const char* Opt attribute ((unused)),
154 const char* Arg attribute ((unused)))
155 /* Print the assembler version */
159 VER_MAJOR, VER_MINOR, VER_PATCH);
164 int main (int argc, char* argv[])
166 /* Program long options */
167 static const LongOpt OptTab[] = {
168 { "--chipdir", 1, OptChipDir },
169 { "--config", 1, OptConfig },
170 { "--cpu", 1, OptCPU },
171 { "--debug", 0, OptDebug },
172 { "--help", 0, OptHelp },
173 { "--verbose", 0, OptVerbose },
174 { "--version", 0, OptVersion },
179 /* Initialize the output file name */
180 const char* InputFile = 0;
182 /* Initialize the cmdline module */
183 InitCmdLine (&argc, &argv, "sim65");
185 /* Parse the command line */
187 while (I < ArgCount) {
189 /* Get the argument */
190 const char* Arg = ArgVec[I];
192 /* Check for an option */
193 if (Arg [0] == '-') {
198 LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
215 OptConfig (Arg, GetArg (&I, 2));
219 OptChipDir (Arg, GetArg (&I, 2));
232 fprintf (stderr, "additional file specs ignored\n");
242 /* Check if we have a valid configuration */
244 Error ("Simulator configuration missing");
248 AddChipPath ("chips");
249 LoadChipLibrary ("ram.so");
252 /* Read the config file */
261 /* Return an apropriate exit code */