src/mess/machine/wd17xx.c
| r7620 | r7621 | |
| 119 | 119 | |
| 120 | 120 | This should probably be considdered a minor hack but it does seem to work ! |
| 121 | 121 | |
| 122 | | 2009-02-04 Phill Harvey-Smith |
| 122 | 2010-02-04 Phill Harvey-Smith |
| 123 | 123 | - Added multiple sector write as the RM Nimbus needs it. |
| 124 | 124 | |
| 125 | 2010-March-22 Curt Coder: |
| 126 | - Implemented immediate and index pulse interrupts. |
| 127 | |
| 125 | 128 | TODO: |
| 126 | 129 | - Multiple record write |
| 127 | 130 | - What happens if a track is read that doesn't have any id's on it? |
| r7620 | r7621 | |
| 140 | 143 | CONSTANTS |
| 141 | 144 | ***************************************************************************/ |
| 142 | 145 | |
| 143 | | #define VERBOSE 1 /* General logging */ |
| 146 | #define VERBOSE 0 /* General logging */ |
| 144 | 147 | #define VERBOSE_DATA 0 /* Logging of each byte during read and write */ |
| 145 | 148 | |
| 146 | 149 | #define DELAY_ERROR 3 |
| r7620 | r7621 | |
| 296 | 299 | UINT8 sector; |
| 297 | 300 | UINT8 command; |
| 298 | 301 | UINT8 status; |
| 302 | UINT8 interrupt; |
| 299 | 303 | |
| 300 | 304 | int stepping_rate[4]; /* track stepping rate in ms */ |
| 301 | 305 | |
| r7620 | r7621 | |
| 822 | 826 | |
| 823 | 827 | w->idx = state; |
| 824 | 828 | |
| 829 | if (!state && w->idx && BIT(w->interrupt, 2)) |
| 830 | wd17xx_set_intrq(controller); |
| 831 | |
| 825 | 832 | if (w->hld_count) |
| 826 | 833 | w->hld_count--; |
| 827 | 834 | } |
| r7620 | r7621 | |
| 1231 | 1238 | { |
| 1232 | 1239 | wd1770_state *w = get_safe_token(device); |
| 1233 | 1240 | w->idx = state; |
| 1241 | |
| 1242 | if (!state && w->idx && BIT(w->interrupt, 2)) |
| 1243 | wd17xx_set_intrq(device); |
| 1234 | 1244 | } |
| 1235 | 1245 | |
| 1236 | 1246 | /* write protect status */ |
| r7620 | r7621 | |
| 1274 | 1284 | wd1770_state *w = get_safe_token(device); |
| 1275 | 1285 | int result; |
| 1276 | 1286 | |
| 1277 | | wd17xx_clear_intrq(device); |
| 1287 | if (!BIT(w->interrupt, 3)) |
| 1288 | { |
| 1289 | wd17xx_clear_intrq(device); |
| 1290 | } |
| 1278 | 1291 | |
| 1279 | 1292 | /* bit 7, 'not ready' or 'motor on' */ |
| 1280 | 1293 | if (device->type == WD1770 || device->type == WD1772) |
| r7620 | r7621 | |
| 1438 | 1451 | |
| 1439 | 1452 | floppy_drive_set_ready_state(w->drive, 1,0); |
| 1440 | 1453 | |
| 1441 | | /* also cleared by writing command */ |
| 1442 | | wd17xx_clear_intrq(device); |
| 1454 | if (!BIT(w->interrupt, 3)) |
| 1455 | { |
| 1456 | wd17xx_clear_intrq(device); |
| 1457 | } |
| 1443 | 1458 | |
| 1444 | 1459 | /* clear write protected. On read sector, read track and read dam, write protected bit is clear */ |
| 1445 | 1460 | w->status &= ~((1<<6) | (1<<5) | (1<<4)); |
| r7620 | r7621 | |
| 1456 | 1471 | |
| 1457 | 1472 | wd17xx_clear_drq(device); |
| 1458 | 1473 | |
| 1459 | | if (data & 0x0f) |
| 1474 | if (!BIT(w->interrupt, 3) && BIT(data, 3)) |
| 1460 | 1475 | { |
| 1476 | /* set immediate interrupt */ |
| 1477 | wd17xx_set_intrq(device); |
| 1478 | } |
| 1461 | 1479 | |
| 1462 | | |
| 1463 | | |
| 1480 | if (BIT(w->interrupt, 3)) |
| 1481 | { |
| 1482 | if (data == FDC_FORCE_INT) |
| 1483 | { |
| 1484 | /* clear immediate interrupt */ |
| 1485 | w->interrupt = data & 0x0f; |
| 1486 | } |
| 1487 | else |
| 1488 | { |
| 1489 | /* keep immediate interrupt */ |
| 1490 | w->interrupt = 0x08 | (data & 0x07); |
| 1491 | } |
| 1464 | 1492 | } |
| 1493 | else |
| 1494 | { |
| 1495 | w->interrupt = data & 0x0f; |
| 1496 | } |
| 1465 | 1497 | |
| 1498 | /* terminate command */ |
| 1499 | wd17xx_complete_command(device, DELAY_ERROR); |
| 1466 | 1500 | |
| 1467 | 1501 | // w->status_ipl = STA_1_IPL; |
| 1468 | 1502 | /* w->status_ipl = 0; */ |