diff --git a/src/emu/imagedev/floppy.c b/src/emu/imagedev/floppy.c index f3a0cf4da2b..7af494c3775 100644 --- a/src/emu/imagedev/floppy.c +++ b/src/emu/imagedev/floppy.c @@ -108,6 +108,11 @@ void floppy_image_device::setup_index_pulse_cb(index_pulse_cb cb) cur_index_pulse_cb = cb; } +void floppy_image_device::setup_ready_cb(ready_cb cb) +{ + cur_ready_cb = cb; +} + void floppy_image_device::set_formats(const floppy_format_type *formats) { image_device_format **formatptr; @@ -205,6 +210,8 @@ void floppy_image_device::device_start() dskchg = exists() ? 1 : 0; index_timer = timer_alloc(0); image_dirty = false; + ready = true; + ready_counter = 0; } void floppy_image_device::device_reset() @@ -212,6 +219,11 @@ 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); } @@ -280,6 +292,10 @@ bool floppy_image_device::call_load() if (!cur_load_cb.isnull()) return cur_load_cb(this); + + if(motor_always_on || !mon) + ready_counter = 2; + return IMAGE_INIT_PASS; } @@ -295,6 +311,11 @@ void floppy_image_device::call_unload() } if (!cur_unload_cb.isnull()) cur_unload_cb(this); + if(!ready) { + ready = true; + if(!cur_ready_cb.isnull()) + cur_ready_cb(this, ready); + } } bool floppy_image_device::call_create(int format_type, option_resolution *format_options) @@ -316,6 +337,7 @@ void floppy_image_device::mon_w(int state) if (!mon && image) { revolution_start_time = machine().time(); + ready_counter = 2; index_resync(); } @@ -325,6 +347,11 @@ void floppy_image_device::mon_w(int state) 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); + } } } @@ -365,7 +392,14 @@ void floppy_image_device::index_resync() 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); } @@ -373,14 +407,7 @@ void floppy_image_device::index_resync() bool floppy_image_device::ready_r() { - if (exists()) - { - if (mon == 0) - { - return 0; - } - } - return 1; + return ready; } double floppy_image_device::get_pos() diff --git a/src/emu/imagedev/floppy.h b/src/emu/imagedev/floppy.h index 1d104eb49e3..67751c658e7 100644 --- a/src/emu/imagedev/floppy.h +++ b/src/emu/imagedev/floppy.h @@ -49,6 +49,7 @@ public: typedef delegate load_cb; typedef delegate unload_cb; typedef delegate index_pulse_cb; + typedef delegate ready_cb; // construction/destruction floppy_image_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock); @@ -83,6 +84,7 @@ public: void setup_load_cb(load_cb cb); void setup_unload_cb(unload_cb cb); void setup_index_pulse_cb(index_pulse_cb cb); + void setup_ready_cb(ready_cb cb); UINT32* get_buffer() { return image->get_buffer(cyl, ss); } UINT32 get_len() { return image->get_track_size(cyl, ss); } @@ -149,6 +151,7 @@ protected: int wpt; /* write protect */ int rdy; /* ready */ int dskchg; /* disk changed */ + bool ready; /* rotation per minute => gives index pulse frequency */ float rpm; @@ -158,10 +161,12 @@ protected: int cyl; bool image_dirty; + int ready_counter; load_cb cur_load_cb; unload_cb cur_unload_cb; index_pulse_cb cur_index_pulse_cb; + ready_cb cur_ready_cb; UINT32 find_position(attotime &base, attotime when); int find_index(UINT32 position, const UINT32 *buf, int buf_size);