/* motor on, active low */ void floppy_image_device::mon_w(int state) { if(mon == state) return; mon = state; /* off -> on */ if (!mon && image) { revolution_start_time = machine().time(); ready_counter = 2; index_resync(); } /* on -> off */ else { if(image_dirty) commit_image(); revolution_start_time = attotime::never; index_timer->adjust(attotime::zero); if(!ready) { ready = true; if(!cur_ready_cb.isnull()) cur_ready_cb(this, ready); } } }
void floppy_image_device::call_unload() { dskchg = 0; if (image) { if(image_dirty) commit_image(); global_free(image); image = 0; } wpt = 1; // disk sleeve is covering the sensor if (!cur_wpt_cb.isnull()) cur_wpt_cb(this, wpt); wpt = 0; // sensor is uncovered if (!cur_wpt_cb.isnull()) cur_wpt_cb(this, wpt); if (!cur_unload_cb.isnull()) cur_unload_cb(this); if(!ready) { ready = true; if(!cur_ready_cb.isnull()) cur_ready_cb(this, ready); } }
void floppy_image_device::device_reset() { revolution_start_time = attotime::never; revolution_count = 0; mon = 1; if(!ready) { ready = true; if(!cur_ready_cb.isnull()) cur_ready_cb(this, ready); } if(motor_always_on) mon_w(0); }
void floppy_image_device::call_unload() { dskchg = 0; if (image) { if(image_dirty) commit_image(); global_free(image); image = 0; } if (!cur_unload_cb.isnull()) cur_unload_cb(this); if(!ready) { ready = true; if(!cur_ready_cb.isnull()) cur_ready_cb(this, ready); } }
/* index pulses at rpm/60 Hz, and stays high for ~2ms at 300rpm */ void floppy_image_device::index_resync() { if(revolution_start_time.is_never()) { if(idx) { idx = 0; if (!cur_index_pulse_cb.isnull()) cur_index_pulse_cb(this, idx); } return; } attotime delta = machine().time() - revolution_start_time; while(delta >= rev_time) { delta -= rev_time; revolution_start_time += rev_time; revolution_count++; } int position = (delta*floppy_ratio_1).as_ticks(1000000000/1000); int new_idx = position < 20000; if(new_idx) { attotime index_up_time = attotime::from_nsec((2000000*1000)/floppy_ratio_1); index_timer->adjust(index_up_time - delta); } else index_timer->adjust(rev_time - delta); if(new_idx != idx) { idx = new_idx; if(idx && ready) { ready_counter--; if(!ready_counter) { ready = false; if(!cur_ready_cb.isnull()) cur_ready_cb(this, ready); } } if (!cur_index_pulse_cb.isnull()) cur_index_pulse_cb(this, idx); } }