void disc_poll() { if (drives[curdrive].poll) drives[curdrive].poll(); if (disc_notfound) { disc_notfound--; if (!disc_notfound) fdc_notfound(); } }
void disc_poll() { disc_poll_time += disc_period * TIMER_USEC; if (drives[disc_drivesel].poll) drives[disc_drivesel].poll(); if (disc_notfound) { disc_notfound--; if (!disc_notfound) fdc_notfound(); } }
void disc_sector_poll() { sector_t *s; int data; if (cur_sector >= disc_sector_count[disc_sector_drive][disc_sector_side]) cur_sector = 0; if (cur_byte >= (128 << disc_sector_data[disc_sector_drive][disc_sector_side][cur_sector].n)) cur_byte = 0; s = &disc_sector_data[disc_sector_drive][disc_sector_side][cur_sector]; switch (disc_sector_state) { case STATE_IDLE: break; case STATE_READ_FIND_SECTOR: /* pclog("STATE_READ_FIND_SECTOR: cur_sector=%i cur_byte=%i sector=%i,%i side=%i,%i track=%i,%i period=%i,%i\n", cur_sector, cur_byte, disc_sector_sector, s->r, disc_sector_side, s->h, disc_sector_track, s->c, fdc_get_bitcell_period(), get_bitcell_period());*/ if (index_count > 1) { // pclog("Find sector not found\n"); fdc_notfound(); disc_sector_state = STATE_IDLE; break; } /* pclog("%i %i %i %i %i\n", cur_byte, disc_sector_track != s->c, disc_sector_side != s->h, disc_sector_sector != s->r, fdc_get_bitcell_period() != get_bitcell_period());*/ if (cur_byte || disc_sector_track != s->c || disc_sector_side != s->h || disc_sector_sector != s->r || disc_sector_n != s->n || fdc_get_bitcell_period() != get_bitcell_period() || !fdd_can_read_medium(disc_sector_drive ^ fdd_swap) || disc_intersector_delay) { advance_byte(); break; } disc_sector_state = STATE_READ_SECTOR; case STATE_READ_SECTOR: // pclog("STATE_READ_SECTOR: cur_byte=%i %i\n", cur_byte, disc_intersector_delay); if (fdc_data(s->data[cur_byte])) { // pclog("fdc_data failed\n"); return; } advance_byte(); if (!cur_byte) { disc_sector_state = STATE_IDLE; fdc_finishread(); } break; case STATE_READ_FIND_FIRST_SECTOR: if (!(fdd_can_read_medium(disc_sector_drive ^ fdd_swap))) { // pclog("Medium is of a density not supported by the drive\n"); fdc_notfound(); disc_sector_state = STATE_IDLE; break; } if (cur_byte || !index_count || fdc_get_bitcell_period() != get_bitcell_period() || disc_intersector_delay) { advance_byte(); break; } disc_sector_state = STATE_READ_FIRST_SECTOR; case STATE_READ_FIRST_SECTOR: if (fdc_data(s->data[cur_byte])) return; advance_byte(); if (!cur_byte) { disc_sector_state = STATE_IDLE; fdc_finishread(); } break; case STATE_READ_FIND_NEXT_SECTOR: if (!(fdd_can_read_medium(disc_sector_drive ^ fdd_swap))) { // pclog("Medium is of a density not supported by the drive\n"); fdc_notfound(); disc_sector_state = STATE_IDLE; break; } if (index_count) { // pclog("Find next sector hit end of track\n"); fdc_notfound(); disc_sector_state = STATE_IDLE; break; } if (cur_byte || fdc_get_bitcell_period() != get_bitcell_period() || disc_intersector_delay) { advance_byte(); break; } disc_sector_state = STATE_READ_NEXT_SECTOR; case STATE_READ_NEXT_SECTOR: if (fdc_data(s->data[cur_byte])) break; advance_byte(); if (!cur_byte) { disc_sector_state = STATE_IDLE; fdc_finishread(); } break; case STATE_WRITE_FIND_SECTOR: if (!(fdd_can_read_medium(disc_sector_drive ^ fdd_swap))) { // pclog("Medium is of a density not supported by the drive\n"); fdc_notfound(); disc_sector_state = STATE_IDLE; break; } if (writeprot[disc_sector_drive]) { fdc_writeprotect(); return; } if (index_count > 1) { // pclog("Write find sector not found\n"); fdc_notfound(); disc_sector_state = STATE_IDLE; break; } if (cur_byte || disc_sector_track != s->c || disc_sector_side != s->h || disc_sector_sector != s->r || disc_sector_n != s->n || fdc_get_bitcell_period() != get_bitcell_period() || disc_intersector_delay) { advance_byte(); break; } disc_sector_state = STATE_WRITE_SECTOR; case STATE_WRITE_SECTOR: data = fdc_getdata(cur_byte == ((128 << s->n) - 1)); if (data == -1) break; s->data[cur_byte] = data; advance_byte(); if (!cur_byte) { disc_sector_state = STATE_IDLE; disc_sector_writeback[disc_sector_drive](disc_sector_drive, disc_sector_track); fdc_finishread(); } break; case STATE_READ_FIND_ADDRESS: if (!(fdd_can_read_medium(disc_sector_drive ^ fdd_swap))) { // pclog("Medium is of a density not supported by the drive\n"); fdc_notfound(); disc_sector_state = STATE_IDLE; break; } if (index_count) { // pclog("Find next sector hit end of track\n"); fdc_notfound(); disc_sector_state = STATE_IDLE; break; } if (cur_byte || fdc_get_bitcell_period() != get_bitcell_period() || disc_intersector_delay) { advance_byte(); break; } disc_sector_state = STATE_READ_ADDRESS; case STATE_READ_ADDRESS: fdc_sectorid(s->c, s->h, s->r, s->n, 0, 0); disc_sector_state = STATE_IDLE; break; case STATE_FORMAT_FIND: if (writeprot[disc_sector_drive]) { fdc_writeprotect(); return; } if (!index_count || fdc_get_bitcell_period() != get_bitcell_period() || disc_intersector_delay) { advance_byte(); break; } if (!(fdd_can_read_medium(disc_sector_drive ^ fdd_swap))) { // pclog("Medium is of a density not supported by the drive\n"); fdc_notfound(); disc_sector_state = STATE_IDLE; break; } if (fdc_get_bitcell_period() != get_bitcell_period()) { fdc_notfound(); disc_sector_state = STATE_IDLE; break; } disc_sector_state = STATE_FORMAT; case STATE_FORMAT: if (!disc_intersector_delay && fdc_get_bitcell_period() == get_bitcell_period()) s->data[cur_byte] = disc_sector_fill; advance_byte(); if (index_count == 2) { disc_sector_writeback[disc_sector_drive](disc_sector_drive, disc_sector_track); fdc_finishread(); disc_sector_state = STATE_IDLE; } break; } }