-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
executable file
·772 lines (681 loc) · 19.1 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
/*
* UAE - The Un*x Amiga Emulator
*
* Main program
*
* Copyright 1995 Ed Hanway
* Copyright 1995, 1996, 1997 Bernd Schmidt
*/
#include "sysconfig.h"
#include "sysdeps.h"
#include <assert.h>
#include "options.h"
#include "threaddep/thread.h"
#include "uae.h"
#include "gensound.h"
#include "audio.h"
#include "sounddep/sound.h"
#include "events.h"
#include "memory.h"
#include "custom.h"
#include "serial.h"
#include "newcpu.h"
#include "disk.h"
#include "debug.h"
#include "xwin.h"
#include "inputdevice.h"
#include "keybuf.h"
#include "gui.h"
#include "zfile.h"
#include "autoconf.h"
#include "traps.h"
#include "osemu.h"
#include "filesys.h"
#include "picasso96.h"
#include "bsdsocket.h"
#include "uaeexe.h"
#include "native2amiga.h"
#include "scsidev.h"
//#include "akiko.h"
#include "savestate.h"
#include "hrtimer.h"
#include "sleep.h"
#include "version.h"
#ifdef USE_SDL
#include "SDL.h"
#endif
long int version = 256*65536L*UAEMAJOR + 65536L*UAEMINOR + UAESUBREV;
struct uae_prefs currprefs, changed_prefs;
int no_gui = 0;
int joystickpresent = 0;
int cloanto_rom = 0;
int log_scsi;
struct gui_info gui_data;
#ifdef WIN32
char warning_buffer[256];
#endif
char optionsfile[256];
void discard_prefs (struct uae_prefs *p, int type)
{
struct strlist **ps = &p->all_lines;
while (*ps) {
struct strlist *s = *ps;
*ps = s->next;
free (s->value);
free (s->option);
free (s);
}
#ifdef FILESYS
filesys_cleanup ();
free_mountinfo (p->mountinfo);
p->mountinfo = alloc_mountinfo ();
#endif
}
void fixup_prefs_dimensions (struct uae_prefs *prefs)
{
if (prefs->gfx_width_fs < 320)
prefs->gfx_width_fs = 320;
if (prefs->gfx_height_fs < 200)
prefs->gfx_height_fs = 200;
if (prefs->gfx_height_fs > 1280)
prefs->gfx_height_fs = 1280;
prefs->gfx_width_fs += 7;
prefs->gfx_width_fs &= ~7;
if (prefs->gfx_width_win < 320)
prefs->gfx_width_win = 320;
if (prefs->gfx_height_win < 200)
prefs->gfx_height_win = 200;
if (prefs->gfx_height_win > 1280)
prefs->gfx_height_win = 1280;
prefs->gfx_width_win += 7;
prefs->gfx_width_win &= ~7;
}
static void fixup_prefs_joysticks (struct uae_prefs *prefs)
{
int joy_count = inputdevice_get_device_total (IDTYPE_JOYSTICK);
/* If either port is configured to use a non-existent joystick, try
* to use a sensible alternative.
*/
if (prefs->jport0 >= JSEM_JOYS && prefs->jport0 < JSEM_MICE) {
if (prefs->jport0 - JSEM_JOYS >= joy_count)
prefs->jport0 = (prefs->jport1 != JSEM_MICE) ? JSEM_MICE : JSEM_NONE;
}
if (prefs->jport1 >= JSEM_JOYS && prefs->jport1 < JSEM_MICE) {
if (prefs->jport1 - JSEM_JOYS >= joy_count)
prefs->jport1 = (prefs->jport0 != JSEM_KBDLAYOUT) ? JSEM_KBDLAYOUT : JSEM_NONE;
}
}
static void fix_options (void)
{
int err = 0;
if ((currprefs.chipmem_size & (currprefs.chipmem_size - 1)) != 0
|| currprefs.chipmem_size < 0x40000
|| currprefs.chipmem_size > 0x800000)
{
//ric currprefs.chipmem_size = 0x200000;
currprefs.chipmem_size = 0x800000;
write_log ("Unsupported chipmem size!\n");
err = 1;
}
if (currprefs.chipmem_size > 0x80000)
currprefs.chipset_mask |= CSMASK_ECS_AGNUS;
if ((currprefs.fastmem_size & (currprefs.fastmem_size - 1)) != 0
|| (currprefs.fastmem_size != 0 && (currprefs.fastmem_size < 0x100000 || currprefs.fastmem_size > 0x800000)))
{
currprefs.fastmem_size = 0;
write_log ("Unsupported fastmem size!\n");
err = 1;
}
if ((currprefs.gfxmem_size & (currprefs.gfxmem_size - 1)) != 0
|| (currprefs.gfxmem_size != 0 && (currprefs.gfxmem_size < 0x100000 || currprefs.gfxmem_size > 0x2000000)))
{
write_log ("Unsupported graphics card memory size %lx!\n", currprefs.gfxmem_size);
currprefs.gfxmem_size = 0;
err = 1;
}
if ((currprefs.z3fastmem_size & (currprefs.z3fastmem_size - 1)) != 0
|| (currprefs.z3fastmem_size != 0 && (currprefs.z3fastmem_size < 0x100000 || currprefs.z3fastmem_size > 0x20000000)))
{
currprefs.z3fastmem_size = 0;
write_log ("Unsupported Zorro III fastmem size!\n");
err = 1;
}
if (currprefs.address_space_24 && (currprefs.gfxmem_size != 0 || currprefs.z3fastmem_size != 0)) {
currprefs.z3fastmem_size = currprefs.gfxmem_size = 0;
write_log ("Can't use a graphics card or Zorro III fastmem when using a 24 bit\n"
"address space - sorry.\n");
}
if (currprefs.bogomem_size != 0 && currprefs.bogomem_size != 0x80000 && currprefs.bogomem_size != 0x100000 && currprefs.bogomem_size != 0x180000)
{
currprefs.bogomem_size = 0;
write_log ("Unsupported bogomem size!\n");
err = 1;
}
if (currprefs.chipmem_size > 0x200000 && currprefs.fastmem_size != 0) {
write_log ("You can't use fastmem and more than 2MB chip at the same time!\n");
currprefs.fastmem_size = 0;
err = 1;
}
#if 0
if (currprefs.m68k_speed < -1 || currprefs.m68k_speed > 20) {
write_log ("Bad value for -w parameter: must be -1, 0, or within 1..20.\n");
currprefs.m68k_speed = 4;
err = 1;
}
#endif
if (currprefs.produce_sound < 0 || currprefs.produce_sound > 3) {
write_log ("Bad value for -S parameter: enable value must be within 0..3\n");
currprefs.produce_sound = 0;
err = 1;
}
#ifdef JIT
if (currprefs.comptrustbyte < 0 || currprefs.comptrustbyte > 3) {
write_log ("Bad value for comptrustbyte parameter: value must be within 0..2\n");
currprefs.comptrustbyte = 1;
err = 1;
}
if (currprefs.comptrustword < 0 || currprefs.comptrustword > 3) {
write_log ("Bad value for comptrustword parameter: value must be within 0..2\n");
currprefs.comptrustword = 1;
err = 1;
}
if (currprefs.comptrustlong < 0 || currprefs.comptrustlong > 3) {
write_log ("Bad value for comptrustlong parameter: value must be within 0..2\n");
currprefs.comptrustlong = 1;
err = 1;
}
if (currprefs.comptrustnaddr < 0 || currprefs.comptrustnaddr > 3) {
write_log ("Bad value for comptrustnaddr parameter: value must be within 0..2\n");
currprefs.comptrustnaddr = 1;
err = 1;
}
if (currprefs.compnf < 0 || currprefs.compnf > 1) {
write_log ("Bad value for compnf parameter: value must be within 0..1\n");
currprefs.compnf = 1;
err = 1;
}
if (currprefs.comp_hardflush < 0 || currprefs.comp_hardflush > 1) {
write_log ("Bad value for comp_hardflush parameter: value must be within 0..1\n");
currprefs.comp_hardflush = 1;
err = 1;
}
if (currprefs.comp_constjump < 0 || currprefs.comp_constjump > 1) {
write_log ("Bad value for comp_constjump parameter: value must be within 0..1\n");
currprefs.comp_constjump = 1;
err = 1;
}
if (currprefs.comp_oldsegv < 0 || currprefs.comp_oldsegv > 1) {
write_log ("Bad value for comp_oldsegv parameter: value must be within 0..1\n");
currprefs.comp_oldsegv = 1;
err = 1;
}
if (currprefs.cachesize < 0 || currprefs.cachesize > 16384) {
write_log ("Bad value for cachesize parameter: value must be within 0..16384\n");
currprefs.cachesize = 0;
err = 1;
}
#endif
if (currprefs.cpu_level < 2 && currprefs.z3fastmem_size > 0) {
write_log ("Z3 fast memory can't be used with a 68000/68010 emulation. It\n"
"requires a 68020 emulation. Turning off Z3 fast memory.\n");
currprefs.z3fastmem_size = 0;
err = 1;
}
if (currprefs.gfxmem_size > 0 && (currprefs.cpu_level < 2 || currprefs.address_space_24)) {
write_log ("Picasso96 can't be used with a 68000/68010 or 68EC020 emulation. It\n"
"requires a 68020 emulation. Turning off Picasso96.\n");
currprefs.gfxmem_size = 0;
err = 1;
}
#ifndef BSDSOCKET
if (currprefs.socket_emu) {
write_log ("Compile-time option of BSDSOCKET was not enabled. You can't use bsd-socket emulation.\n");
currprefs.socket_emu = 0;
err = 1;
}
#endif
if (currprefs.nr_floppies < 0 || currprefs.nr_floppies > 4) {
write_log ("Invalid number of floppies. Using 4.\n");
currprefs.nr_floppies = 4;
currprefs.dfxtype[0] = 0;
currprefs.dfxtype[1] = 0;
currprefs.dfxtype[2] = 0;
currprefs.dfxtype[3] = 0;
err = 1;
}
if (currprefs.floppy_speed > 0 && currprefs.floppy_speed < 10) {
currprefs.floppy_speed = 100;
}
if (currprefs.input_mouse_speed < 1 || currprefs.input_mouse_speed > 1000) {
currprefs.input_mouse_speed = 100;
}
if (currprefs.collision_level < 0 || currprefs.collision_level > 3) {
write_log ("Invalid collision support level. Using 1.\n");
currprefs.collision_level = 1;
err = 1;
}
fixup_prefs_dimensions (&currprefs);
#ifdef CPU_68000_ONLY
currprefs.cpu_level = 0;
#endif
#ifndef CPUEMU_0
currprefs.cpu_compatible = 1;
currprefs.address_space_24 = 1;
#endif
#if !defined(CPUEMU_5) && !defined (CPUEMU_6)
currprefs.cpu_compatible = 0;
currprefs.address_space_24 = 0;
#endif
#if !defined (CPUEMU_6)
currprefs.cpu_cycle_exact = currprefs.blitter_cycle_exact = 0;
#endif
#ifndef AGA
currprefs.chipset_mask &= ~CSMASK_AGA;
#endif
#ifndef AUTOCONFIG
currprefs.z3fastmem_size = 0;
currprefs.fastmem_size = 0;
currprefs.gfxmem_size = 0;
#endif
#if !defined (BSDSOCKET)
currprefs.socket_emu = 0;
#endif
#if !defined (SCSIEMU)
currprefs.scsi = 0;
#ifdef _WIN32
currprefs.win32_aspi = 0;
#endif
#endif
fixup_prefs_joysticks (&currprefs);
if (err)
write_log ("Please use \"uae -h\" to get usage information.\n");
}
int quit_program = 0;
static int restart_program;
static char restart_config[256];
void uae_reset (int hardreset)
{
if (quit_program == 0) {
quit_program = -2;
if (hardreset)
quit_program = -3;
}
}
void uae_quit (void)
{
if (quit_program != -1)
quit_program = -1;
}
/* 0 = normal, 1 = nogui, -1 = disable nogui */
void uae_restart (int opengui, char *cfgfile)
{
uae_quit ();
restart_program = opengui > 0 ? 1 : (opengui == 0 ? 2 : 3);
restart_config[0] = 0;
if (cfgfile)
strcpy (restart_config, cfgfile);
}
#ifndef DONT_PARSE_CMDLINE
void usage (void)
{
cfgfile_show_usage ();
}
static void show_version (void)
{
#ifdef PACKAGE_VERSION
write_log (PACKAGE_NAME " " PACKAGE_VERSION "\n");
#else
write_log ("UAE %d.%d.%d\n", UAEMAJOR, UAEMINOR, UAESUBREV);
#endif
write_log ("Build date: " __DATE__ " " __TIME__ "\n");
}
static void show_version_full (void)
{
write_log ("\n");
show_version ();
write_log ("\nCopyright 1995-2002 Bernd Schmidt\n");
write_log (" 1999-2005 Toni Wilen\n");
write_log (" 2003-2005 Richard Drummond\n\n");
write_log ("See the source for a full list of contributors.\n");
write_log ("This is free software; see the file COPYING for copying conditions. There is NO\n");
write_log ("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
}
static void parse_cmdline (int argc, char **argv)
{
int i;
for (i = 1; i < argc; i++) {
if (strcmp (argv[i], "-cfgparam") == 0) {
if (i + 1 < argc)
i++;
} else if (strncmp (argv[i], "-config=", 8) == 0) {
#ifdef FILESYS
free_mountinfo (currprefs.mountinfo);
currprefs.mountinfo = alloc_mountinfo ();
#endif
if (cfgfile_load (&currprefs, argv[i] + 8, 0))
strcpy (optionsfile, argv[i] + 8);
}
/* Check for new-style "-f xxx" argument, where xxx is config-file */
else if (strcmp (argv[i], "-f") == 0) {
if (i + 1 == argc) {
write_log ("Missing argument for '-f' option.\n");
} else {
#ifdef FILESYS
free_mountinfo (currprefs.mountinfo);
currprefs.mountinfo = alloc_mountinfo ();
#endif
if (cfgfile_load (&currprefs, argv[++i], 0))
strcpy (optionsfile, argv[i]);
}
} else if (strcmp (argv[i], "-s") == 0) {
if (i + 1 == argc)
write_log ("Missing argument for '-s' option.\n");
else
cfgfile_parse_line (&currprefs, argv[++i], 0);
} else if (strcmp (argv[i], "-h") == 0 || strcmp (argv[i], "-help") == 0) {
usage ();
exit (0);
} else if (strcmp (argv[i], "-version") == 0) {
show_version_full ();
exit (0);
} else if (strcmp (argv[i], "-scsilog") == 0) {
log_scsi = 1;
} else {
if (argv[i][0] == '-' && argv[i][1] != '\0') {
const char *arg = argv[i] + 2;
int extra_arg = *arg == '\0';
if (extra_arg)
arg = i + 1 < argc ? argv[i + 1] : 0;
if (parse_cmdline_option (&currprefs, argv[i][1], (char*)arg) && extra_arg)
i++;
}
}
}
}
#endif
static void parse_cmdline_and_init_file (int argc, char **argv)
{
char *home;
#ifdef _WIN32
extern char *start_path;
#endif
strcpy (optionsfile, "");
#ifdef OPTIONS_IN_HOME
home = getenv ("HOME");
if (home != NULL && strlen (home) < 240)
{
strcpy (optionsfile, home);
strcat (optionsfile, "/");
}
#endif
#ifdef _WIN32
sprintf( optionsfile, "%s\\Configurations\\", start_path );
#endif
strcat (optionsfile, OPTIONSFILENAME);
if (! cfgfile_load (&currprefs, optionsfile, 0)) {
// write_log ("failed to load config '%s'\n", optionsfile);
#ifdef OPTIONS_IN_HOME
/* sam: if not found in $HOME then look in current directory */
char *saved_path = strdup (optionsfile);
strcpy (optionsfile, OPTIONSFILENAME);
if (! cfgfile_load (&currprefs, optionsfile, 0) ) {
/* If not in current dir either, change path back to home
* directory - so that a GUI can save a new config file there */
strcpy (optionsfile, saved_path);
}
free (saved_path);
#endif
}
fix_options ();
parse_cmdline (argc, argv);
fix_options ();
}
void reset_all_systems (void)
{
init_eventtab ();
// thinkp
memory_cleanup ();
memory_init ();
// thinkp
memory_reset ();
#ifdef BSDSOCKET
bsdlib_reset ();
#endif
#ifdef FILESYS
filesys_reset ();
filesys_start_threads ();
hardfile_reset ();
#endif
#ifdef SCSIEMU
scsidev_reset ();
scsidev_start_threads ();
#endif
}
/* Okay, this stuff looks strange, but it is here to encourage people who
* port UAE to re-use as much of this code as possible. Functions that you
* should be using are do_start_program() and do_leave_program(), as well
* as real_main(). Some OSes don't call main() (which is braindamaged IMHO,
* but unfortunately very common), so you need to call real_main() from
* whatever entry point you have. You may want to write your own versions
* of start_program() and leave_program() if you need to do anything special.
* Add #ifdefs around these as appropriate.
*/
void do_start_program (void)
{
if (quit_program == -1)
return;
/* Do a reset on startup. Whether this is elegant is debatable. */
inputdevice_updateconfig (&currprefs);
// if (quit_program >= 0)
quit_program = 2;
m68k_go (1);
}
void do_leave_program (void)
{
graphics_leave ();
inputdevice_close ();
#ifdef SCSIEMU
scsidev_exit ();
#endif
DISK_free ();
close_sound ();
dump_counts ();
#ifdef SERIAL_PORT
serial_exit ();
#endif
/*
#ifdef CD32
akiko_free ();
#endif
*/
if (! no_gui)
gui_exit ();
#ifdef AUTOCONFIG
expansion_cleanup ();
#endif
#ifdef FILESYS
filesys_cleanup ();
#endif
#ifdef SAVESTATE
savestate_free ();
#endif
memory_cleanup ();
cfgfile_addcfgparam (0);
}
void start_program (void)
{
do_start_program ();
}
void leave_program (void)
{
do_leave_program ();
}
static void real_main2 (int argc, char **argv)
{
#if defined (NATMEM_OFFSET) && defined( _WIN32 ) && !defined( NO_WIN32_EXCEPTION_HANDLER )
extern int EvalException ( LPEXCEPTION_POINTERS blah, int n_except );
__try
#endif
{
if (! graphics_setup ()) {
exit (1);
}
if (restart_config[0]) {
#ifdef FILESYS
free_mountinfo (currprefs.mountinfo);
currprefs.mountinfo = alloc_mountinfo ();
#endif
default_prefs (&currprefs, 0);
fix_options ();
}
#ifdef NATMEM_OFFSET
init_shm ();
#endif
#ifdef FILESYS
rtarea_init ();
hardfile_install ();
#endif
if (restart_config[0])
parse_cmdline_and_init_file (argc, argv);
else
currprefs = changed_prefs;
uae_inithrtimer ();
sleep_test ();
machdep_init ();
if (! setup_sound ()) {
write_log ("Sound driver unavailable: Sound output disabled\n");
currprefs.produce_sound = 0;
}
inputdevice_init ();
changed_prefs = currprefs;
no_gui = ! currprefs.start_gui;
if (restart_program == 2)
no_gui = 1;
else if (restart_program == 3)
no_gui = 0;
if (! no_gui) {
int err = gui_init ();
struct uaedev_mount_info *mi = currprefs.mountinfo;
currprefs = changed_prefs;
currprefs.mountinfo = mi;
if (err == -1) {
write_log ("Failed to initialize the GUI\n");
if (restart_program == 3) {
restart_program = 0;
return;
}
} else if (err == -2) {
restart_program = 0;
return;
}
}
restart_program = 0;
#ifdef JIT
if (!(( currprefs.cpu_level >= 2 ) && ( currprefs.address_space_24 == 0 ) && ( currprefs.cachesize )))
canbang = 0;
#endif
#ifdef _WIN32
logging_init(); /* Yes, we call this twice - the first case handles when the user has loaded
a config using the cmd-line. This case handles loads through the GUI. */
#endif
fix_options ();
changed_prefs = currprefs;
#ifdef SAVESTATE
savestate_init ();
#endif
#ifdef SCSIEMU
scsidev_install ();
#endif
#ifdef AUTOCONFIG
/* Install resident module to get 8MB chipmem, if requested */
rtarea_setup ();
#endif
keybuf_init (); /* Must come after init_joystick */
#ifdef AUTOCONFIG
expansion_init ();
#endif
memory_init ();
memory_reset ();
#ifdef FILESYS
filesys_install ();
#endif
#ifdef AUTOCONFIG
bsdlib_install ();
emulib_install ();
uaeexe_install ();
native2amiga_install ();
#endif
if (custom_init ()) { /* Must come after memory_init */
#ifdef SERIAL_PORT
serial_init ();
#endif
DISK_init ();
reset_frame_rate_hack ();
init_m68k(); /* must come after reset_frame_rate_hack (); */
gui_update ();
if (graphics_init ()) {
#ifdef DEBUGGER
setup_brkhandler ();
if (currprefs.start_debugger && debuggable ())
activate_debugger ();
#endif
#ifdef WIN32
#ifdef FILESYS
filesys_init (); /* New function, to do 'add_filesys_unit()' calls at start-up */
#endif
#endif
if (sound_available && currprefs.produce_sound > 1 && ! init_audio ()) {
write_log ("Sound driver unavailable: Sound output disabled\n");
currprefs.produce_sound = 0;
}
start_program ();
}
}
}
#if defined (NATMEM_OFFSET) && defined( _WIN32 ) && !defined( NO_WIN32_EXCEPTION_HANDLER )
__except( EvalException( GetExceptionInformation(), GetExceptionCode() ) )
{
// EvalException does the good stuff...
}
#endif
}
void real_main (int argc, char **argv)
{
//ric show_version ();
restart_program = 1;
strcpy (restart_config, "");
#ifdef _WIN32
sprintf (restart_config, "%sConfigurations\\", start_path);
#endif
strcat (restart_config, OPTIONSFILENAME);
while (restart_program) {
changed_prefs = currprefs;
real_main2 (argc, argv);
leave_program ();
quit_program = 0;
}
zfile_exit ();
}
#ifdef USE_SDL
int init_sdl (void)
{
int result = (SDL_Init (SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE /*| SDL_INIT_AUDIO*/) == 0);
if (result)
atexit (SDL_Quit);
return result;
}
#else
#define init_sdl()
#endif
#ifndef NO_MAIN_IN_MAIN_C
int main (int argc, char **argv)
{
init_sdl ();
real_main (argc, argv);
return 0;
}
#endif
#ifdef SINGLEFILE
uae_u8 singlefile_config[50000] = { "_CONFIG_STARTS_HERE" };
uae_u8 singlefile_data[1500000] = { "_DATA_STARTS_HERE" };
#endif