ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/main_unix.cpp
(Generate patch)

Comparing SheepShaver/src/Unix/main_unix.cpp (file contents):
Revision 1.94 by asvitkine, 2011-12-28T23:17:29Z vs.
Revision 1.95 by asvitkine, 2011-12-28T23:24:30Z

# Line 577 | Line 577 | static void get_system_info(void)
577          D(bug("PVR: %08x (assumed)\n", PVR));
578   }
579  
580 < int main(int argc, char **argv)
580 > static bool load_mac_rom(void)
581   {
582        char str[256];
583        int rom_fd;
584        const char *rom_path;
582          uint32 rom_size, actual;
583          uint8 *rom_tmp;
584 +        const char *rom_path = PrefsFindString("rom");
585 +        int rom_fd = open(rom_path && *rom_path ? rom_path : ROM_FILE_NAME, O_RDONLY);
586 +        if (rom_fd < 0) {
587 +                rom_fd = open(ROM_FILE_NAME2, O_RDONLY);
588 +                if (rom_fd < 0) {
589 +                        ErrorAlert(GetString(STR_NO_ROM_FILE_ERR));
590 +                        return false;
591 +                }
592 +        }
593 +        printf("%s", GetString(STR_READING_ROM_FILE));
594 +        rom_size = lseek(rom_fd, 0, SEEK_END);
595 +        lseek(rom_fd, 0, SEEK_SET);
596 +        rom_tmp = new uint8[ROM_SIZE];
597 +        actual = read(rom_fd, (void *)rom_tmp, ROM_SIZE);
598 +        close(rom_fd);
599 +        
600 +        // Decode Mac ROM
601 +        if (!DecodeROM(rom_tmp, actual)) {
602 +                if (rom_size != 4*1024*1024) {
603 +                        ErrorAlert(GetString(STR_ROM_SIZE_ERR));
604 +                        return false;
605 +                } else {
606 +                        ErrorAlert(GetString(STR_ROM_FILE_READ_ERR));
607 +                        return false;
608 +                }
609 +        }
610 +        delete[] rom_tmp;
611 +        return true;
612 + }
613 +
614 + int main(int argc, char **argv)
615 + {
616 +        char str[256];
617          bool memory_mapped_from_zero, ram_rom_areas_contiguous;
618          const char *vmdir = NULL;
619  
# Line 936 | Line 966 | int main(int argc, char **argv)
966          }
967  
968          // Load Mac ROM
969 <        rom_path = PrefsFindString("rom");
970 <        rom_fd = open(rom_path && *rom_path ? rom_path : ROM_FILE_NAME, O_RDONLY);
941 <        if (rom_fd < 0) {
942 <                rom_fd = open(ROM_FILE_NAME2, O_RDONLY);
943 <                if (rom_fd < 0) {
944 <                        ErrorAlert(GetString(STR_NO_ROM_FILE_ERR));
945 <                        goto quit;
946 <                }
947 <        }
948 <        printf("%s", GetString(STR_READING_ROM_FILE));
949 <        rom_size = lseek(rom_fd, 0, SEEK_END);
950 <        lseek(rom_fd, 0, SEEK_SET);
951 <        rom_tmp = new uint8[ROM_SIZE];
952 <        actual = read(rom_fd, (void *)rom_tmp, ROM_SIZE);
953 <        close(rom_fd);
954 <        
955 <        // Decode Mac ROM
956 <        if (!DecodeROM(rom_tmp, actual)) {
957 <                if (rom_size != 4*1024*1024) {
958 <                        ErrorAlert(GetString(STR_ROM_SIZE_ERR));
959 <                        goto quit;
960 <                } else {
961 <                        ErrorAlert(GetString(STR_ROM_FILE_READ_ERR));
962 <                        goto quit;
963 <                }
964 <        }
965 <        delete[] rom_tmp;
969 >        if (!load_mac_rom())
970 >                goto quit;
971  
972          // Initialize everything
973          if (!InitAll(vmdir))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines