Esempio n. 1
0
/* Activate full drive emulation. */
int drive_enable(drive_context_t *drv)
{
    int i, drive_true_emulation = 0;
    unsigned int dnr;
    drive_t *drive;
    unsigned int enabled_drives = 0;

    dnr = drv->mynumber;
    drive = drv->drive;

    /* This must come first, because this might be called before the drive
       initialization.  */
    if (!rom_loaded)
        return -1;

    resources_get_int("DriveTrueEmulation", &drive_true_emulation);

    /* Always disable kernal traps. */
    if (!drive_true_emulation)
        return 0;

    if (drive->type == DRIVE_TYPE_NONE)
        return 0;

    /* Recalculate drive geometry.  */
    if (drive->image != NULL)
        drive_image_attach(drive->image, dnr + 8);

    drivecpu_wake_up(drv);

    /* Make sure the UI is updated.  */
    for (i = 0; i < DRIVE_NUM; i++) {
        unsigned int the_drive;
 
        the_drive = 1 << i;
        if (drive_context[i]->drive->enable) {
            enabled_drives |= the_drive;
            drive_context[i]->drive->old_led_status = -1;
            drive_context[i]->drive->old_half_track = -1;
        }
    }

    /* FIXME: this doesn't care about dual drives anymore */
    drive_set_active_led_color(drive->type, dnr);
    ui_enable_drive_status(enabled_drives,
                           drive_led_color);

#if 0
    /* this is the old code not respecting more than 2 drives */
    ui_enable_drive_status((drive_context[0]->drive->enable
                           ? UI_DRIVE_ENABLE_0 : 0)
                           | ((drive_context[1]->drive->enable
                           || (drive_context[0]->drive->enable
                           && drive_check_dual(drive_context[0]->drive->type))
                           ) ? UI_DRIVE_ENABLE_1 : 0),
                           drive_led_color);
#endif
    return 0;
}
Esempio n. 2
0
/* Activate full drive emulation. */
int drive_enable(drive_context_t *drv)
{
    int drive_true_emulation = 0;
    unsigned int dnr;
    drive_t *drive;

    dnr = drv->mynumber;
    drive = drv->drive;

    /* This must come first, because this might be called before the drive
       initialization.  */
    if (!rom_loaded) {
        return -1;
    }

    resources_get_int("DriveTrueEmulation", &drive_true_emulation);

    /* Always disable kernal traps. */
    if (!drive_true_emulation) {
        return 0;
    }

    if (drive->type == DRIVE_TYPE_NONE) {
        return 0;
    }

    /* Recalculate drive geometry.  */
    if (drive->image != NULL) {
        drive_image_attach(drive->image, dnr + 8);
    }

    /* resync */
    drv->cpu->stop_clk = *(drv->clk_ptr);

    if (drive->type == DRIVE_TYPE_2000 || drive->type == DRIVE_TYPE_4000) {
        drivecpu65c02_wake_up(drv);
    } else {
        drivecpu_wake_up(drv);
    }

    /* Make sure the UI is updated.  */
    drive_enable_update_ui(drv);
    return 0;
}
Esempio n. 3
0
static int attach_disk_image(disk_image_t **imgptr, vdrive_t *floppy,
                             const char *filename, unsigned int unit,
                             int devicetype)
{
    disk_image_t *image;
    disk_image_t new_image;
    int err = -1;

    if (filename == NULL) {
        log_error(attach_log, "No name, cannot attach floppy image.");
        return -1;
    }

    new_image.gcr = NULL;
    new_image.p64 = lib_calloc(1, sizeof(TP64Image));
    new_image.read_only = (unsigned int)attach_device_readonly_enabled[unit - 8];

    switch (devicetype) {
        case ATTACH_DEVICE_NONE:
        case ATTACH_DEVICE_VIRT:
        case ATTACH_DEVICE_FS:
            new_image.device = DISK_IMAGE_DEVICE_FS;
            break;
        case ATTACH_DEVICE_RAW:
            new_image.device = DISK_IMAGE_DEVICE_RAW;
            break;
    }

    disk_image_media_create(&new_image);

    switch (devicetype) {
        case ATTACH_DEVICE_NONE:
        case ATTACH_DEVICE_VIRT:
        case ATTACH_DEVICE_FS:
            disk_image_fsimage_name_set(&new_image, filename);
            break;
        case ATTACH_DEVICE_RAW:
            disk_image_rawimage_driver_name_set(&new_image);
            break;
    }

    if (disk_image_open(&new_image) < 0) {
        P64ImageDestroy((PP64Image) new_image.p64);
        lib_free(new_image.p64);
        disk_image_media_destroy(&new_image);
        return -1;
    }

    detach_disk_image_and_free(*imgptr, floppy, unit);

    *imgptr = disk_image_create();
    image = *imgptr;

    memcpy(image, &new_image, sizeof(disk_image_t));

    switch (unit) {
        case 8:
        case 9:
        case 10:
        case 11:
            err = drive_image_attach(image, unit);
            err &= vdrive_attach_image(image, unit, floppy);
            err &= machine_drive_image_attach(image, unit);
            break;
    }
    if (err) {
        disk_image_close(image);
        disk_image_media_destroy(image);
        disk_image_destroy(image);
        *imgptr = NULL;
    }
    return err;
}