Previous 15994 Revisions Next

r6222 Friday 30th October, 2009 at 16:16:54 UTC by Dirk Best
[UPD765] Some fixes to avoid crashes when accessing unconnected drives
[src/mess/machine]upd765.c

src/mess/machine/upd765.c
r6221r6222
295295   const device_config *img = current_image(device);
296296   upd765_t *fdc = get_safe_token(device);
297297
298   if (!img)
299      return;
300
301298   fdc->pcn[fdc->drive] = fdc->ncn;
302299
303300   /* drive ready? */
304   if (floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY))
301   if (img != NULL && floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY))
305302   {
306303      /* yes */
307304
r6221r6222
505502
506503   fdc->FDC_main |= (1<<fdc->drive);
507504   fdc->FDC_main |= 0x20;  // execution phase
508   fdc->FDC_main &= ~0x10;  // not busy, can send another seek/recalibrate
505   fdc->FDC_main &= ~0x10;  // not busy, can send another seek/recalibrate
509506                            // for a different drive, or sense int status
510507
511508   /* recalibrate command? */
r6221r6222
516513      fdc->ncn = 0;
517514
518515      /* if drive is already at track 0, or drive is not ready */
519      if (
520         floppy_drive_get_flag_state(img, FLOPPY_DRIVE_HEAD_AT_TRACK_0) ||
516      if (img == NULL || floppy_drive_get_flag_state(img, FLOPPY_DRIVE_HEAD_AT_TRACK_0) ||
521517         (!floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY))
522518         )
523519      {
r6221r6222
572568      signed_tracks = fdc->ncn - fdc->pcn[fdc->drive];
573569
574570      /* if no tracks to seek, or drive is not ready, seek is complete */
575      if ((signed_tracks==0) || (!floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY)))
571      if (img == NULL || (signed_tracks==0) || (!floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY)))
576572      {
577573         upd765_seek_complete(device);
578574      }
r6221r6222
782778   }
783779}
784780
785READ8_DEVICE_HANDLER(upd765_status_r)
781READ8_DEVICE_HANDLER( upd765_status_r )
786782{
787783   upd765_t *fdc = get_safe_token(device);
788784   if (LOG_EXTRA)
789      logerror("upd765 status r: %02x\n",fdc->FDC_main);
785      logerror("%s: upd765_status_r: %02x\n", cpuexec_describe_context(device->machine), fdc->FDC_main);
790786   return fdc->FDC_main;
791787}
792788
r6221r6222
16791675      fdc->FDC_main |= 0x10;                      /* set BUSY */
16801676
16811677      if (LOG_VERBOSE)
1682         logerror("upd765(): pc=0x%08x command=0x%02x\n", cpu_get_pc(device->machine->firstcpu), fdc->upd765_data_reg);
1678         logerror("%s: upd765(): command=0x%02x\n", cpuexec_describe_context(device->machine), fdc->upd765_data_reg);
16831679
16841680      /* seek in progress? */
16851681      if (fdc->upd765_flags & UPD765_SEEK_ACTIVE)
r6221r6222
17111707
17121708    case UPD765_COMMAND_PHASE_BYTES:
17131709      if (LOG_VERBOSE)
1714         logerror("upd765(): pc=0x%08x command=0x%02x\n", cpu_get_pc(device->machine->firstcpu), fdc->upd765_data_reg);
1710         logerror("%s: upd765(): command=0x%02x\n", cpuexec_describe_context(device->machine), fdc->upd765_data_reg);
17151711
17161712      fdc->upd765_command_bytes[fdc->upd765_transfer_bytes_count] = fdc->upd765_data_reg;
17171713      fdc->upd765_transfer_bytes_count++;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team