Previous 199869 Revisions Next

r19241 Saturday 1st December, 2012 at 14:57:14 UTC by O. Galibert
floppy: Enhance ready support [O. Galibert]
[src/emu/imagedev]floppy.c floppy.h

trunk/src/emu/imagedev/floppy.h
r19240r19241
4949   typedef delegate<int (floppy_image_device *)> load_cb;
5050   typedef delegate<void (floppy_image_device *)> unload_cb;
5151   typedef delegate<void (floppy_image_device *, int)> index_pulse_cb;
52   typedef delegate<void (floppy_image_device *, int)> ready_cb;
5253
5354   // construction/destruction
5455   floppy_image_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
r19240r19241
8384   void setup_load_cb(load_cb cb);
8485   void setup_unload_cb(unload_cb cb);
8586   void setup_index_pulse_cb(index_pulse_cb cb);
87   void setup_ready_cb(ready_cb cb);
8688
8789   UINT32* get_buffer() { return image->get_buffer(cyl, ss); }
8890   UINT32 get_len() { return image->get_track_size(cyl, ss); }
r19240r19241
149151   int wpt;  /* write protect */
150152   int rdy;  /* ready */
151153   int dskchg;     /* disk changed */
154   bool ready;
152155
153156   /* rotation per minute => gives index pulse frequency */
154157   float rpm;
r19240r19241
158161   int cyl;
159162
160163   bool image_dirty;
164   int ready_counter;
161165
162166   load_cb cur_load_cb;
163167   unload_cb cur_unload_cb;
164168   index_pulse_cb cur_index_pulse_cb;
169   ready_cb cur_ready_cb;
165170
166171   UINT32 find_position(attotime &base, attotime when);
167172   int find_index(UINT32 position, const UINT32 *buf, int buf_size);
trunk/src/emu/imagedev/floppy.c
r19240r19241
108108   cur_index_pulse_cb = cb;
109109}
110110
111void floppy_image_device::setup_ready_cb(ready_cb cb)
112{
113   cur_ready_cb = cb;
114}
115
111116void floppy_image_device::set_formats(const floppy_format_type *formats)
112117{
113118   image_device_format **formatptr;
r19240r19241
205210   dskchg = exists() ? 1 : 0;
206211   index_timer = timer_alloc(0);
207212   image_dirty = false;
213   ready = true;
214   ready_counter = 0;
208215}
209216
210217void floppy_image_device::device_reset()
r19240r19241
212219   revolution_start_time = attotime::never;
213220   revolution_count = 0;
214221   mon = 1;
222   if(!ready) {
223      ready = true;
224      if(!cur_ready_cb.isnull())
225         cur_ready_cb(this, ready);
226   }
215227   if(motor_always_on)
216228      mon_w(0);
217229}
r19240r19241
280292
281293   if (!cur_load_cb.isnull())
282294      return cur_load_cb(this);
295
296   if(motor_always_on || !mon)
297      ready_counter = 2;
298
283299   return IMAGE_INIT_PASS;
284300}
285301
r19240r19241
295311   }
296312   if (!cur_unload_cb.isnull())
297313      cur_unload_cb(this);
314   if(!ready) {
315      ready = true;
316      if(!cur_ready_cb.isnull())
317         cur_ready_cb(this, ready);
318   }
298319}
299320
300321bool floppy_image_device::call_create(int format_type, option_resolution *format_options)
r19240r19241
316337   if (!mon && image)
317338   {
318339      revolution_start_time = machine().time();
340      ready_counter = 2;
319341      index_resync();
320342   }
321343
r19240r19241
325347         commit_image();
326348      revolution_start_time = attotime::never;
327349      index_timer->adjust(attotime::zero);
350      if(!ready) {
351         ready = true;
352         if(!cur_ready_cb.isnull())
353            cur_ready_cb(this, ready);
354      }
328355   }
329356}
330357
r19240r19241
365392
366393   if(new_idx != idx) {
367394      idx = new_idx;
368
395      if(idx && ready) {
396         ready_counter--;
397         if(!ready_counter) {
398            ready = false;
399            if(!cur_ready_cb.isnull())
400               cur_ready_cb(this, ready);
401         }
402      }
369403      if (!cur_index_pulse_cb.isnull())
370404         cur_index_pulse_cb(this, idx);
371405   }
r19240r19241
373407
374408bool floppy_image_device::ready_r()
375409{
376   if (exists())
377   {
378      if (mon == 0)
379      {
380         return 0;
381      }
382   }
383   return 1;
410   return ready;
384411}
385412
386413double floppy_image_device::get_pos()

Previous 199869 Revisions Next


© 1997-2024 The MAME Team