/* Autostart disk image `file_name'. */ int autostart_disk(const char *file_name, const char *program_name, unsigned int program_number, unsigned int runmode) { char *name = NULL; if (network_connected() || !file_name || !autostart_enabled) return -1; /* Get program name first to avoid more than one file handle open on image. */ if (!program_name && program_number > 0) name = image_contents_filename_by_number(IMAGE_CONTENTS_DISK, file_name, 0, program_number); else name = lib_stralloc(program_name ? program_name : "*"); if (name) { autostart_disk_cook_name(&name); if (!(file_system_attach_disk(8, file_name) < 0)) { log_message(autostart_log, "Attached file `%s' as a disk image.", file_name); reboot_for_autostart(name, AUTOSTART_HASDISK, runmode); lib_free(name); return 0; } } autostartmode = AUTOSTART_ERROR; deallocate_program_name(); if (name) lib_free(name); return -1; }
/* Autostart snapshot file `file_name'. */ int autostart_snapshot(const char *file_name, const char *program_name) { BYTE vmajor, vminor; snapshot_t *snap; if (network_connected() || file_name == NULL || !autostart_enabled) return -1; deallocate_program_name(); /* not needed at all */ if (!(snap = snapshot_open(file_name, &vmajor, &vminor, machine_name)) ) { autostartmode = AUTOSTART_ERROR; return -1; } log_message(autostart_log, "Loading snapshot file `%s'.", file_name); snapshot_close(snap); /*autostart_program_name = (BYTE *)lib_stralloc(file_name); interrupt_maincpu_trigger_trap(load_snapshot_trap, (void*)0);*/ /* use for snapshot */ reboot_for_autostart(file_name, AUTOSTART_HASSNAPSHOT, AUTOSTART_MODE_RUN); return 0; }
/* Clean memory and reboot for autostart. */ static void reboot_for_autostart(const char *program_name, unsigned int mode, unsigned int runmode) { if (!autostart_enabled) return; //log_message(autostart_log, "Resetting the machine to autostart '%s'", program_name ? program_name : "*"); mem_powerup(); autostart_ignore_reset = 1; deallocate_program_name(); if (program_name && program_name[0]) { autostart_program_name = lib_stralloc(program_name); } machine_trigger_reset(MACHINE_RESET_MODE_SOFT); /* The autostartmode must be set AFTER the shutdown to make the autostart threadsafe for OS/2 */ autostartmode = mode; autostart_run_mode = runmode; autostart_wait_for_reset = 1; /* enable warp before reset */ if (mode != AUTOSTART_HASSNAPSHOT) { enable_warp_if_requested(); } }
static void advance_hastape(void) { char *tmp; switch (check("READY.", AUTOSTART_WAIT_BLINK)) { case YES: log_message(autostart_log, "Loading file."); if (autostart_program_name) { tmp = util_concat("LOAD\"", autostart_program_name, "\":\r", NULL); kbdbuf_feed(tmp); lib_free(tmp); } else { kbdbuf_feed("LOAD:\r"); } if (tape_tap_attched()) { autostartmode = AUTOSTART_PRESSPLAYONTAPE; } else { autostartmode = AUTOSTART_LOADINGTAPE; } deallocate_program_name(); break; case NO: autostart_disable(); break; case NOT_YET: break; } }
void autostart_disable(void) { if (!autostart_enabled) return; autostartmode = AUTOSTART_ERROR; deallocate_program_name(); log_error(autostart_log, "Turned off."); }
static void advance_hasdisk(void) { char *tmp; int traps; switch (check("READY.", AUTOSTART_WAIT_BLINK)) { case YES: if (autostart_program_name) log_message(autostart_log, "Loading program '%s'", autostart_program_name); else log_message(autostart_log, "Loading program '*'"); orig_drive_true_emulation_state = get_true_drive_emulation_state(); if (handle_drive_true_emulation) { resources_get_int("VirtualDevices", &traps); if (traps) { if (orig_drive_true_emulation_state) log_message(autostart_log, "Turning true drive emulation off."); set_true_drive_emulation_mode(0); } else { if (!orig_drive_true_emulation_state) log_message(autostart_log, "Turning true drive emulation on."); set_true_drive_emulation_mode(1); } } else { traps = 1; } if (autostart_program_name) tmp = lib_msprintf("LOAD\"%s\",8,1:\r", autostart_program_name); else tmp = lib_stralloc("LOAD\"*\",8,1:\r"); kbdbuf_feed(tmp); lib_free(tmp); if (!traps) { if (autostart_run_mode == AUTOSTART_MODE_RUN) kbdbuf_feed(AutostartRunCommand); autostartmode = AUTOSTART_DONE; } else { autostartmode = AUTOSTART_LOADINGDISK; machine_bus_attention_callback_set(disk_attention_callback); } deallocate_program_name(); break; case NO: orig_drive_true_emulation_state = get_true_drive_emulation_state(); autostart_disable(); break; case NOT_YET: break; } }
/* Autostart tape image `file_name'. */ int autostart_tape(const char *file_name, const char *program_name, unsigned int program_number, unsigned int runmode) { char *name = NULL; if (network_connected() || !file_name || !autostart_enabled) return -1; /* Get program name first to avoid more than one file handle open on image. */ if (!program_name && program_number > 0) name = image_contents_filename_by_number(IMAGE_CONTENTS_TAPE, file_name, 0, program_number); else name = lib_stralloc(program_name ? program_name : ""); if (!(tape_image_attach(1, file_name) < 0)) { log_message(autostart_log, "Attached file `%s' as a tape image.", file_name); if (tape_tap_attched()) { if (program_number > 0) { lib_free(name); name = NULL; /* program numbers in tape_seek_to_file() start at 0 */ tape_seek_to_file(tape_image_dev1, program_number-1); } else { tape_seek_start(tape_image_dev1); } } resources_set_int("VirtualDevices", 1); /* Kludge: iAN CooG - for t64 images we need devtraps ON */ reboot_for_autostart(name, AUTOSTART_HASTAPE, runmode); lib_free(name); return 0; } autostartmode = AUTOSTART_ERROR; deallocate_program_name(); if (name) lib_free(name); return -1; }
/* Disable autostart on reset. */ void autostart_reset(void) { int oldmode; if (!autostart_enabled) return; if (!autostart_ignore_reset && autostartmode != AUTOSTART_NONE && autostartmode != AUTOSTART_ERROR) { oldmode = autostartmode; autostartmode = AUTOSTART_NONE; if (oldmode != AUTOSTART_DONE) disk_eof_callback(); autostartmode = AUTOSTART_NONE; deallocate_program_name(); log_message(autostart_log, "Turned off."); } autostart_ignore_reset = 0; }
/* Clean memory and reboot for autostart. */ static void reboot_for_autostart(const char *program_name, unsigned int mode, unsigned int runmode) { if (!autostart_enabled) return; log_message(autostart_log, "Resetting the machine to autostart '%s'", program_name ? program_name : "*"); mem_powerup(); autostart_ignore_reset = 1; deallocate_program_name(); if (program_name && program_name[0]) autostart_program_name = (BYTE *)lib_stralloc(program_name); machine_trigger_reset(MACHINE_RESET_MODE_SOFT); /* The autostartmode must be set AFTER the shutdown to make the autostart threadsafe for OS/2 */ autostartmode = mode; autostart_run_mode = runmode; autostart_wait_for_reset = 1; }
/* Clean memory and reboot for autostart. */ static void reboot_for_autostart(const char *program_name, unsigned int mode, unsigned int runmode) { int rnd; if (!autostart_enabled) { return; } log_message(autostart_log, "Resetting the machine to autostart '%s'", program_name ? program_name : "*"); mem_powerup(); autostart_ignore_reset = 1; deallocate_program_name(); if (program_name && program_name[0]) { autostart_program_name = lib_stralloc(program_name); } autostart_initial_delay_cycles = min_cycles; resources_get_int("AutostartDelayRandom", &rnd); if (rnd) { autostart_initial_delay_cycles += AUTOSTART_RAND(); } DBG(("autostart_initial_delay_cycles: %d", autostart_initial_delay_cycles)); machine_trigger_reset(MACHINE_RESET_MODE_SOFT); /* The autostartmode must be set AFTER the shutdown to make the autostart threadsafe for OS/2 */ autostartmode = mode; autostart_run_mode = runmode; autostart_wait_for_reset = 1; /* enable warp before reset */ if (mode != AUTOSTART_HASSNAPSHOT) { enable_warp_if_requested(); } }
/* Autostart disk image `file_name'. */ int autostart_disk(const char *file_name, const char *program_name, unsigned int program_number, unsigned int runmode) { char *name = NULL; if (network_connected() || event_record_active() || event_playback_active() || !file_name || !autostart_enabled) { return -1; } /* Get program name first to avoid more than one file handle open on image. */ if (!program_name && program_number > 0) { image_contents_t *contents = diskcontents_filesystem_read(file_name); if (contents) { name = image_contents_filename_by_number(contents, program_number); image_contents_destroy(contents); } } else { name = lib_stralloc(program_name ? program_name : "*"); } if (name) { autostart_disk_cook_name(&name); if (!(file_system_attach_disk(8, file_name) < 0)) { log_message(autostart_log, "Attached file `%s' as a disk image.", file_name); reboot_for_autostart(name, AUTOSTART_HASDISK, runmode); lib_free(name); return 0; } } autostartmode = AUTOSTART_ERROR; deallocate_program_name(); lib_free(name); return -1; }
/* Autostart tape image `file_name'. */ int autostart_tape(const char *file_name, const char *program_name, unsigned int program_number, unsigned int runmode) { BYTE do_seek = 1; if (network_connected() || event_record_active() || event_playback_active() || !file_name || !autostart_enabled) { return -1; } if (!(tape_image_attach(1, file_name) < 0)) { log_message(autostart_log, "Attached file `%s' as a tape image.", file_name); if (!tape_tap_attached()) { if (program_number == 0 || program_number == 1) { do_seek = 0; } program_number -= 1; } if (do_seek) { if (program_number > 0) { /* program numbers in tape_seek_to_file() start at 0 */ tape_seek_to_file(tape_image_dev1, program_number - 1); } else { tape_seek_start(tape_image_dev1); } } if (!tape_tap_attached()) { resources_set_int("VirtualDevices", 1); /* Kludge: for t64 images we need devtraps ON */ } reboot_for_autostart(program_name, AUTOSTART_HASTAPE, runmode); return 0; } autostartmode = AUTOSTART_ERROR; deallocate_program_name(); return -1; }
void autostart_shutdown(void) { deallocate_program_name(); }
static void advance_hasdisk(void) { char *tmp; int traps; switch (check("READY.", AUTOSTART_WAIT_BLINK)) { case YES: if (autostart_program_name) log_message(autostart_log, "Loading program '%s'", autostart_program_name); else log_message(autostart_log, "Loading program '*'"); orig_drive_true_emulation_state = get_true_drive_emulation_state(); if (handle_drive_true_emulation_overridden) { resources_get_int("VirtualDevices", &traps); if (traps) { if (orig_drive_true_emulation_state) log_message(autostart_log, "Turning true drive emulation off."); set_true_drive_emulation_mode(0); } else { if (!orig_drive_true_emulation_state) log_message(autostart_log, "Turning true drive emulation on."); set_true_drive_emulation_mode(1); } } else { if (!orig_drive_true_emulation_state) { traps = 1; } else { traps = 0; } } tmp = lib_msprintf("LOAD\"%s\",8%s:\r", autostart_program_name ? autostart_program_name : "*", autostart_basic_load ? "" : ",1"); kbdbuf_feed(tmp); lib_free(tmp); if (!traps) { if (AutostartWarp) { autostartmode = AUTOSTART_WAITSEARCHINGFOR; } else { /* be most compatible if warp is disabled */ if (autostart_run_mode == AUTOSTART_MODE_RUN) { kbdbuf_feed(AutostartRunCommand); } autostart_done(); } } else { autostartmode = AUTOSTART_LOADINGDISK; machine_bus_attention_callback_set(disk_attention_callback); } deallocate_program_name(); break; case NO: orig_drive_true_emulation_state = get_true_drive_emulation_state(); disable_warp_if_was_requested(); autostart_disable(); break; case NOT_YET: break; } }
static void advance_hasdisk(void) { char *tmp, *temp_name; int traps; switch (check("READY.", AUTOSTART_WAIT_BLINK)) { case YES: /* autostart_program_name may be petscii or ascii at this point, ANDing the charcodes with 0x7f here is a cheap way to prevent illegal characters in the printed message */ if (autostart_program_name) { temp_name = tmp = lib_stralloc(autostart_program_name); while (*tmp) { *tmp++ &= 0x7f; } log_message(autostart_log, "Loading program '%s'", temp_name); lib_free(temp_name); } else { log_message(autostart_log, "Loading program '*'"); } orig_drive_true_emulation_state = get_true_drive_emulation_state(); if (handle_drive_true_emulation_overridden) { resources_get_int("VirtualDevices", &traps); if (traps) { if (orig_drive_true_emulation_state) { log_message(autostart_log, "Turning true drive emulation off."); } set_true_drive_emulation_mode(0); } else { if (!orig_drive_true_emulation_state) { log_message(autostart_log, "Turning true drive emulation on."); } set_true_drive_emulation_mode(1); } } else { if (!orig_drive_true_emulation_state) { traps = 1; } else { traps = 0; } } tmp = lib_msprintf("LOAD\"%s\",8%s:\r", autostart_program_name ? autostart_program_name : "*", autostart_basic_load ? "" : ",1"); DBG(("advance_hasdisk '%s'", tmp)); kbdbuf_feed(tmp); lib_free(tmp); if (!traps) { if (AutostartWarp) { autostartmode = AUTOSTART_WAITSEARCHINGFOR; } else { /* be most compatible if warp is disabled */ autostart_finish(); autostart_done(); } } else { autostartmode = AUTOSTART_LOADINGDISK; machine_bus_attention_callback_set(disk_attention_callback); } deallocate_program_name(); break; case NO: orig_drive_true_emulation_state = get_true_drive_emulation_state(); disable_warp_if_was_requested(); autostart_disable(); break; case NOT_YET: break; } }
/* Clean memory and reboot for autostart. */ static void reboot_for_autostart(const char *program_name, unsigned int mode, unsigned int runmode) { int rnd; char *temp_name = NULL, *temp; if (!autostart_enabled) { return; } /* program_name may be petscii or ascii at this point, ANDing the charcodes with 0x7f here is a cheap way to prevent illegal characters in the printed message */ if (program_name) { temp_name = temp = lib_stralloc(program_name); while (*temp) { *temp++ &= 0x7f; } } log_message(autostart_log, "Resetting the machine to autostart '%s'", program_name ? temp_name : "*"); if (program_name) { lib_free(temp_name); } /* on x128 autostart will only work in 40 columns mode (and can not be fixed easily for VDC mode). We work around that by switching to 40 columns and back if needed */ if (machine_class == VICE_MACHINE_C128) { resources_get_int("40/80ColumnKey", &c128_column4080_key); resources_set_int("40/80ColumnKey", 1); } mem_powerup(); autostart_ignore_reset = 1; deallocate_program_name(); if (program_name && program_name[0]) { autostart_program_name = lib_stralloc(program_name); } autostart_initial_delay_cycles = min_cycles; resources_get_int("AutostartDelayRandom", &rnd); if (rnd) { /* additional random delay of up to 10 frames */ autostart_initial_delay_cycles += lib_unsigned_rand(1, machine_get_cycles_per_frame() * 10); } DBG(("autostart_initial_delay_cycles: %d", autostart_initial_delay_cycles)); machine_trigger_reset(MACHINE_RESET_MODE_HARD); /* The autostartmode must be set AFTER the shutdown to make the autostart threadsafe for OS/2 */ autostartmode = mode; autostart_run_mode = runmode; autostart_wait_for_reset = 1; /* enable warp before reset */ if (mode != AUTOSTART_HASSNAPSHOT) { enable_warp_if_requested(); } }