src/mess/machine/wd17xx.c
| r6688 | r6689 | |
| 158 | 158 | #define STA_1_SEEK_ERR 0x10 /* seek error */ |
| 159 | 159 | #define STA_1_HD_LOADED 0x20 /* head loaded */ |
| 160 | 160 | #define STA_1_WRITE_PRO 0x40 /* floppy is write protected */ |
| 161 | | #define STA_1_NOT_READY 0x80 /* controller not ready */ |
| 161 | #define STA_1_NOT_READY 0x80 /* drive not ready */ |
| 162 | #define STA_1_MOTOR_ON 0x80 /* status of the Motor On output (WD1770 and WD1772 only) */ |
| 162 | 163 | |
| 163 | 164 | /* Type II and III additional flags */ |
| 164 | 165 | #define FDC_DELETED_AM 0x01 /* read/write deleted address mark */ |
| r6688 | r6689 | |
| 316 | 317 | INT8 direction; /* last step direction */ |
| 317 | 318 | |
| 318 | 319 | UINT8 status_drq; /* status register data request bit */ |
| 319 | | UINT8 status_ipl; /* status register toggle index pulse bit */ |
| 320 | 320 | UINT8 busy_count; /* how long to keep busy bit set */ |
| 321 | 321 | |
| 322 | 322 | UINT8 buffer[6144]; /* I/O buffer (holds up to a whole track) */ |
| r6688 | r6689 | |
| 335 | 335 | emu_timer *timer, *timer_rs, *timer_ws, *timer_rid; |
| 336 | 336 | int data_direction; |
| 337 | 337 | |
| 338 | | UINT8 ipl; /* index pulse */ |
| 339 | 338 | int hld_count; /* head loaded counter */ |
| 340 | 339 | |
| 341 | 340 | emu_timer *busy_timer; |
| r6688 | r6689 | |
| 807 | 806 | if (img != w->drive) |
| 808 | 807 | return; |
| 809 | 808 | |
| 810 | | w->ipl = state; |
| 809 | w->idx = state; |
| 811 | 810 | |
| 812 | 811 | if (w->hld_count) |
| 813 | 812 | w->hld_count--; |
| r6688 | r6689 | |
| 1288 | 1287 | READ8_DEVICE_HANDLER( wd17xx_status_r ) |
| 1289 | 1288 | { |
| 1290 | 1289 | wd1770_state *w = get_safe_token(device); |
| 1291 | | int result = w->status; |
| 1290 | int result; |
| 1292 | 1291 | |
| 1293 | 1292 | wd17xx_clear_intrq(device); |
| 1294 | 1293 | |
| 1294 | /* bit 7, 'not ready' or 'motor on' */ |
| 1295 | if (device->type == WD1770 || device->type == WD1772) |
| 1296 | { |
| 1297 | w->status &= ~STA_1_MOTOR_ON; |
| 1298 | w->status |= w->mo << 7; |
| 1299 | } |
| 1300 | else |
| 1301 | { |
| 1302 | w->status &= ~STA_1_NOT_READY; |
| 1303 | if (!floppy_drive_get_flag_state(w->drive, FLOPPY_DRIVE_READY)) |
| 1304 | w->status |= STA_1_NOT_READY; |
| 1305 | } |
| 1306 | |
| 1307 | result = w->status; |
| 1308 | |
| 1295 | 1309 | /* type 1 command or force int command? */ |
| 1296 | 1310 | if ((w->command_type==TYPE_I) || (w->command_type==TYPE_IV)) |
| 1297 | 1311 | { |
| 1298 | | /* toggle index pulse */ |
| 1299 | | result &= ~STA_1_IPL; |
| 1300 | | if (w->ipl) result |= STA_1_IPL; |
| 1312 | result &= ~(STA_1_IPL | STA_1_TRACK0); |
| 1301 | 1313 | |
| 1302 | | /* set track 0 state */ |
| 1303 | | result &=~STA_1_TRACK0; |
| 1304 | | if (floppy_tk00_r(w->drive) == CLEAR_LINE) |
| 1305 | | result |= STA_1_TRACK0; |
| 1314 | /* bit 1, index pulse */ |
| 1315 | result |= w->idx << 1; |
| 1306 | 1316 | |
| 1307 | | // floppy_drive_set_ready_state(w->drive, 1,1); |
| 1308 | | w->status &= ~STA_1_NOT_READY; |
| 1317 | /* bit 2, track 0 state, inverted */ |
| 1318 | result |= !floppy_tk00_r(w->drive) << 2; |
| 1309 | 1319 | |
| 1310 | | /* TODO: What is this? We need some more info on this */ |
| 1311 | | if ((w->type == WD_TYPE_179X) || (w->type == WD_TYPE_1793) || (w->type == WD_TYPE_1773) || (w->type == WD_TYPE_1771)) |
| 1312 | | { |
| 1313 | | if (!floppy_drive_get_flag_state(w->drive, FLOPPY_DRIVE_READY)) |
| 1314 | | w->status |= STA_1_NOT_READY; |
| 1315 | | } |
| 1316 | | else |
| 1317 | | { |
| 1318 | | if (floppy_drive_get_flag_state(w->drive, FLOPPY_DRIVE_READY)) |
| 1319 | | w->status |= STA_1_NOT_READY; |
| 1320 | | } |
| 1321 | | |
| 1322 | 1320 | if (w->command_type==TYPE_I) |
| 1323 | 1321 | { |
| 1324 | 1322 | if (w->hld_count) |
| r6688 | r6689 | |
| 1326 | 1324 | else |
| 1327 | 1325 | w->status &= ~ STA_1_HD_LOADED; |
| 1328 | 1326 | } |
| 1327 | |
| 1329 | 1328 | if (w->command_type==TYPE_IV) result &= 0x63; /* to allow microbee to boot up */ |
| 1330 | 1329 | } |
| 1331 | 1330 | |
| r6688 | r6689 | |
| 1445 | 1444 | { |
| 1446 | 1445 | wd1770_state *w = get_safe_token(device); |
| 1447 | 1446 | |
| 1448 | | floppy_mon_w(w->drive, CLEAR_LINE); |
| 1447 | /* only the WD1770 and WD1772 have a 'motor on' line */ |
| 1448 | if (device->type == WD1770 || device->type == WD1772) |
| 1449 | { |
| 1450 | w->mo = ASSERT_LINE; |
| 1451 | floppy_mon_w(w->drive, CLEAR_LINE); |
| 1452 | } |
| 1453 | |
| 1449 | 1454 | floppy_drive_set_ready_state(w->drive, 1,0); |
| 1450 | 1455 | |
| 1451 | 1456 | /* also cleared by writing command */ |