src/mess/machine/upd765.c
| r6221 | r6222 | |
| 295 | 295 | const device_config *img = current_image(device); |
| 296 | 296 | upd765_t *fdc = get_safe_token(device); |
| 297 | 297 | |
| 298 | | if (!img) |
| 299 | | return; |
| 300 | | |
| 301 | 298 | fdc->pcn[fdc->drive] = fdc->ncn; |
| 302 | 299 | |
| 303 | 300 | /* 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)) |
| 305 | 302 | { |
| 306 | 303 | /* yes */ |
| 307 | 304 | |
| r6221 | r6222 | |
| 505 | 502 | |
| 506 | 503 | fdc->FDC_main |= (1<<fdc->drive); |
| 507 | 504 | 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 |
| 509 | 506 | // for a different drive, or sense int status |
| 510 | 507 | |
| 511 | 508 | /* recalibrate command? */ |
| r6221 | r6222 | |
| 516 | 513 | fdc->ncn = 0; |
| 517 | 514 | |
| 518 | 515 | /* 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) || |
| 521 | 517 | (!floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY)) |
| 522 | 518 | ) |
| 523 | 519 | { |
| r6221 | r6222 | |
| 572 | 568 | signed_tracks = fdc->ncn - fdc->pcn[fdc->drive]; |
| 573 | 569 | |
| 574 | 570 | /* 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))) |
| 576 | 572 | { |
| 577 | 573 | upd765_seek_complete(device); |
| 578 | 574 | } |
| r6221 | r6222 | |
| 782 | 778 | } |
| 783 | 779 | } |
| 784 | 780 | |
| 785 | | READ8_DEVICE_HANDLER(upd765_status_r) |
| 781 | READ8_DEVICE_HANDLER( upd765_status_r ) |
| 786 | 782 | { |
| 787 | 783 | upd765_t *fdc = get_safe_token(device); |
| 788 | 784 | 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); |
| 790 | 786 | return fdc->FDC_main; |
| 791 | 787 | } |
| 792 | 788 | |
| r6221 | r6222 | |
| 1679 | 1675 | fdc->FDC_main |= 0x10; /* set BUSY */ |
| 1680 | 1676 | |
| 1681 | 1677 | 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); |
| 1683 | 1679 | |
| 1684 | 1680 | /* seek in progress? */ |
| 1685 | 1681 | if (fdc->upd765_flags & UPD765_SEEK_ACTIVE) |
| r6221 | r6222 | |
| 1711 | 1707 | |
| 1712 | 1708 | case UPD765_COMMAND_PHASE_BYTES: |
| 1713 | 1709 | 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); |
| 1715 | 1711 | |
| 1716 | 1712 | fdc->upd765_command_bytes[fdc->upd765_transfer_bytes_count] = fdc->upd765_data_reg; |
| 1717 | 1713 | fdc->upd765_transfer_bytes_count++; |