384 |
|
return false; |
385 |
|
} |
386 |
|
|
387 |
< |
int main(int argc, char **argv) |
387 |
> |
static void get_system_info(void) |
388 |
|
{ |
389 |
– |
char str[256]; |
390 |
– |
int rom_fd; |
391 |
– |
FILE *proc_file; |
392 |
– |
const char *rom_path; |
393 |
– |
uint32 rom_size, actual; |
394 |
– |
uint8 *rom_tmp; |
395 |
– |
time_t now, expire; |
396 |
– |
bool memory_mapped_from_zero, ram_rom_areas_contiguous; |
397 |
– |
const char *vmdir = NULL; |
398 |
– |
|
399 |
– |
#ifdef USE_SDL_VIDEO |
400 |
– |
// Don't let SDL block the screensaver |
401 |
– |
setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", TRUE); |
402 |
– |
|
403 |
– |
// Make SDL pass through command-clicks and option-clicks unaltered |
404 |
– |
setenv("SDL_HAS3BUTTONMOUSE", "1", TRUE); |
405 |
– |
#endif |
406 |
– |
|
407 |
– |
// Initialize variables |
408 |
– |
RAMBase = 0; |
409 |
– |
tzset(); |
410 |
– |
|
411 |
– |
// Print some info |
412 |
– |
printf(GetString(STR_ABOUT_TEXT1), VERSION_MAJOR, VERSION_MINOR); |
413 |
– |
printf(" %s\n", GetString(STR_ABOUT_TEXT2)); |
414 |
– |
|
415 |
– |
#if !EMULATED_PPC |
416 |
– |
#ifdef SYSTEM_CLOBBERS_R2 |
417 |
– |
// Get TOC pointer |
418 |
– |
TOC = get_r2(); |
419 |
– |
#endif |
420 |
– |
#ifdef SYSTEM_CLOBBERS_R13 |
421 |
– |
// Get r13 register |
422 |
– |
R13 = get_r13(); |
423 |
– |
#endif |
424 |
– |
#endif |
425 |
– |
|
426 |
– |
// Parse command line arguments |
427 |
– |
for (int i=1; i<argc; i++) { |
428 |
– |
if (strcmp(argv[i], "--help") == 0) { |
429 |
– |
usage(argv[0]); |
430 |
– |
#ifndef USE_SDL_VIDEO |
431 |
– |
} else if (strcmp(argv[i], "--display") == 0) { |
432 |
– |
i++; |
433 |
– |
if (i < argc) |
434 |
– |
x_display_name = strdup(argv[i]); |
435 |
– |
#endif |
436 |
– |
} else if (strcmp(argv[i], "--gui-connection") == 0) { |
437 |
– |
argv[i++] = NULL; |
438 |
– |
if (i < argc) { |
439 |
– |
gui_connection_path = argv[i]; |
440 |
– |
argv[i] = NULL; |
441 |
– |
} |
442 |
– |
} else if (valid_vmdir(argv[i])) { |
443 |
– |
vmdir = argv[i]; |
444 |
– |
argv[i] = NULL; |
445 |
– |
printf("Using %s as vmdir.\n", vmdir); |
446 |
– |
if (chdir(vmdir)) { |
447 |
– |
printf("Failed to chdir to %s. Good bye.", vmdir); |
448 |
– |
exit(1); |
449 |
– |
} |
450 |
– |
break; |
451 |
– |
} |
452 |
– |
} |
453 |
– |
|
454 |
– |
// Remove processed arguments |
455 |
– |
for (int i=1; i<argc; i++) { |
456 |
– |
int k; |
457 |
– |
for (k=i; k<argc; k++) |
458 |
– |
if (argv[k] != NULL) |
459 |
– |
break; |
460 |
– |
if (k > i) { |
461 |
– |
k -= i; |
462 |
– |
for (int j=i+k; j<argc; j++) |
463 |
– |
argv[j-k] = argv[j]; |
464 |
– |
argc -= k; |
465 |
– |
} |
466 |
– |
} |
467 |
– |
|
468 |
– |
// Connect to the external GUI |
469 |
– |
if (gui_connection_path) { |
470 |
– |
if ((gui_connection = rpc_init_client(gui_connection_path)) == NULL) { |
471 |
– |
fprintf(stderr, "Failed to initialize RPC client connection to the GUI\n"); |
472 |
– |
return 1; |
473 |
– |
} |
474 |
– |
} |
475 |
– |
|
476 |
– |
#ifdef ENABLE_GTK |
477 |
– |
if (!gui_connection) { |
478 |
– |
// Init GTK |
479 |
– |
gtk_set_locale(); |
480 |
– |
gtk_init(&argc, &argv); |
481 |
– |
} |
482 |
– |
#endif |
483 |
– |
|
484 |
– |
// Read preferences |
485 |
– |
PrefsInit(vmdir, argc, argv); |
486 |
– |
|
487 |
– |
// Any command line arguments left? |
488 |
– |
for (int i=1; i<argc; i++) { |
489 |
– |
if (argv[i][0] == '-') { |
490 |
– |
fprintf(stderr, "Unrecognized option '%s'\n", argv[i]); |
491 |
– |
usage(argv[0]); |
492 |
– |
} |
493 |
– |
} |
494 |
– |
|
495 |
– |
#ifdef USE_SDL |
496 |
– |
// Initialize SDL system |
497 |
– |
int sdl_flags = 0; |
498 |
– |
#ifdef USE_SDL_VIDEO |
499 |
– |
sdl_flags |= SDL_INIT_VIDEO; |
500 |
– |
#endif |
501 |
– |
#ifdef USE_SDL_AUDIO |
502 |
– |
sdl_flags |= SDL_INIT_AUDIO; |
503 |
– |
#endif |
504 |
– |
assert(sdl_flags != 0); |
505 |
– |
if (SDL_Init(sdl_flags) == -1) { |
506 |
– |
char str[256]; |
507 |
– |
sprintf(str, "Could not initialize SDL: %s.\n", SDL_GetError()); |
508 |
– |
ErrorAlert(str); |
509 |
– |
goto quit; |
510 |
– |
} |
511 |
– |
atexit(SDL_Quit); |
512 |
– |
|
513 |
– |
// Don't let SDL catch SIGINT and SIGTERM signals |
514 |
– |
signal(SIGINT, SIG_DFL); |
515 |
– |
signal(SIGTERM, SIG_DFL); |
516 |
– |
#endif |
517 |
– |
|
518 |
– |
#ifndef USE_SDL_VIDEO |
519 |
– |
// Open display |
520 |
– |
x_display = XOpenDisplay(x_display_name); |
521 |
– |
if (x_display == NULL) { |
522 |
– |
char str[256]; |
523 |
– |
sprintf(str, GetString(STR_NO_XSERVER_ERR), XDisplayName(x_display_name)); |
524 |
– |
ErrorAlert(str); |
525 |
– |
goto quit; |
526 |
– |
} |
527 |
– |
|
528 |
– |
#if defined(ENABLE_XF86_DGA) && !defined(ENABLE_MON) |
529 |
– |
// Fork out, so we can return from fullscreen mode when things get ugly |
530 |
– |
XF86DGAForkApp(DefaultScreen(x_display)); |
531 |
– |
#endif |
532 |
– |
#endif |
533 |
– |
|
534 |
– |
#ifdef ENABLE_MON |
535 |
– |
// Initialize mon |
536 |
– |
mon_init(); |
537 |
– |
#endif |
538 |
– |
|
389 |
|
#if !EMULATED_PPC |
390 |
< |
// Create and install stacks for signal handlers |
541 |
< |
sig_stack.ss_sp = malloc(SIG_STACK_SIZE); |
542 |
< |
D(bug("Signal stack at %p\n", sig_stack.ss_sp)); |
543 |
< |
if (sig_stack.ss_sp == NULL) { |
544 |
< |
ErrorAlert(GetString(STR_NOT_ENOUGH_MEMORY_ERR)); |
545 |
< |
goto quit; |
546 |
< |
} |
547 |
< |
sig_stack.ss_flags = 0; |
548 |
< |
sig_stack.ss_size = SIG_STACK_SIZE; |
549 |
< |
if (sigaltstack(&sig_stack, NULL) < 0) { |
550 |
< |
sprintf(str, GetString(STR_SIGALTSTACK_ERR), strerror(errno)); |
551 |
< |
ErrorAlert(str); |
552 |
< |
goto quit; |
553 |
< |
} |
554 |
< |
extra_stack.ss_sp = malloc(SIG_STACK_SIZE); |
555 |
< |
D(bug("Extra stack at %p\n", extra_stack.ss_sp)); |
556 |
< |
if (extra_stack.ss_sp == NULL) { |
557 |
< |
ErrorAlert(GetString(STR_NOT_ENOUGH_MEMORY_ERR)); |
558 |
< |
goto quit; |
559 |
< |
} |
560 |
< |
extra_stack.ss_flags = 0; |
561 |
< |
extra_stack.ss_size = SIG_STACK_SIZE; |
562 |
< |
#endif |
563 |
< |
|
564 |
< |
#if !EMULATED_PPC |
565 |
< |
// Install SIGSEGV and SIGBUS handlers |
566 |
< |
sigemptyset(&sigsegv_action.sa_mask); // Block interrupts during SEGV handling |
567 |
< |
sigaddset(&sigsegv_action.sa_mask, SIGUSR2); |
568 |
< |
sigsegv_action.sa_sigaction = sigsegv_handler; |
569 |
< |
sigsegv_action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
570 |
< |
#ifdef HAVE_SIGNAL_SA_RESTORER |
571 |
< |
sigsegv_action.sa_restorer = NULL; |
572 |
< |
#endif |
573 |
< |
if (sigaction(SIGSEGV, &sigsegv_action, NULL) < 0) { |
574 |
< |
sprintf(str, GetString(STR_SIG_INSTALL_ERR), "SIGSEGV", strerror(errno)); |
575 |
< |
ErrorAlert(str); |
576 |
< |
goto quit; |
577 |
< |
} |
578 |
< |
if (sigaction(SIGBUS, &sigsegv_action, NULL) < 0) { |
579 |
< |
sprintf(str, GetString(STR_SIG_INSTALL_ERR), "SIGBUS", strerror(errno)); |
580 |
< |
ErrorAlert(str); |
581 |
< |
goto quit; |
582 |
< |
} |
583 |
< |
#else |
584 |
< |
// Install SIGSEGV handler for CPU emulator |
585 |
< |
if (!sigsegv_install_handler(sigsegv_handler)) { |
586 |
< |
sprintf(str, GetString(STR_SIG_INSTALL_ERR), "SIGSEGV", strerror(errno)); |
587 |
< |
ErrorAlert(str); |
588 |
< |
goto quit; |
589 |
< |
} |
390 |
> |
FILE *proc_file; |
391 |
|
#endif |
392 |
|
|
592 |
– |
// Initialize VM system |
593 |
– |
vm_init(); |
594 |
– |
|
595 |
– |
// Get system info |
393 |
|
PVR = 0x00040000; // Default: 604 |
394 |
|
CPUClockSpeed = 100000000; // Default: 100MHz |
395 |
|
BusClockSpeed = 100000000; // Default: 100MHz |
396 |
|
TimebaseSpeed = 25000000; // Default: 25MHz |
397 |
+ |
|
398 |
|
#if EMULATED_PPC |
399 |
|
PVR = 0x000c0000; // Default: 7400 (with AltiVec) |
400 |
|
#elif defined(__APPLE__) && defined(__MACH__) |
429 |
|
} |
430 |
|
fclose(proc_file); |
431 |
|
} else { |
432 |
+ |
char str[256]; |
433 |
|
sprintf(str, GetString(STR_PROC_CPUINFO_WARN), strerror(errno)); |
434 |
|
WarningAlert(str); |
435 |
|
} |
484 |
|
{ 0xffff0000, 0x00350000, "Power4" }, |
485 |
|
{ 0xffff0000, 0x00390000, "PPC970" }, |
486 |
|
{ 0xffff0000, 0x003c0000, "PPC970FX" }, |
487 |
+ |
{ 0xffff0000, 0x00440000, "PPC970MP" }, |
488 |
|
{ 0xffff0000, 0x003a0000, "POWER5 (gr)" }, |
489 |
|
{ 0xffff0000, 0x003b0000, "POWER5+ (gs)" }, |
490 |
|
{ 0xffff0000, 0x003e0000, "POWER6" }, |
561 |
|
closedir(cpus_dir); |
562 |
|
} |
563 |
|
#endif |
564 |
+ |
|
565 |
|
// Remap any newer G4/G5 processor to plain G4 for compatibility |
566 |
|
switch (PVR >> 16) { |
567 |
|
case 0x8000: // 7450 |
571 |
|
case 0x8004: // 7448 |
572 |
|
case 0x0039: // 970 |
573 |
|
case 0x003c: // 970FX |
574 |
+ |
case 0x0044: // 970MP |
575 |
|
PVR = 0x000c0000; // 7400 |
576 |
|
break; |
577 |
|
} |
578 |
|
D(bug("PVR: %08x (assumed)\n", PVR)); |
579 |
+ |
} |
580 |
+ |
|
581 |
+ |
static bool load_mac_rom(void) |
582 |
+ |
{ |
583 |
+ |
uint32 rom_size, actual; |
584 |
+ |
uint8 *rom_tmp; |
585 |
+ |
const char *rom_path = PrefsFindString("rom"); |
586 |
+ |
int rom_fd = open(rom_path && *rom_path ? rom_path : ROM_FILE_NAME, O_RDONLY); |
587 |
+ |
if (rom_fd < 0) { |
588 |
+ |
rom_fd = open(ROM_FILE_NAME2, O_RDONLY); |
589 |
+ |
if (rom_fd < 0) { |
590 |
+ |
ErrorAlert(GetString(STR_NO_ROM_FILE_ERR)); |
591 |
+ |
return false; |
592 |
+ |
} |
593 |
+ |
} |
594 |
+ |
printf("%s", GetString(STR_READING_ROM_FILE)); |
595 |
+ |
rom_size = lseek(rom_fd, 0, SEEK_END); |
596 |
+ |
lseek(rom_fd, 0, SEEK_SET); |
597 |
+ |
rom_tmp = new uint8[ROM_SIZE]; |
598 |
+ |
actual = read(rom_fd, (void *)rom_tmp, ROM_SIZE); |
599 |
+ |
close(rom_fd); |
600 |
+ |
|
601 |
+ |
// Decode Mac ROM |
602 |
+ |
if (!DecodeROM(rom_tmp, actual)) { |
603 |
+ |
if (rom_size != 4*1024*1024) { |
604 |
+ |
ErrorAlert(GetString(STR_ROM_SIZE_ERR)); |
605 |
+ |
return false; |
606 |
+ |
} else { |
607 |
+ |
ErrorAlert(GetString(STR_ROM_FILE_READ_ERR)); |
608 |
+ |
return false; |
609 |
+ |
} |
610 |
+ |
} |
611 |
+ |
delete[] rom_tmp; |
612 |
+ |
return true; |
613 |
+ |
} |
614 |
+ |
|
615 |
+ |
static bool install_signal_handlers(void) |
616 |
+ |
{ |
617 |
+ |
char str[256]; |
618 |
+ |
#if !EMULATED_PPC |
619 |
+ |
// Create and install stacks for signal handlers |
620 |
+ |
sig_stack.ss_sp = malloc(SIG_STACK_SIZE); |
621 |
+ |
D(bug("Signal stack at %p\n", sig_stack.ss_sp)); |
622 |
+ |
if (sig_stack.ss_sp == NULL) { |
623 |
+ |
ErrorAlert(GetString(STR_NOT_ENOUGH_MEMORY_ERR)); |
624 |
+ |
return false; |
625 |
+ |
} |
626 |
+ |
sig_stack.ss_flags = 0; |
627 |
+ |
sig_stack.ss_size = SIG_STACK_SIZE; |
628 |
+ |
if (sigaltstack(&sig_stack, NULL) < 0) { |
629 |
+ |
sprintf(str, GetString(STR_SIGALTSTACK_ERR), strerror(errno)); |
630 |
+ |
ErrorAlert(str); |
631 |
+ |
return false; |
632 |
+ |
} |
633 |
+ |
extra_stack.ss_sp = malloc(SIG_STACK_SIZE); |
634 |
+ |
D(bug("Extra stack at %p\n", extra_stack.ss_sp)); |
635 |
+ |
if (extra_stack.ss_sp == NULL) { |
636 |
+ |
ErrorAlert(GetString(STR_NOT_ENOUGH_MEMORY_ERR)); |
637 |
+ |
return false; |
638 |
+ |
} |
639 |
+ |
extra_stack.ss_flags = 0; |
640 |
+ |
extra_stack.ss_size = SIG_STACK_SIZE; |
641 |
+ |
|
642 |
+ |
// Install SIGSEGV and SIGBUS handlers |
643 |
+ |
sigemptyset(&sigsegv_action.sa_mask); // Block interrupts during SEGV handling |
644 |
+ |
sigaddset(&sigsegv_action.sa_mask, SIGUSR2); |
645 |
+ |
sigsegv_action.sa_sigaction = sigsegv_handler; |
646 |
+ |
sigsegv_action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
647 |
+ |
#ifdef HAVE_SIGNAL_SA_RESTORER |
648 |
+ |
sigsegv_action.sa_restorer = NULL; |
649 |
+ |
#endif |
650 |
+ |
if (sigaction(SIGSEGV, &sigsegv_action, NULL) < 0) { |
651 |
+ |
sprintf(str, GetString(STR_SIG_INSTALL_ERR), "SIGSEGV", strerror(errno)); |
652 |
+ |
ErrorAlert(str); |
653 |
+ |
return false; |
654 |
+ |
} |
655 |
+ |
if (sigaction(SIGBUS, &sigsegv_action, NULL) < 0) { |
656 |
+ |
sprintf(str, GetString(STR_SIG_INSTALL_ERR), "SIGBUS", strerror(errno)); |
657 |
+ |
ErrorAlert(str); |
658 |
+ |
return false; |
659 |
+ |
} |
660 |
+ |
#else |
661 |
+ |
// Install SIGSEGV handler for CPU emulator |
662 |
+ |
if (!sigsegv_install_handler(sigsegv_handler)) { |
663 |
+ |
sprintf(str, GetString(STR_SIG_INSTALL_ERR), "SIGSEGV", strerror(errno)); |
664 |
+ |
ErrorAlert(str); |
665 |
+ |
return false; |
666 |
+ |
} |
667 |
+ |
#endif |
668 |
+ |
return true; |
669 |
+ |
} |
670 |
+ |
|
671 |
+ |
static bool init_sdl() |
672 |
+ |
{ |
673 |
+ |
int sdl_flags = 0; |
674 |
+ |
#ifdef USE_SDL_VIDEO |
675 |
+ |
sdl_flags |= SDL_INIT_VIDEO; |
676 |
+ |
#endif |
677 |
+ |
#ifdef USE_SDL_AUDIO |
678 |
+ |
sdl_flags |= SDL_INIT_AUDIO; |
679 |
+ |
#endif |
680 |
+ |
assert(sdl_flags != 0); |
681 |
+ |
|
682 |
+ |
#ifdef USE_SDL_VIDEO |
683 |
+ |
// Don't let SDL block the screensaver |
684 |
+ |
setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", TRUE); |
685 |
+ |
|
686 |
+ |
// Make SDL pass through command-clicks and option-clicks unaltered |
687 |
+ |
setenv("SDL_HAS3BUTTONMOUSE", "1", TRUE); |
688 |
+ |
#endif |
689 |
+ |
|
690 |
+ |
if (SDL_Init(sdl_flags) == -1) { |
691 |
+ |
char str[256]; |
692 |
+ |
sprintf(str, "Could not initialize SDL: %s.\n", SDL_GetError()); |
693 |
+ |
ErrorAlert(str); |
694 |
+ |
return false; |
695 |
+ |
} |
696 |
+ |
atexit(SDL_Quit); |
697 |
+ |
|
698 |
+ |
// Don't let SDL catch SIGINT and SIGTERM signals |
699 |
+ |
signal(SIGINT, SIG_DFL); |
700 |
+ |
signal(SIGTERM, SIG_DFL); |
701 |
+ |
return true; |
702 |
+ |
} |
703 |
+ |
|
704 |
+ |
int main(int argc, char **argv) |
705 |
+ |
{ |
706 |
+ |
char str[256]; |
707 |
+ |
bool memory_mapped_from_zero, ram_rom_areas_contiguous; |
708 |
+ |
const char *vmdir = NULL; |
709 |
+ |
|
710 |
+ |
// Initialize variables |
711 |
+ |
RAMBase = 0; |
712 |
+ |
tzset(); |
713 |
+ |
|
714 |
+ |
// Print some info |
715 |
+ |
printf(GetString(STR_ABOUT_TEXT1), VERSION_MAJOR, VERSION_MINOR); |
716 |
+ |
printf(" %s\n", GetString(STR_ABOUT_TEXT2)); |
717 |
+ |
|
718 |
+ |
#if !EMULATED_PPC |
719 |
+ |
#ifdef SYSTEM_CLOBBERS_R2 |
720 |
+ |
// Get TOC pointer |
721 |
+ |
TOC = get_r2(); |
722 |
+ |
#endif |
723 |
+ |
#ifdef SYSTEM_CLOBBERS_R13 |
724 |
+ |
// Get r13 register |
725 |
+ |
R13 = get_r13(); |
726 |
+ |
#endif |
727 |
+ |
#endif |
728 |
+ |
|
729 |
+ |
// Parse command line arguments |
730 |
+ |
for (int i=1; i<argc; i++) { |
731 |
+ |
if (strcmp(argv[i], "--help") == 0) { |
732 |
+ |
usage(argv[0]); |
733 |
+ |
#ifndef USE_SDL_VIDEO |
734 |
+ |
} else if (strcmp(argv[i], "--display") == 0) { |
735 |
+ |
i++; |
736 |
+ |
if (i < argc) |
737 |
+ |
x_display_name = strdup(argv[i]); |
738 |
+ |
#endif |
739 |
+ |
} else if (strcmp(argv[i], "--gui-connection") == 0) { |
740 |
+ |
argv[i++] = NULL; |
741 |
+ |
if (i < argc) { |
742 |
+ |
gui_connection_path = argv[i]; |
743 |
+ |
argv[i] = NULL; |
744 |
+ |
} |
745 |
+ |
} else if (valid_vmdir(argv[i])) { |
746 |
+ |
vmdir = argv[i]; |
747 |
+ |
argv[i] = NULL; |
748 |
+ |
printf("Using %s as vmdir.\n", vmdir); |
749 |
+ |
if (chdir(vmdir)) { |
750 |
+ |
printf("Failed to chdir to %s. Good bye.", vmdir); |
751 |
+ |
exit(1); |
752 |
+ |
} |
753 |
+ |
break; |
754 |
+ |
} |
755 |
+ |
} |
756 |
+ |
|
757 |
+ |
// Remove processed arguments |
758 |
+ |
for (int i=1; i<argc; i++) { |
759 |
+ |
int k; |
760 |
+ |
for (k=i; k<argc; k++) |
761 |
+ |
if (argv[k] != NULL) |
762 |
+ |
break; |
763 |
+ |
if (k > i) { |
764 |
+ |
k -= i; |
765 |
+ |
for (int j=i+k; j<argc; j++) |
766 |
+ |
argv[j-k] = argv[j]; |
767 |
+ |
argc -= k; |
768 |
+ |
} |
769 |
+ |
} |
770 |
+ |
|
771 |
+ |
// Connect to the external GUI |
772 |
+ |
if (gui_connection_path) { |
773 |
+ |
if ((gui_connection = rpc_init_client(gui_connection_path)) == NULL) { |
774 |
+ |
fprintf(stderr, "Failed to initialize RPC client connection to the GUI\n"); |
775 |
+ |
return 1; |
776 |
+ |
} |
777 |
+ |
} |
778 |
+ |
|
779 |
+ |
#ifdef ENABLE_GTK |
780 |
+ |
if (!gui_connection) { |
781 |
+ |
// Init GTK |
782 |
+ |
gtk_set_locale(); |
783 |
+ |
gtk_init(&argc, &argv); |
784 |
+ |
} |
785 |
+ |
#endif |
786 |
+ |
|
787 |
+ |
// Read preferences |
788 |
+ |
PrefsInit(vmdir, argc, argv); |
789 |
+ |
|
790 |
+ |
// Any command line arguments left? |
791 |
+ |
for (int i=1; i<argc; i++) { |
792 |
+ |
if (argv[i][0] == '-') { |
793 |
+ |
fprintf(stderr, "Unrecognized option '%s'\n", argv[i]); |
794 |
+ |
usage(argv[0]); |
795 |
+ |
} |
796 |
+ |
} |
797 |
+ |
|
798 |
+ |
#ifdef USE_SDL |
799 |
+ |
// Initialize SDL system |
800 |
+ |
if (!init_sdl()) |
801 |
+ |
goto quit; |
802 |
+ |
#endif |
803 |
+ |
|
804 |
+ |
#ifndef USE_SDL_VIDEO |
805 |
+ |
// Open display |
806 |
+ |
x_display = XOpenDisplay(x_display_name); |
807 |
+ |
if (x_display == NULL) { |
808 |
+ |
char str[256]; |
809 |
+ |
sprintf(str, GetString(STR_NO_XSERVER_ERR), XDisplayName(x_display_name)); |
810 |
+ |
ErrorAlert(str); |
811 |
+ |
goto quit; |
812 |
+ |
} |
813 |
+ |
|
814 |
+ |
#if defined(ENABLE_XF86_DGA) && !defined(ENABLE_MON) |
815 |
+ |
// Fork out, so we can return from fullscreen mode when things get ugly |
816 |
+ |
XF86DGAForkApp(DefaultScreen(x_display)); |
817 |
+ |
#endif |
818 |
+ |
#endif |
819 |
+ |
|
820 |
+ |
#ifdef ENABLE_MON |
821 |
+ |
// Initialize mon |
822 |
+ |
mon_init(); |
823 |
+ |
#endif |
824 |
+ |
|
825 |
+ |
// Install signal handlers |
826 |
+ |
if (!install_signal_handlers()) |
827 |
+ |
goto quit; |
828 |
+ |
|
829 |
+ |
// Initialize VM system |
830 |
+ |
vm_init(); |
831 |
+ |
|
832 |
+ |
// Get system info |
833 |
+ |
get_system_info(); |
834 |
|
|
835 |
|
// Init system routines |
836 |
|
SysInit(); |
982 |
|
} |
983 |
|
|
984 |
|
// Load Mac ROM |
985 |
< |
rom_path = PrefsFindString("rom"); |
986 |
< |
rom_fd = open(rom_path && *rom_path ? rom_path : ROM_FILE_NAME, O_RDONLY); |
930 |
< |
if (rom_fd < 0) { |
931 |
< |
rom_fd = open(ROM_FILE_NAME2, O_RDONLY); |
932 |
< |
if (rom_fd < 0) { |
933 |
< |
ErrorAlert(GetString(STR_NO_ROM_FILE_ERR)); |
934 |
< |
goto quit; |
935 |
< |
} |
936 |
< |
} |
937 |
< |
printf(GetString(STR_READING_ROM_FILE)); |
938 |
< |
rom_size = lseek(rom_fd, 0, SEEK_END); |
939 |
< |
lseek(rom_fd, 0, SEEK_SET); |
940 |
< |
rom_tmp = new uint8[ROM_SIZE]; |
941 |
< |
actual = read(rom_fd, (void *)rom_tmp, ROM_SIZE); |
942 |
< |
close(rom_fd); |
943 |
< |
|
944 |
< |
// Decode Mac ROM |
945 |
< |
if (!DecodeROM(rom_tmp, actual)) { |
946 |
< |
if (rom_size != 4*1024*1024) { |
947 |
< |
ErrorAlert(GetString(STR_ROM_SIZE_ERR)); |
948 |
< |
goto quit; |
949 |
< |
} else { |
950 |
< |
ErrorAlert(GetString(STR_ROM_FILE_READ_ERR)); |
951 |
< |
goto quit; |
952 |
< |
} |
953 |
< |
} |
954 |
< |
delete[] rom_tmp; |
985 |
> |
if (!load_mac_rom()) |
986 |
> |
goto quit; |
987 |
|
|
988 |
|
// Initialize everything |
989 |
|
if (!InitAll(vmdir)) |