static void wd_fdc_type_ii( wd_fdc *f ) { libspectrum_byte b = f->command_register; wd_fdc_drive *d = f->current_drive; event_remove_type( fdc_event ); if( f->type == WD1773 || f->type == FD1793 ) { if( !f->hlt ) { event_add_with_data( tstates + 5 * machine_current->timings.processor_speed / 1000, fdc_event, f ); return; } } if( f->state == WD_FDC_STATE_WRITE ) { if( d->fdd.wrprot ) { f->status_register |= WD_FDC_SR_WRPROT; f->status_register &= ~WD_FDC_SR_BUSY; f->state = WD_FDC_STATE_NONE; wd_fdc_set_intrq( f ); return; } f->status_register &= ~WD_FDC_SR_WRPROT; } f->data_multisector = b & 0x10 ? 1 : 0; f->rev = 5; f->id_mark = WD_FDC_AM_NONE; wd_fdc_type_ii_seek( f ); }
static void wd_fdc_event( libspectrum_dword last_tstates GCC_UNUSED, int event, void *user_data ) { wd_fdc *f = user_data; fdd_t *d = f->current_drive; if( event == timeout_event ) { if( f->state == WD_FDC_STATE_READ || f->state == WD_FDC_STATE_WRITE || f->state == WD_FDC_STATE_READTRACK || f->state == WD_FDC_STATE_WRITETRACK || f->state == WD_FDC_STATE_READID ) { f->state = WD_FDC_STATE_NONE; f->status_register |= WD_FDC_SR_LOST; f->status_register &= ~WD_FDC_SR_BUSY; wd_fdc_reset_datarq( f ); wd_fdc_set_intrq( f ); } return; } if( event == motor_off_event ) { if( f->type == WD1770 || f->type == WD1772 ) { f->status_register &= ~WD_FDC_SR_MOTORON; fdd_motoron( d, 0 ); } else { /* WD1773/FD1973 */ f->head_load = 0; if( f->flags & WD_FLAG_BETA128 ) fdd_motoron( d, 0 ); else fdd_head_load( d, 0 ); } return; } if( ( f->type == WD1773 || f->type == FD1793 || f->type == WD2797 ) && f->hlt_time > 0 && f->head_load && !f->hlt ) f->hlt = 1; if( ( ( f->type == WD1770 || f->type == WD1772 ) && ( f->status_register & WD_FDC_SR_MOTORON ) && f->status_type == WD_FDC_STATUS_TYPE1 ) || ( ( f->type == WD1773 || f->type == FD1793 || f->type == WD2797 ) && ( f->state == WD_FDC_STATE_SEEK || f->state == WD_FDC_STATE_SEEK_DELAY ) && f->head_load ) ) { f->status_register |= WD_FDC_SR_SPINUP; } if( f->read_id ) { if( f->state == WD_FDC_STATE_VERIFY ) wd_fdc_seek_verify_read_id( f ); else if( ( f->state == WD_FDC_STATE_READ || f->state == WD_FDC_STATE_WRITE ) && f->datarq ) f->datarq = 0, wd_fdc_set_datarq( f ); else if( f->state == WD_FDC_STATE_READ || f->state == WD_FDC_STATE_WRITE ) wd_fdc_type_ii_seek( f ); else if( f->state == WD_FDC_STATE_READID ) wd_fdc_type_iii( f ); } else if( f->state == WD_FDC_STATE_SEEK || f->state == WD_FDC_STATE_SEEK_DELAY ) wd_fdc_type_i( f ); else if( f->state == WD_FDC_STATE_VERIFY ) wd_fdc_seek_verify( f ); else if( ( f->state == WD_FDC_STATE_READ || f->state == WD_FDC_STATE_WRITE ) && f->datarq ) f->datarq = 0, wd_fdc_set_datarq( f ); else if( f->state == WD_FDC_STATE_READ || f->state == WD_FDC_STATE_WRITE ) wd_fdc_type_ii( f ); else if( ( f->state == WD_FDC_STATE_READTRACK || f->state == WD_FDC_STATE_READID || f->state == WD_FDC_STATE_WRITETRACK ) && f->datarq ) f->datarq = 0, wd_fdc_set_datarq( f ); else if( f->state == WD_FDC_STATE_READTRACK || f->state == WD_FDC_STATE_READID || f->state == WD_FDC_STATE_WRITETRACK ) wd_fdc_type_iii( f ); }