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; }
void fdc_reset(unsigned int fnum, unsigned int drive_type) { fdc_t *thefdc = &fdc[fnum]; int drive1 = mk_drive1(fnum); disk_image_t *saved_image0, *saved_image1; #ifdef FDC_DEBUG log_message(fdc_log, "fdc_reset: drive %d type=%d\n",fnum, drive_type); #endif saved_image0 = fdc[fnum].realimage; saved_image1 = NULL; /* detach disk images */ if (thefdc->image) { thefdc->wps_change = 0; fdc_detach_image(thefdc->image, fnum + 8); } if (thefdc->num_drives == 2) { saved_image1 = fdc[drive1].realimage; if (fdc[drive1].image) { fdc[drive1].wps_change = 0; fdc_detach_image(fdc[drive1].image, drive1 + 8); } } if (drive_check_old(drive_type)) { thefdc->drive_type = drive_type; thefdc->num_drives = is_drive1(fnum) ? 1 : drive_check_dual(drive_type) ? 2 : 1; thefdc->fdc_state = FDC_RESET0; alarm_set(thefdc->fdc_alarm, drive_clk[fnum] + 20); } else { thefdc->drive_type = DRIVE_TYPE_NONE; alarm_unset(thefdc->fdc_alarm); thefdc->fdc_state = FDC_UNUSED; thefdc->num_drives = 0; } /* re-attach disk images */ if (saved_image0) { #ifdef FDC_DEBUG printf("ieee/fdc.c:fdc_reset dev %d type %d drive 0 re-attach image %p (drive: %p)\n", fnum+8, drive_type, saved_image0, drive_context[fnum]->drive->image); #endif fdc_attach_image(saved_image0, fnum + 8); } if (saved_image1) { #ifdef FDC_DEBUG printf("ieee/fdc.c:fdc_reset dev %d type %d drive 1 re-attach image %p (drive: %p)\n", fnum+8, drive_type, saved_image0, drive_context[drive1]->drive->image); #endif fdc_attach_image(saved_image1, drive1 + 8); } }