Esempio n. 1
0
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;
    }
}
Esempio n. 2
0
/* This function is called by the `serialreceivebyte()' trap as soon as EOF
   is reached.  */
static void disk_eof_callback(void)
{
    if (handle_drive_true_emulation) {
        BYTE id[2], *buffer;
        unsigned int track, sector;

        if (orig_drive_true_emulation_state) {
            log_message(autostart_log, "Turning true drive emulation on.");
            vdrive_bam_get_disk_id(8, id);
            vdrive_get_last_read(&track, &sector, &buffer);
        }
        set_true_drive_emulation_mode(orig_drive_true_emulation_state);
        if (orig_drive_true_emulation_state) {
            drive_set_disk_memory(id, track, sector, drive_context[0]);
            drive_set_last_read(track, sector, buffer, drive_context[0]);
        }
    }

    if (autostartmode != AUTOSTART_NONE) {
        if (autostart_run_mode == AUTOSTART_MODE_RUN)
            log_message(autostart_log, "Starting program.");
        else
            log_message(autostart_log, "Program loaded.");
    }

    autostartmode = AUTOSTART_DONE;

    machine_bus_eof_callback_set(NULL);
}
Esempio n. 3
0
/* This function is called by the `serialreceivebyte()' trap as soon as EOF
   is reached.  */
static void disk_eof_callback(void)
{
    if (handle_drive_true_emulation_overridden) {
        BYTE id[2], *buffer;
        unsigned int track, sector;

        if (orig_drive_true_emulation_state) {
            log_message(autostart_log, "Turning true drive emulation on.");
            vdrive_bam_get_disk_id(8, id);
            vdrive_get_last_read(&track, &sector, &buffer);
        }
        set_true_drive_emulation_mode(orig_drive_true_emulation_state);
        if (orig_drive_true_emulation_state) {
            drive_set_disk_memory(id, track, sector, drive_context[0]);
            drive_set_last_read(track, sector, buffer, drive_context[0]);
        }
    }

    if (autostartmode != AUTOSTART_NONE) {
        if (autostart_run_mode == AUTOSTART_MODE_RUN) {
            log_message(autostart_log, "Starting program.");
            kbdbuf_feed(AutostartRunCommand);
        }
        else {
            log_message(autostart_log, "Program loaded.");
        }
    }
    
    autostart_done();

    machine_bus_eof_callback_set(NULL);

    disable_warp_if_was_requested();
}
Esempio n. 4
0
/* This function is called by the `serialreceivebyte()' trap as soon as EOF
   is reached.  */
static void disk_eof_callback(void)
{
    if (handle_drive_true_emulation_overridden) {
        BYTE id[2], *buffer = NULL;
        unsigned int track, sector;
        /* FIXME: shouldnt this loop over all drives? */
        if (orig_drive_true_emulation_state) {
            log_message(autostart_log, "Turning true drive emulation on.");
            if (vdrive_bam_get_disk_id(8, id) == 0) {
                vdrive_get_last_read(&track, &sector, &buffer);
            }
        }
        set_true_drive_emulation_mode(orig_drive_true_emulation_state);
        if (orig_drive_true_emulation_state) {
            if (buffer) {
                log_message(autostart_log, "Restoring true drive state of drive 8.");
                drive_set_disk_memory(id, track, sector, drive_context[0]);
                drive_set_last_read(track, sector, buffer, drive_context[0]);
            } else {
                log_message(autostart_log, "No Disk Image in drive 8.");
            }
        }
    }

    if (autostartmode != AUTOSTART_NONE) {
        autostart_finish();
    }

    autostart_done();

    machine_bus_eof_callback_set(NULL);

    disable_warp_if_was_requested();
}
Esempio n. 5
0
/* Execute the actions for the current `autostartmode', advancing to the next
   mode if necessary.  */
