Esempio n. 1
0
int vdrive_attach_image(disk_image_t *image, unsigned int unit,
                        vdrive_t *vdrive)
{
	vdrive->unit = unit;

	disk_image_attach_log(image, 0, unit);

	switch(image->type) {
		case DISK_IMAGE_TYPE_D64:
			vdrive->image_format = VDRIVE_IMAGE_FORMAT_1541;
			vdrive->num_tracks  = image->tracks;
			break;
		case DISK_IMAGE_TYPE_D67:
			vdrive->image_format = VDRIVE_IMAGE_FORMAT_2040;
			vdrive->num_tracks  = image->tracks;
			break;
		case DISK_IMAGE_TYPE_D71:
			vdrive->image_format = VDRIVE_IMAGE_FORMAT_1571;
			vdrive->num_tracks  = image->tracks;
			break;
		case DISK_IMAGE_TYPE_D81:
			vdrive->image_format = VDRIVE_IMAGE_FORMAT_1581;
			vdrive->num_tracks  = image->tracks;
			break;
		case DISK_IMAGE_TYPE_D80:
			vdrive->image_format = VDRIVE_IMAGE_FORMAT_8050;
			vdrive->num_tracks  = image->tracks;
			break;
		case DISK_IMAGE_TYPE_D82:
			vdrive->image_format = VDRIVE_IMAGE_FORMAT_8250;
			vdrive->num_tracks = image->tracks;
			break;
		case DISK_IMAGE_TYPE_G64:
			vdrive->image_format = VDRIVE_IMAGE_FORMAT_1541;
			vdrive->num_tracks = 35;
			break;
		case DISK_IMAGE_TYPE_X64:
			vdrive->image_format = VDRIVE_IMAGE_FORMAT_1541;
			vdrive->num_tracks = image->tracks;
			break;
		default:
			return -1;
	}

	/* Initialise format constants */
	vdrive_set_disk_geometry(vdrive);

	vdrive->image = image;

	if (vdrive_bam_read_bam(vdrive))
	{
		#ifdef CELL_DEBUG
		printf("ERROR: Cannot access BAM.\n");
		#endif
		return -1;
	}
	return 0;
}
Esempio n. 2
0
/* Attach a disk image to the true drive emulation. */
int drive_image_attach(disk_image_t *image, unsigned int unit)
{
    unsigned int dnr;
    drive_t *drive;

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

    dnr = unit - 8;
    drive = drive_context[dnr]->drive;

    if (drive_check_image_format(image->type, dnr) < 0) {
        return -1;
    }

    drive->read_only = image->read_only;
    drive->attach_clk = drive_clk[dnr];
    if (drive->detach_clk > (CLOCK)0) {
        drive->attach_detach_clk = drive_clk[dnr];
    }
    drive->ask_extend_disk_image = 1;

    switch (image->type) {
        case DISK_IMAGE_TYPE_D64:
        case DISK_IMAGE_TYPE_D67:
        case DISK_IMAGE_TYPE_D71:
        case DISK_IMAGE_TYPE_G64:
        case DISK_IMAGE_TYPE_X64:
        case DISK_IMAGE_TYPE_P64:
            disk_image_attach_log(image, driveimage_log, unit);
            break;
        default:
            return -1;
    }

    drive->image = image;
    drive->image->gcr = drive->gcr;
    drive->image->p64 = (void*)drive->p64;

    if (disk_image_read_image(drive->image) < 0) {
        drive->image = NULL;
        return -1;
    }
    if (drive->image->type == DISK_IMAGE_TYPE_P64) {
        drive->P64_image_loaded = 1;
        drive->P64_dirty = 0;
    } else {
        drive->GCR_image_loaded = 1;
    }
    drive->complicated_image_loaded = (drive->image->type == DISK_IMAGE_TYPE_P64
                                       || drive->image->type == DISK_IMAGE_TYPE_G64);
    drive_set_half_track(drive->current_half_track, drive->side, drive);
    return 0;
}
Esempio n. 3
0
/* Attach a disk image to the true drive emulation. */
int drive_image_attach(disk_image_t *image, unsigned int unit)
{
	unsigned int dnr;
	drive_t *drive;

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

	dnr = unit - 8;
	drive = drive_context[dnr]->drive;

	if (drive_check_image_format(image->type, dnr) < 0)
		return -1;

	drive->read_only = image->read_only;
	drive->attach_clk = drive_clk[dnr];
	if (drive->detach_clk > (CLOCK)0)
		drive->attach_detach_clk = drive_clk[dnr];
	drive->ask_extend_disk_image = 1;

	switch(image->type)
	{
		case DISK_IMAGE_TYPE_D64:
		case DISK_IMAGE_TYPE_D67:
		case DISK_IMAGE_TYPE_D71:
		case DISK_IMAGE_TYPE_G64:
		case DISK_IMAGE_TYPE_X64:
			disk_image_attach_log(image, 0, unit);
			break;
		default:
			return -1;
	}

	drive->image = image;
	drive->image->gcr = drive->gcr;

	if (drive->image->type == DISK_IMAGE_TYPE_G64) {
		if (disk_image_read_gcr_image(drive->image) < 0) {
			drive->image = NULL;
			return -1;
		}
	} else {
		if (setID(dnr) >= 0) {
			drive_image_read_d64_d71(drive);
			drive->GCR_image_loaded = 1;
			return 0;
		} else {
			return -1;
		}
	}
	drive->GCR_image_loaded = 1;

	return 0;
}
Esempio n. 4
0
int wd1770_attach_image(disk_image_t *image, unsigned int unit)
{
    if (unit < 8 || unit > 8 + DRIVE_NUM)
        return -1;

    switch(image->type) {
      case DISK_IMAGE_TYPE_D81:
        disk_image_attach_log(image, wd1770_log, unit, "D81");
        break;
      default:
        return -1;
    }

    wd1770[unit - 8].attach_clk = drive_clk[unit - 8];
    wd1770[unit - 8].image = image;
    return 0;
}
Esempio n. 5
0
int vdrive_attach_image(disk_image_t *image, unsigned int unit,
                        vdrive_t *vdrive)
{
    vdrive->unit = unit;

    switch(image->type) {
      case DISK_IMAGE_TYPE_D64:
        disk_image_attach_log(image, vdrive_log, unit, "D64");
        vdrive->image_format = VDRIVE_IMAGE_FORMAT_1541;
        vdrive->num_tracks  = image->tracks;
        break;
      case DISK_IMAGE_TYPE_D67:
        disk_image_attach_log(image, vdrive_log, unit, "D67");
        vdrive->image_format = VDRIVE_IMAGE_FORMAT_2040;
        vdrive->num_tracks  = image->tracks;
        break;
      case DISK_IMAGE_TYPE_D71:
        disk_image_attach_log(image, vdrive_log, unit, "D71");
        vdrive->image_format = VDRIVE_IMAGE_FORMAT_1571;
        vdrive->num_tracks  = image->tracks;
        break;
      case DISK_IMAGE_TYPE_D81:
        disk_image_attach_log(image, vdrive_log, unit, "D81");
        vdrive->image_format = VDRIVE_IMAGE_FORMAT_1581;
        vdrive->num_tracks  = image->tracks;
        break;
      case DISK_IMAGE_TYPE_D80:
        disk_image_attach_log(image, vdrive_log, unit, "D80");
        vdrive->image_format = VDRIVE_IMAGE_FORMAT_8050;
        vdrive->num_tracks  = image->tracks;
        break;
      case DISK_IMAGE_TYPE_D82:
        disk_image_attach_log(image, vdrive_log, unit, "D82");
        vdrive->image_format = VDRIVE_IMAGE_FORMAT_8250;
        vdrive->num_tracks = image->tracks;
        break;
      case DISK_IMAGE_TYPE_G64:
        disk_image_attach_log(image, vdrive_log, unit, "G64");
        vdrive->image_format = VDRIVE_IMAGE_FORMAT_1541;
        vdrive->num_tracks = 35;
        break;
      case DISK_IMAGE_TYPE_X64:
        disk_image_attach_log(image, vdrive_log, unit, "X64");
        vdrive->image_format = VDRIVE_IMAGE_FORMAT_1541;
        vdrive->num_tracks = image->tracks;
        break;
      default:
        return -1;
    }

    /* Initialise format constants */
    vdrive_set_disk_geometry(vdrive);

    vdrive->image = image;

    if (vdrive_bam_read_bam(vdrive)) {
        log_error(vdrive_log, "Cannot access BAM.");
        return -1;
    }
    return 0;
}
Esempio n. 6
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;
}
Esempio n. 7
0
int vdrive_attach_image(disk_image_t *image, unsigned int unit,
                        vdrive_t *vdrive)
{
    vdrive->unit = unit;

    disk_image_attach_log(image, vdrive_log, unit);

    switch (image->type) {
        case DISK_IMAGE_TYPE_D64:
            vdrive->image_format = VDRIVE_IMAGE_FORMAT_1541;
            vdrive->num_tracks = image->tracks;
            vdrive->bam_size = 0x100;
            break;
        case DISK_IMAGE_TYPE_D67:
            vdrive->image_format = VDRIVE_IMAGE_FORMAT_2040;
            vdrive->num_tracks = image->tracks;
            vdrive->bam_size = 0x100;
            break;
        case DISK_IMAGE_TYPE_D71:
            vdrive->image_format = VDRIVE_IMAGE_FORMAT_1571;
            vdrive->num_tracks = image->tracks;
            vdrive->bam_size = 0x200;
            break;
        case DISK_IMAGE_TYPE_D81:
            vdrive->image_format = VDRIVE_IMAGE_FORMAT_1581;
            vdrive->num_tracks = image->tracks;
            vdrive->bam_size = 0x300;
            break;
        case DISK_IMAGE_TYPE_D80:
            vdrive->image_format = VDRIVE_IMAGE_FORMAT_8050;
            vdrive->num_tracks = image->tracks;
            vdrive->bam_size = 0x500;
            break;
        case DISK_IMAGE_TYPE_D82:
            vdrive->image_format = VDRIVE_IMAGE_FORMAT_8250;
            vdrive->num_tracks = image->tracks;
            vdrive->bam_size = 0x500;
            break;
        case DISK_IMAGE_TYPE_G64:
            vdrive->image_format = VDRIVE_IMAGE_FORMAT_1541;
            vdrive->num_tracks = 35; /* FIXME: it can be more */
            vdrive->bam_size = 0x100;
            break;
        case DISK_IMAGE_TYPE_P64:
            vdrive->image_format = VDRIVE_IMAGE_FORMAT_1541;
            vdrive->num_tracks = 35; /* FIXME: it can be more */
            vdrive->bam_size = 0x100;
            break;
        case DISK_IMAGE_TYPE_X64:
            vdrive->image_format = VDRIVE_IMAGE_FORMAT_1541;
            vdrive->num_tracks = image->tracks;
            vdrive->bam_size = 0x100;
            break;
        case DISK_IMAGE_TYPE_D1M:
        case DISK_IMAGE_TYPE_D2M:
        case DISK_IMAGE_TYPE_D4M:
            vdrive->image_format = VDRIVE_IMAGE_FORMAT_4000;
            vdrive->num_tracks = image->tracks - 1;
            vdrive->bam_size = 0x2100;
            break;
        default:
            return -1;
    }
    DBG(("vdrive_attach_image image type:%d vdrive format:%d num_tracks:%d bam_size:%d",
         image->type, vdrive->image_format, vdrive->num_tracks, vdrive->bam_size));

    /* Initialise format constants */
    vdrive_set_disk_geometry(vdrive);

    vdrive->image = image;
    vdrive->bam = lib_malloc(vdrive->bam_size);

    if (vdrive_bam_read_bam(vdrive)) {
        log_error(vdrive_log, "Cannot access BAM.");
        return -1;
    }
    return 0;
}