Exemplo n.º 1
0
int drive_check_type(unsigned int drive_type, unsigned int dnr)
{
    if (!drive_check_bus(drive_type, iec_available_busses()))
        return 0;

    if (drive_check_dual(drive_type)) {
        if (is_drive1(dnr)) {
            /* Dual drives only supported on even device numbers.  */
            return 0;
        } else {
            if (drive_context[mk_drive1(dnr)]->drive->type != DRIVE_TYPE_NONE)
                /* Disable dual drive if second device is enabled.  */
                return 0;
        }
    } else {
        if (is_drive1(dnr)) {
            if (drive_check_dual(drive_context[mk_drive0(dnr)]->drive->type))
                /* Disable second device if dual drive is enabled.  */
                return drive_type == DRIVE_TYPE_NONE;
        }
    }

    if (machine_drive_rom_check_loaded(drive_type) < 0)
        return 0;

    return 1;
}
Exemplo n.º 2
0
int fdc_detach_image(disk_image_t *image, unsigned int unit)
{
    int drive_no, imgno;

#ifdef FDC_DEBUG
    log_message(fdc_log, "fdc_detach_image(image=%p, unit=%d)",
                image, unit);
#endif

    if (image == NULL || unit < 8 || unit >= (8+DRIVE_NUM))
        return -1;

    {
        int drive0 = mk_drive0(unit - 8);

        if (fdc[drive0].num_drives == 2) {
            drive_no = drive0;
        } else {
            drive_no = unit - 8;
        }
    }

    imgno = unit - 8;

    fdc[imgno].realimage = NULL;

    if (fdc[drive_no].drive_type == DRIVE_TYPE_8050
        || fdc[drive_no].drive_type == DRIVE_TYPE_8250
        || fdc[drive_no].drive_type == DRIVE_TYPE_1001) {
        switch(image->type) {
          case DISK_IMAGE_TYPE_D80:
          case DISK_IMAGE_TYPE_D82:
            disk_image_detach_log(image, fdc_log, unit);
            break;
          default:
            return -1;
        }
    } else {
        switch(image->type) {
          case DISK_IMAGE_TYPE_D64:
          case DISK_IMAGE_TYPE_D67:
          case DISK_IMAGE_TYPE_G64:
          case DISK_IMAGE_TYPE_P64:
          case DISK_IMAGE_TYPE_X64:
            disk_image_detach_log(image, fdc_log, unit);
            break;
          default:
            return -1;
        }
    }

    fdc[imgno].wps_change += 2;
    fdc[imgno].image = NULL;
    return 0;
}
Exemplo n.º 3
0
static int drive_resources_type(int val, void *param)
{
    unsigned int type, dnr;
    int busses;
    drive_t *drive, *drive0;

    dnr = vice_ptr_to_uint(param);
    drive = drive_context[dnr]->drive;

    type = (unsigned int)val;
    busses = iec_available_busses();

    /* if bus for drive type is not allowed, set to default value for bus */
    if (!drive_check_bus(type, busses)) {
        if (busses & IEC_BUS_IEC) {
            type = DRIVE_TYPE_1541;
        } else
        if (busses & IEC_BUS_IEEE) {
            type = DRIVE_TYPE_2031;
        } else {
            type = DRIVE_TYPE_NONE;
        }
    }

    if (is_drive0(dnr)) {
        if (drive_check_dual(type)) {
            int drive1 = mk_drive1(dnr);

            /* dual disk drives disable second emulated unit */
            log_warning(drive->log,
                        "Dual disk drive %d disables emulated drive %d", dnr, drive1);

            drive_resources_type(DRIVE_TYPE_NONE, int_to_void_ptr(drive1));
        }
    } else {
        drive0 = drive_context[mk_drive0(dnr)]->drive;
        if (drive0->enable && drive_check_dual(drive0->type)) {
            /* dual disk drives disable second emulated unit */
            log_warning(drive->log,
                        "Dual disk drive %d disables emulated drive %d", mk_drive0(dnr), dnr);

            type = DRIVE_TYPE_NONE;
        }
    }

    switch (type) {
        case DRIVE_TYPE_1541:
        case DRIVE_TYPE_1541II:
        case DRIVE_TYPE_1551:
        case DRIVE_TYPE_1570:
        case DRIVE_TYPE_1571:
        case DRIVE_TYPE_1571CR:
        case DRIVE_TYPE_1581:
        case DRIVE_TYPE_2000:
        case DRIVE_TYPE_4000:
        case DRIVE_TYPE_2031:
        case DRIVE_TYPE_1001:
        case DRIVE_TYPE_2040:
        case DRIVE_TYPE_3040:
        case DRIVE_TYPE_4040:
        case DRIVE_TYPE_8050:
        case DRIVE_TYPE_8250:
            if (drive->type != type) {
                drive->current_half_track = 2 * 18;
                if ((type == DRIVE_TYPE_1001)
                    || (type == DRIVE_TYPE_8050)
                    || (type == DRIVE_TYPE_8250)) {
                    drive->current_half_track = 2 * 38;
                }
            }
            drive->type = type;
            if (drive_true_emulation) {
                drive->enable = 1;
                drive_enable(drive_context[dnr]);
                /* 1551 drive does not use the IEC bus */
                machine_bus_status_drivetype_set(dnr + 8, drive_check_bus(type,
                                                                          IEC_BUS_IEC));
            } else {
                drive_enable_update_ui(drive_context[dnr]);
            }
            drive_set_disk_drive_type(type, drive_context[dnr]);
            driverom_initialize_traps(drive);
            machine_drive_idling_method(dnr);
            return 0;
        case DRIVE_TYPE_NONE:
            drive->type = type;
            drive_disable(drive_context[dnr]);
            machine_bus_status_drivetype_set(dnr + 8, 0);
            return 0;
        default:
            return -1;
    }
}
Exemplo n.º 4
0
int fdc_attach_image(disk_image_t *image, unsigned int unit)
{
    int drive_no, imgno;

#ifdef FDC_DEBUG
    log_message(fdc_log, "fdc_attach_image(image=%p, unit=%d)",
                image, unit);
#endif

    if (unit < 8 || unit >= 8 + DRIVE_NUM)
        return -1;

    {
        int drive0 = mk_drive0(unit - 8);

        if (fdc[drive0].num_drives == 2) {
            drive_no = drive0;
        } else {
            drive_no = unit - 8;
        }
    }

    imgno = unit - 8;

    /* FIXME: hack - we need to save the image to be able to re-attach
       when the disk drive type changes, in particular from the initial
       DRIVE_TYPE_NONE to a proper drive. */
    fdc[imgno].realimage = image;

    if (fdc[drive_no].drive_type == DRIVE_TYPE_NONE) {
        return -1;
    }

    if (fdc[drive_no].drive_type == DRIVE_TYPE_8050
        || fdc[drive_no].drive_type == DRIVE_TYPE_8250
        || fdc[drive_no].drive_type == DRIVE_TYPE_1001) {
        switch(image->type) {
          case DISK_IMAGE_TYPE_D80:
          case DISK_IMAGE_TYPE_D82:
            disk_image_attach_log(image, fdc_log, unit);
            break;
          default:
#ifdef FDC_DEBUG
            log_message(fdc_log, "Could not attach image type %d to disk %d.",
                        image->type, fdc[drive_no].drive_type);
#endif
            return -1;
        }
    } else {
        switch(image->type) {
          case DISK_IMAGE_TYPE_D64:
          case DISK_IMAGE_TYPE_D67:
          case DISK_IMAGE_TYPE_G64:
          case DISK_IMAGE_TYPE_P64:
          case DISK_IMAGE_TYPE_X64:
            disk_image_attach_log(image, fdc_log, unit);
            break;
          default:
#ifdef FDC_DEBUG
            log_message(fdc_log, "Could not attach image type %d to disk %d.",
                        image->type, fdc[drive_no].drive_type);
#endif
            return -1;
        }
    }

    fdc[imgno].wps_change += 2;
    fdc[imgno].image = image;
    return 0;
}