40 |
|
using std::string; |
41 |
|
|
42 |
|
#include "cpu_emulation.h" |
43 |
< |
#include "macos_util_macosx.h" |
44 |
< |
#include "main.h" |
43 |
> |
#include "sys.h" |
44 |
> |
#include "rom_patches.h" |
45 |
> |
#include "xpram.h" |
46 |
> |
#include "video.h" |
47 |
|
#include "prefs.h" |
48 |
|
#include "prefs_editor.h" |
49 |
< |
#include "rom_patches.h" |
48 |
< |
#include "sigsegv.h" |
49 |
< |
#include "sys.h" |
49 |
> |
#include "macos_util_macosx.h" |
50 |
|
#include "user_strings.h" |
51 |
|
#include "version.h" |
52 |
< |
#include "video.h" |
52 |
> |
#include "main.h" |
53 |
|
#include "vm_alloc.h" |
54 |
< |
#include "xpram.h" |
54 |
> |
#include "sigsegv.h" |
55 |
|
|
56 |
|
#if USE_JIT |
57 |
< |
extern void flush_icache_range(uint8 *start, uint32 size); // from compemu_support.cpp |
57 |
> |
extern void flush_icache_range(uint8 *start, uint32 size); // from compemu_support.cpp |
58 |
|
#endif |
59 |
|
|
60 |
|
#ifdef ENABLE_MON |
155 |
|
return SIGSEGV_RETURN_FAILURE; |
156 |
|
} |
157 |
|
|
158 |
– |
|
158 |
|
/* |
159 |
|
* Dump state when everything went wrong after a SEGV |
160 |
|
*/ |
199 |
|
|
200 |
|
static void usage(const char *prg_name) |
201 |
|
{ |
202 |
< |
printf("Usage: %s [OPTION...]\n", prg_name); |
203 |
< |
printf("\nUnix options:\n"); |
204 |
< |
printf(" --help\n display this usage message\n"); |
205 |
< |
printf(" --config FILE\n read/write configuration from/to FILE\n"); |
206 |
< |
printf(" --break ADDRESS\n set ROM breakpoint\n"); |
207 |
< |
printf(" --rominfo\n dump ROM information\n"); |
208 |
< |
LoadPrefs(); // read the prefs file so PrefsPrintUsage() will print the correct default values |
202 |
> |
printf( |
203 |
> |
"Usage: %s [OPTION...]\n" |
204 |
> |
"\nUnix options:\n" |
205 |
> |
" --config FILE\n read/write configuration from/to FILE\n" |
206 |
> |
" --break ADDRESS\n set ROM breakpoint\n" |
207 |
> |
" --rominfo\n dump ROM information\n", prg_name |
208 |
> |
); |
209 |
> |
LoadPrefs(NULL); // read the prefs file so PrefsPrintUsage() will print the correct default values |
210 |
|
PrefsPrintUsage(); |
211 |
|
exit(0); |
212 |
|
} |
213 |
|
|
214 |
|
int main(int argc, char **argv) |
215 |
|
{ |
216 |
+ |
const char *vmdir = NULL; |
217 |
+ |
char str[256]; |
218 |
+ |
|
219 |
|
// Initialize variables |
220 |
|
RAMBaseHost = NULL; |
221 |
|
ROMBaseHost = NULL; |
233 |
|
} else if (strncmp(argv[i], "-psn_", 5) == 0) {// OS X process identifier |
234 |
|
i++; |
235 |
|
} else if (strcmp(argv[i], "--break") == 0) { |
236 |
< |
i++; |
237 |
< |
if (i < argc) |
236 |
> |
argv[i++] = NULL; |
237 |
> |
if (i < argc) { |
238 |
|
ROMBreakpoint = strtol(argv[i], NULL, 0); |
239 |
+ |
argv[i] = NULL; |
240 |
+ |
} |
241 |
|
} else if (strcmp(argv[i], "--config") == 0) { |
242 |
|
argv[i++] = NULL; |
243 |
|
if (i < argc) { |
246 |
|
argv[i] = NULL; |
247 |
|
} |
248 |
|
} else if (strcmp(argv[i], "--rominfo") == 0) { |
249 |
+ |
argv[i] = NULL; |
250 |
|
PrintROMInfo = true; |
251 |
< |
} else if (argv[i][0] == '-') { |
252 |
< |
fprintf(stderr, "Unrecognized option '%s'\n", argv[i]); |
253 |
< |
usage(argv[0]); |
251 |
> |
} |
252 |
> |
} |
253 |
> |
|
254 |
> |
// Remove processed arguments |
255 |
> |
for (int i=1; i<argc; i++) { |
256 |
> |
int k; |
257 |
> |
for (k=i; k<argc; k++) |
258 |
> |
if (argv[k] != NULL) |
259 |
> |
break; |
260 |
> |
if (k > i) { |
261 |
> |
k -= i; |
262 |
> |
for (int j=i+k; j<argc; j++) |
263 |
> |
argv[j-k] = argv[j]; |
264 |
> |
argc -= k; |
265 |
|
} |
266 |
|
} |
267 |
|
|
268 |
|
// Read preferences |
269 |
< |
PrefsInit(argc, argv); |
269 |
> |
PrefsInit(vmdir, argc, argv); |
270 |
> |
|
271 |
> |
// Any command line arguments left? |
272 |
> |
for (int i=1; i<argc; i++) { |
273 |
> |
if (argv[i][0] == '-') { |
274 |
> |
fprintf(stderr, "Unrecognized option '%s'\n", argv[i]); |
275 |
> |
usage(argv[0]); |
276 |
> |
} |
277 |
> |
} |
278 |
|
|
279 |
|
// Init system routines |
280 |
|
SysInit(); |