void mc6843_device::device_reset() { int i; LOG (( "mc6843 reset\n" )); /* setup/reset floppy drive */ for ( i = 0; i < 4; i++ ) { legacy_floppy_image_device * img = floppy_image( i ); img->floppy_mon_w(CLEAR_LINE); img->floppy_drive_set_ready_state(FLOPPY_DRIVE_READY, 0 ); img->floppy_drive_set_rpm( 300. ); } /* reset registers */ m_CMR &= 0xf0; /* zero only command */ m_ISR = 0; m_STRA &= 0x5c; m_SAR = 0; m_STRB &= 0x20; status_update( ); m_data_size = 0; m_data_idx = 0; m_timer_cont->adjust( attotime::never ); }
bool floppy_image_device::call_create(int format_type, option_resolution *format_options) { image = global_alloc(floppy_image(tracks, sides, form_factor)); output_format = 0; // search for a suitable format based on the extension for(floppy_image_format_t *i = fif_list; i; i = i->next) { // only consider formats that actually support saving if(!i->supports_save()) continue; if (i->extension_matches(basename())) { output_format = i; break; } } // did we find a suitable format? if (output_format == 0) { seterror(IMAGE_ERROR_INVALIDIMAGE, "Unable to identify the image format"); return IMAGE_INIT_FAIL; } return IMAGE_INIT_PASS; }
bool floppy_image_device::call_load() { io_generic io; // Do _not_ remove this cast otherwise the pointer will be incorrect when used by the ioprocs. io.file = (device_image_interface *)this; io.procs = &image_ioprocs; io.filler = 0xff; int best = 0; floppy_image_format_t *best_format = 0; for(floppy_image_format_t *format = fif_list; format; format = format->next) { int score = format->identify(&io, form_factor); if(score > best) { best = score; best_format = format; } } if(!best_format) return IMAGE_INIT_FAIL; image = global_alloc(floppy_image(tracks, sides, form_factor)); best_format->load(&io, form_factor, image); revolution_start_time = attotime::never; revolution_count = 0; index_resync(); image_dirty = false; output_format = 0; if (!cur_load_cb.isnull()) return cur_load_cb(this); return IMAGE_INIT_PASS; }
/* preamble to all sector read / write commands, returns 1 if found */ int mc6843_device::address_search( chrn_id* id ) { legacy_floppy_image_device* img = floppy_image( ); int r = 0; while ( 1 ) { if ( ( ! img->floppy_drive_get_next_id( m_side, id ) ) || ( id->flags & ID_FLAG_CRC_ERROR_IN_ID_FIELD ) || ( id->N != 0 ) ) { /* read address error */ LOG(( "%f mc6843_address_search: get_next_id failed\n", machine().time().as_double() )); m_STRB |= 0x0a; /* set CRC error & Sector Address Undetected */ cmd_end( ); return 0; } if ( id->C != m_LTAR ) { /* track mismatch */ LOG(( "%f mc6843_address_search: track mismatch: logical=%i real=%i\n", machine().time().as_double(), m_LTAR, id->C )); m_data[0] = id->C; /* make the track number available to the CPU */ m_STRA |= 0x20; /* set Track Not Equal */ cmd_end( ); return 0; } if ( id->R == m_SAR ) { /* found! */ LOG(( "%f mc6843_address_search: sector %i found on track %i\n", machine().time().as_double(), id->R, id->C )); if ( ! (m_CMR & 0x20) ) { m_ISR |= 0x04; /* if no DMA, set Status Sense */ } return 1; } if ( img->floppy_drive_get_flag_state( FLOPPY_DRIVE_INDEX ) ) { r++; if ( r >= 4 ) { /* time-out after 3 full revolutions */ LOG(( "%f mc6843_address_search: no sector %i found after 3 revolutions\n", machine().time().as_double(), m_SAR )); m_STRB |= 0x08; /* set Sector Address Undetected */ cmd_end( ); return 0; } } } //return 0; /* unreachable */ }
bool floppy_image_device::call_load() { io_generic io; // Do _not_ remove this cast otherwise the pointer will be incorrect when used by the ioprocs. io.file = (device_image_interface *)this; io.procs = &image_ioprocs; io.filler = 0xff; int best = 0; floppy_image_format_t *best_format = 0; for(floppy_image_format_t *format = fif_list; format; format = format->next) { int score = format->identify(&io, form_factor); if(score > best) { best = score; best_format = format; } } if(!best_format) { seterror(IMAGE_ERROR_INVALIDIMAGE, "Unable to identify the image format"); return IMAGE_INIT_FAIL; } image = global_alloc(floppy_image(tracks, sides, form_factor)); best_format->load(&io, form_factor, image); output_format = is_readonly() ? 0 : best_format; revolution_start_time = mon ? attotime::never : machine().time(); revolution_count = 0; index_resync(); image_dirty = false; wpt = 1; // disk sleeve is covering the sensor if (!cur_wpt_cb.isnull()) cur_wpt_cb(this, wpt); wpt = is_readonly() || (output_format == 0); if (!cur_wpt_cb.isnull()) cur_wpt_cb(this, wpt); if (!cur_load_cb.isnull()) return cur_load_cb(this); if(!mon) ready_counter = 2; return IMAGE_INIT_PASS; }
/* Seek bottom half */ void mc6843_device::finish_SEK( ) { legacy_floppy_image_device* img = floppy_image( ); /* seek to track */ // TODO: not sure how CTAR bit 7 is handled here, but this is the safest approach for now img->floppy_drive_seek( m_GCR - (m_CTAR & 0x7F) ); LOG(( "%f mc6843_finish_SEK: from %i to %i (actual=%i)\n", machine().time().as_double(), (m_CTAR & 0x7F), m_GCR, img->floppy_drive_get_current_track() )); /* update state */ m_CTAR = m_GCR; m_SAR = 0; cmd_end( ); }
/* Single / Multiple Sector Read bottom half */ void mc6843_device::cont_SR( ) { chrn_id id; legacy_floppy_image_device* img = floppy_image( ); /* sector seek */ if ( ! address_search_read( &id ) ) return; /* sector read */ img->floppy_drive_read_sector_data( m_side, id.data_id, m_data, 128 ); m_data_idx = 0; m_data_size = 128; m_STRA |= 0x01; /* set Data Transfer Request */ status_update( ); }
/* Seek Track Zero bottom half */ void mc6843_device::finish_STZ( ) { legacy_floppy_image_device* img = floppy_image( ); int i; /* seek to track zero */ for ( i=0; i<83; i++ ) { if (img->floppy_tk00_r() == CLEAR_LINE) break; img->floppy_drive_seek( -1 ); } LOG(( "%f mc6843_finish_STZ: actual=%i\n", machine().time().as_double(), img->floppy_drive_get_current_track() )); /* update state */ m_CTAR = 0; m_GCR = 0; m_SAR = 0; m_STRB |= img->floppy_tk00_r() << 4; cmd_end( ); }
legacy_floppy_image_device* mc6843_device::floppy_image( ) { return floppy_image( m_drive ); }
bool floppy_image_device::call_create(int format_type, option_resolution *format_options) { image = global_alloc(floppy_image(tracks, sides, form_factor)); output_format = 0; return IMAGE_INIT_PASS; }