/* Autostart PRG file `file_name'. The PRG file can either be a raw CBM file or a P00 file */ int autostart_prg(const char *file_name, unsigned int runmode) { fileio_info_t *finfo; int result; const char *boot_file_name; int mode; if (event_record_active() || event_playback_active()) return -1; /* open prg file */ finfo = fileio_open(file_name, NULL, FILEIO_FORMAT_RAW | FILEIO_FORMAT_P00, FILEIO_COMMAND_READ | FILEIO_COMMAND_FSNAME, FILEIO_TYPE_PRG); /* can't open file */ if (finfo == NULL) { #ifdef CELL_DEBUG printf("ERROR: Cannot open `%s'.\n", file_name); #endif return -1; } /* determine how to load file */ switch(AutostartPrgMode) { case AUTOSTART_PRG_MODE_VFS: //log_message(autostart_log, "Loading PRG file `%s' with virtual FS on unit #8.", file_name); result = autostart_prg_with_virtual_fs(file_name, finfo); mode = AUTOSTART_HASDISK; boot_file_name = (const char *)finfo->name; break; case AUTOSTART_PRG_MODE_INJECT: //log_message(autostart_log, "Loading PRG file `%s' with direct RAM injection.", file_name); result = autostart_prg_with_ram_injection(file_name, finfo); mode = AUTOSTART_INJECT; boot_file_name = NULL; break; case AUTOSTART_PRG_MODE_DISK: //log_message(autostart_log, "Loading PRG file `%s' with autostart disk image.", file_name); result = autostart_prg_with_disk_image(file_name, finfo, AutostartPrgDiskImage); mode = AUTOSTART_HASDISK; boot_file_name = "*"; break; default: //log_error(autostart_log, "Invalid PRG autostart mode: %d", AutostartPrgMode); result = -1; break; } /* Now either proceed with disk image booting or prg injection after reset */ if (result >= 0) { ui_update_menus(); reboot_for_autostart(boot_file_name, mode, runmode); } /* close prg file */ fileio_close(finfo); return result; }
/* Autostart PRG file `file_name'. The PRG file can either be a raw CBM file or a P00 file */ int autostart_prg(const char *file_name, unsigned int runmode) { fileio_info_t *finfo; int result; const char *boot_file_name; int mode; if (network_connected() || event_record_active() || event_playback_active()) { return -1; } /* open prg file */ finfo = fileio_open(file_name, NULL, FILEIO_FORMAT_RAW | FILEIO_FORMAT_P00, FILEIO_COMMAND_READ | FILEIO_COMMAND_FSNAME, FILEIO_TYPE_PRG); /* can't open file */ if (finfo == NULL) { log_error(autostart_log, "Cannot open `%s'.", file_name); return -1; } /* determine how to load file */ switch (AutostartPrgMode) { case AUTOSTART_PRG_MODE_VFS: log_message(autostart_log, "Loading PRG file `%s' with virtual FS on unit #8.", file_name); result = autostart_prg_with_virtual_fs(file_name, finfo, autostart_log); mode = AUTOSTART_HASDISK; boot_file_name = (const char *)finfo->name; break; case AUTOSTART_PRG_MODE_INJECT: log_message(autostart_log, "Loading PRG file `%s' with direct RAM injection.", file_name); result = autostart_prg_with_ram_injection(file_name, finfo, autostart_log); mode = AUTOSTART_INJECT; boot_file_name = NULL; break; case AUTOSTART_PRG_MODE_DISK: { char *savedir; log_message(autostart_log, "Loading PRG file `%s' with autostart disk image.", file_name); /* create the directory where the image should be written first */ util_fname_split(AutostartPrgDiskImage, &savedir, NULL); ioutil_mkdir(savedir, IOUTIL_MKDIR_RWXU); lib_free(savedir); result = autostart_prg_with_disk_image(file_name, finfo, autostart_log, AutostartPrgDiskImage); mode = AUTOSTART_HASDISK; boot_file_name = "*"; } break; default: log_error(autostart_log, "Invalid PRG autostart mode: %d", AutostartPrgMode); result = -1; break; } /* Now either proceed with disk image booting or prg injection after reset */ if (result >= 0) { ui_update_menus(); reboot_for_autostart(boot_file_name, mode, runmode); } /* close prg file */ fileio_close(finfo); return result; }