void autostart_advance(void)
{
    if (!autostart_enabled) {
        return;
    }

    if ( orig_drive_true_emulation_state == -1) {
        orig_drive_true_emulation_state = get_true_drive_emulation_state();
    }

    if (maincpu_clk < autostart_initial_delay_cycles) {
        autostart_wait_for_reset = 0;
        return;
    }

    if (autostart_wait_for_reset) {
        return;
    }

    switch (autostartmode) {
      case AUTOSTART_HASTAPE:
        advance_hastape();
        break;
      case AUTOSTART_PRESSPLAYONTAPE:
        advance_pressplayontape();
        break;
      case AUTOSTART_LOADINGTAPE:
        advance_loadingtape();
        break;
      case AUTOSTART_HASDISK:
        advance_hasdisk();
        break;
      case AUTOSTART_HASSNAPSHOT:
        advance_hassnapshot();
        break;
      case AUTOSTART_WAITLOADREADY:
        advance_waitloadready();
        break;
      case AUTOSTART_WAITLOADING:
        advance_waitloading();
        break;
      case AUTOSTART_WAITSEARCHINGFOR:
        advance_waitsearchingfor();
        break;
      case AUTOSTART_INJECT:
        advance_inject();
        break;
      default:
        return;
    }

    if (autostartmode == AUTOSTART_ERROR && handle_drive_true_emulation_overridden) {
        log_message(autostart_log, "Now turning true drive emulation %s.",
                    orig_drive_true_emulation_state ? "on" : "off");
        set_true_drive_emulation_mode(orig_drive_true_emulation_state);
    }
}
Esempio n. 6
0
/* Autostart PRG file `file_name'.  The PRG file can either be a raw CBM file
   or a P00 file, and the FS-based drive emulation is set up so that its
   directory becomes the current one on unit #8.  */
int autostart_prg(const char *file_name, unsigned int runmode)
{
    char *directory;
    char *file;
    fileio_info_t *finfo;

    if (network_connected())
        return -1;
    
    finfo = fileio_open(file_name, NULL, FILEIO_FORMAT_RAW | FILEIO_FORMAT_P00,
                        FILEIO_COMMAND_READ | FILEIO_COMMAND_FSNAME,
                        FILEIO_TYPE_PRG);

    if (finfo == NULL) {
        log_error(autostart_log, "Cannot open `%s'.", file_name);
        return -1;
    }

    /* Extract the directory path to allow FS-based drive emulation to
       work.  */
    util_fname_split(file_name, &directory, &file);

    if (archdep_path_is_relative(directory)) {
        char *tmp;
        archdep_expand_path(&tmp, directory);
        lib_free(directory);
        directory = tmp;

        /* FIXME: We should actually eat `.'s and `..'s from `directory'
           instead.  */
    }

    /* Setup FS-based drive emulation.  */
    fsdevice_set_directory(directory ? directory : ".", 8);
    set_true_drive_emulation_mode(0);
    orig_drive_true_emulation_state =0;
    resources_set_int("VirtualDevices", 1);
    resources_set_int("FSDevice8ConvertP00", 1);
    file_system_detach_disk(8);
    ui_update_menus();

    /* Now it's the same as autostarting a disk image.  */
    reboot_for_autostart((char *)(finfo->name), AUTOSTART_HASDISK, runmode);

    lib_free(directory);
    lib_free(file);
    fileio_close(finfo);

    log_message(autostart_log, "Preparing to load PRG file `%s'.",
                file_name);

    return 0;
}
Esempio n. 7
0
/* Execute the actions for the current `autostartmode', advancing to the next
   mode if necessary.  */
void autostart_advance(void)
{
    if (!autostart_enabled)
        return;

    if( orig_drive_true_emulation_state == -1)
    {
        orig_drive_true_emulation_state = get_true_drive_emulation_state();
    }
 
    if (maincpu_clk < min_cycles)
    {
        autostart_wait_for_reset = 0;
        return;
    }

    if (autostart_wait_for_reset)
        return;


    switch (autostartmode) {
      case AUTOSTART_HASTAPE:
        advance_hastape();
        break;
      case AUTOSTART_PRESSPLAYONTAPE:
        advance_pressplayontape();
        break;
      case AUTOSTART_LOADINGTAPE:
        advance_loadingtape();
        break;
      case AUTOSTART_HASDISK:
        advance_hasdisk();
        break;
      case AUTOSTART_HASSNAPSHOT:
        advance_hassnapshot();
        break;
      default:
        return;
    }

    if (autostartmode == AUTOSTART_ERROR && handle_drive_true_emulation) {
        log_message(autostart_log, "Now turning true drive emulation %s.",
                    orig_drive_true_emulation_state ? "on" : "off");
        set_true_drive_emulation_mode(orig_drive_true_emulation_state);
    }
}
Esempio n. 8
0
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;
    }
}
Esempio n. 9
0
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;
    }
}