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 /*****************************************************************************/
57 /*****************************************************************************/
59 /*****************************************************************************/
63 static void Usage (void)
66 "Usage: %s [options] file\n"
68 " -V\t\t\tPrint the simulator version number\n"
69 " -d\t\t\tDebug mode\n"
70 " -h\t\t\tHelp (this text)\n"
71 " -v\t\t\tIncrease verbosity\n"
74 " --cpu type\t\tSet cpu type\n"
75 " --debug\t\tDebug mode\n"
76 " --help\t\tHelp (this text)\n"
77 " --verbose\t\tIncrease verbosity\n"
78 " --version\t\tPrint the simulator version number\n",
84 static void OptCPU (const char* Opt, const char* Arg)
85 /* Handle the --cpu option */
87 if (strcmp (Arg, "6502") == 0) {
89 } else if (strcmp (Arg, "65C02") == 0) {
92 AbEnd ("Invalid argument for %s: `%s'", Opt, Arg);
98 static void OptDebug (const char* Opt attribute ((unused)),
99 const char* Arg attribute ((unused)))
100 /* Simulator debug mode */
107 static void OptHelp (const char* Opt attribute ((unused)),
108 const char* Arg attribute ((unused)))
109 /* Print usage information and exit */
117 static void OptVerbose (const char* Opt attribute ((unused)),
118 const char* Arg attribute ((unused)))
119 /* Increase verbosity */
126 static void OptVersion (const char* Opt attribute ((unused)),
127 const char* Arg attribute ((unused)))
128 /* Print the assembler version */
132 VER_MAJOR, VER_MINOR, VER_PATCH);
137 int main (int argc, char* argv[])
139 /* Program long options */
140 static const LongOpt OptTab[] = {
141 { "--cpu", 1, OptCPU },
142 { "--debug", 0, OptDebug },
143 { "--help", 0, OptHelp },
144 { "--verbose", 0, OptVerbose },
145 { "--version", 0, OptVersion },
150 /* Initialize the output file name */
151 const char* InputFile = 0;
153 /* Initialize the cmdline module */
154 InitCmdLine (&argc, &argv, "sim65");
156 /* Parse the command line */
158 while (I < ArgCount) {
160 /* Get the argument */
161 const char* Arg = ArgVec[I];
163 /* Check for an option */
164 if (Arg [0] == '-') {
169 LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
195 fprintf (stderr, "additional file specs ignored\n");
205 /* Initialize modules */
206 AddChipPath ("chips");
207 LoadChipLibrary ("ram.so");
210 MemLoad ("uz.bin", 0x200, 0);
214 /* Return an apropriate exit code */