Previous 15994 Revisions Next

r5999 Wednesday 7th October, 2009 at 15:52:03 UTC by Dirk Best
[FLOPPY] Connect track 0 callback
[src/mess/devices]flopdrv.c

src/mess/devices/flopdrv.c
r5998r5999
3939   devcb_resolved_write_line out_wpt_func;
4040   devcb_resolved_write_line out_rdy_func;
4141
42   /* state of output lines */
43   int idx;  /* index pulse */
44   int tk00; /* track 00 */
45   int wpt;  /* write protect */
46   int rdy;  /* ready */
47
4248   const floppy_config   *config;
4349
4450   /* flags */
r5998r5999
5763   void   (*index_pulse_callback)(const device_config *controller,const device_config *image, int state);
5864   /* rotation per minute => gives index pulse frequency */
5965   float rpm;
60   /* current index pulse value */
61   int index;
6266
6367   void   (*ready_state_change_callback)(const device_config *controller,const device_config *img, int state);
6468
r5998r5999
262266   pDrive->index_pulse_callback = NULL;
263267   pDrive->ready_state_change_callback = NULL;
264268   pDrive->index_timer = timer_alloc(img->machine, floppy_drive_index_callback, (void *) img);
265   pDrive->index = 0;
269   pDrive->idx = 0;
266270
267271   floppy_drive_set_geometry(img, ((floppy_config*)img->static_config)->floppy_type);
268272
r5998r5999
284288/* index pulses at rpm/60 Hz, and stays high 1/20th of time */
285289static void floppy_drive_index_func(const device_config *img)
286290{
287   floppy_drive *pDrive = get_safe_token( img );
291   floppy_drive *drive = get_safe_token( img );
288292
289   double ms = 1000. / (pDrive->rpm / 60.);
293   double ms = 1000.0 / (drive->rpm / 60.0);
290294
291   if (pDrive->index)
295   if (drive->idx)
292296   {
293      pDrive->index = 0;
294      timer_adjust_oneshot(pDrive->index_timer, double_to_attotime(ms*19/20/1000.0), 0);
297      drive->idx = 0;
298      timer_adjust_oneshot(drive->index_timer, double_to_attotime(ms*19/20/1000.0), 0);
295299   }
296300   else
297301   {
298      pDrive->index = 1;
299      timer_adjust_oneshot(pDrive->index_timer, double_to_attotime(ms/20/1000.0), 0);
302      drive->idx = 1;
303      timer_adjust_oneshot(drive->index_timer, double_to_attotime(ms/20/1000.0), 0);
300304   }
301305
302   devcb_call_write_line(&pDrive->out_idx_func, pDrive->index);
306   devcb_call_write_line(&drive->out_idx_func, drive->idx);
303307
304   if (pDrive->index_pulse_callback)
305      pDrive->index_pulse_callback(pDrive->controller, img, pDrive->index);
308   if (drive->index_pulse_callback)
309      drive->index_pulse_callback(drive->controller, img, drive->idx);
306310}
307311
308312static TIMER_CALLBACK(floppy_drive_index_callback)
r5998r5999
361365      if (flag & FLOPPY_DRIVE_READY)
362366      {
363367         /* trigger state change callback */
364         devcb_call_write_line(&drv->out_rdy_func, new_state);
368         devcb_call_write_line(&drv->out_rdy_func, new_state ? ASSERT_LINE : CLEAR_LINE);
365369
366370         if (drv->ready_state_change_callback)
367371            drv->ready_state_change_callback(drv->controller, img, new_state);
r5998r5999
403407      {
404408         floppy_drive *pDrive = get_safe_token( img );
405409
406         pDrive->index = 0;
410         pDrive->idx = 0;
407411         if (new_motor_state)
408412         {
409413            /* off->on */
r5998r5999
520524   }
521525
522526   /* set track 0 flag */
527   pDrive->tk00 = ASSERT_LINE;
523528   pDrive->flags &= ~FLOPPY_DRIVE_HEAD_AT_TRACK_0;
524529
525530   if (pDrive->current_track==0)
526531   {
532      pDrive->tk00 = CLEAR_LINE;
527533      pDrive->flags |= FLOPPY_DRIVE_HEAD_AT_TRACK_0;
528534   }
529535
536   devcb_call_write_line(&pDrive->out_tk00_func, pDrive->tk00);
537
530538   /* inform disk image of step operation so it can cache information */
531539   if (image_exists(img))
532540      flopimg_seek_callback(img, pDrive->current_track);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team