trunk/src/emu/bus/ieee488/c2040fdc.c
| r242339 | r242340 | |
| 427 | 427 | |
| 428 | 428 | UINT8 data = (BIT(e, 6) << 7) | (BIT(i, 7) << 6) | (e & 0x33) | (BIT(e, 2) << 3) | (i & 0x04); |
| 429 | 429 | |
| 430 | | if (LOG) logerror("%s VIA reads data %02x (%03x)\n", machine().time().as_string(), data, checkpoint_live.shift_reg); |
| 430 | if (LOG) logerror("%s %s VIA reads data %02x (%03x)\n", machine().time().as_string(), machine().describe_context(), data, checkpoint_live.shift_reg); |
| 431 | 431 | |
| 432 | 432 | return data; |
| 433 | 433 | } |
| r242339 | r242340 | |
| 439 | 439 | live_sync(); |
| 440 | 440 | m_pi = cur_live.pi = data; |
| 441 | 441 | checkpoint(); |
| 442 | | if (LOG) logerror("%s PI %02x\n", machine().time().as_string(), data); |
| 442 | if (LOG) logerror("%s %s PI %02x\n", machine().time().as_string(), machine().describe_context(), data); |
| 443 | 443 | live_run(); |
| 444 | 444 | } |
| 445 | 445 | } |
| r242339 | r242340 | |
| 451 | 451 | live_sync(); |
| 452 | 452 | m_drv_sel = cur_live.drv_sel = state; |
| 453 | 453 | checkpoint(); |
| 454 | | if (LOG) logerror("%s DRV SEL %u\n", machine().time().as_string(), state); |
| 454 | if (LOG) logerror("%s %s DRV SEL %u\n", machine().time().as_string(), machine().describe_context(), state); |
| 455 | 455 | live_run(); |
| 456 | 456 | } |
| 457 | 457 | } |
| r242339 | r242340 | |
| 463 | 463 | live_sync(); |
| 464 | 464 | m_mode_sel = cur_live.mode_sel = state; |
| 465 | 465 | checkpoint(); |
| 466 | | if (LOG) logerror("%s MODE SEL %u\n", machine().time().as_string(), state); |
| 466 | if (LOG) logerror("%s %s MODE SEL %u\n", machine().time().as_string(), machine().describe_context(), state); |
| 467 | 467 | live_run(); |
| 468 | 468 | } |
| 469 | 469 | } |
| r242339 | r242340 | |
| 475 | 475 | live_sync(); |
| 476 | 476 | m_rw_sel = cur_live.rw_sel = state; |
| 477 | 477 | checkpoint(); |
| 478 | | if (LOG) logerror("%s RW SEL %u\n", machine().time().as_string(), state); |
| 478 | if (LOG) logerror("%s %s RW SEL %u\n", machine().time().as_string(), machine().describe_context(), state); |
| 479 | 479 | if (m_rw_sel) { |
| 480 | 480 | stop_writing(machine().time()); |
| 481 | 481 | } else { |
| r242339 | r242340 | |
| 491 | 491 | { |
| 492 | 492 | live_sync(); |
| 493 | 493 | m_mtr0 = state; |
| 494 | | if (LOG) logerror("%s MTR0 %u\n", machine().time().as_string(), state); |
| 494 | if (LOG) logerror("%s %s MTR0 %u\n", machine().time().as_string(), machine().describe_context(), state); |
| 495 | 495 | m_floppy0->mon_w(state); |
| 496 | 496 | checkpoint(); |
| 497 | 497 | |
| r242339 | r242340 | |
| 513 | 513 | { |
| 514 | 514 | live_sync(); |
| 515 | 515 | m_mtr1 = state; |
| 516 | | if (LOG) logerror("%s MTR1 %u\n", machine().time().as_string(), state); |
| 516 | if (LOG) logerror("%s %s MTR1 %u\n", machine().time().as_string(), machine().describe_context(), state); |
| 517 | 517 | if (m_floppy1) m_floppy1->mon_w(state); |
| 518 | 518 | checkpoint(); |
| 519 | 519 | |
| r242339 | r242340 | |
| 587 | 587 | { |
| 588 | 588 | live_sync(); |
| 589 | 589 | m_ds = cur_live.ds = ds; |
| 590 | if (LOG) logerror("%s %s DS %u\n", machine().time().as_string(), machine().describe_context(), ds); |
| 590 | 591 | checkpoint(); |
| 591 | 592 | live_run(); |
| 592 | 593 | } |
trunk/src/emu/bus/ieee488/c8050fdc.c
| r242339 | r242340 | |
| 17 | 17 | // MACROS / CONSTANTS |
| 18 | 18 | //************************************************************************** |
| 19 | 19 | |
| 20 | | #define LOG 0 |
| 20 | #define LOG 1 |
| 21 | 21 | |
| 22 | #define GCR_DECODE(_e, _i) \ |
| 23 | ((BIT(_e, 6) << 7) | (BIT(_i, 7) << 6) | (_e & 0x33) | (BIT(_e, 2) << 3) | (_i & 0x04)) |
| 22 | 24 | |
| 25 | #define GCR_ENCODE(_e, _i) \ |
| 26 | ((_e & 0xc0) << 2 | (_i & 0x80) | (_e & 0x3c) << 1 | (_i & 0x04) | (_e & 0x03)) |
| 23 | 27 | |
| 28 | |
| 29 | |
| 24 | 30 | //************************************************************************** |
| 25 | 31 | // DEVICE DEFINITIONS |
| 26 | 32 | //************************************************************************** |
| r242339 | r242340 | |
| 72 | 78 | m_ds(0), |
| 73 | 79 | m_drv_sel(0), |
| 74 | 80 | m_mode_sel(0), |
| 75 | | m_rw_sel(0), |
| 76 | | m_period(attotime::from_hz(clock)) |
| 81 | m_rw_sel(0) |
| 77 | 82 | { |
| 78 | 83 | cur_live.tm = attotime::never; |
| 79 | 84 | cur_live.state = IDLE; |
| r242339 | r242340 | |
| 169 | 174 | if (m_stp0 != stp) |
| 170 | 175 | { |
| 171 | 176 | live_sync(); |
| 172 | | this->stp_w(m_floppy0, m_mtr0, m_stp0, stp); |
| 177 | stp_w(m_floppy0, m_mtr0, m_stp0, stp); |
| 173 | 178 | checkpoint(); |
| 174 | 179 | live_run(); |
| 175 | 180 | } |
| r242339 | r242340 | |
| 180 | 185 | if (m_stp1 != stp) |
| 181 | 186 | { |
| 182 | 187 | live_sync(); |
| 183 | | if (m_floppy1) this->stp_w(m_floppy1, m_mtr1, m_stp1, stp); |
| 188 | if (m_floppy1) stp_w(m_floppy1, m_mtr1, m_stp1, stp); |
| 184 | 189 | checkpoint(); |
| 185 | 190 | live_run(); |
| 186 | 191 | } |
| r242339 | r242340 | |
| 192 | 197 | { |
| 193 | 198 | live_sync(); |
| 194 | 199 | m_ds = cur_live.ds = ds; |
| 200 | pll_reset(cur_live.tm, attotime::from_hz(clock() / (16 - m_ds))); |
| 195 | 201 | checkpoint(); |
| 196 | 202 | live_run(); |
| 197 | 203 | } |
| r242339 | r242340 | |
| 220 | 226 | cur_live.rw_sel = m_rw_sel; |
| 221 | 227 | cur_live.pi = m_pi; |
| 222 | 228 | |
| 223 | | pll_reset(cur_live.tm, attotime::from_double(0)); |
| 229 | pll_reset(cur_live.tm, attotime::from_hz(clock() / (16 - m_ds))); |
| 224 | 230 | checkpoint_live = cur_live; |
| 225 | 231 | pll_save_checkpoint(); |
| 226 | 232 | |
| r242339 | r242340 | |
| 281 | 287 | pll_retrieve_checkpoint(); |
| 282 | 288 | } |
| 283 | 289 | |
| 290 | void c8050_fdc_t::live_delay(int state) |
| 291 | { |
| 292 | cur_live.next_state = state; |
| 293 | if(cur_live.tm != machine().time()) |
| 294 | t_gen->adjust(cur_live.tm - machine().time()); |
| 295 | else |
| 296 | live_sync(); |
| 297 | } |
| 298 | |
| 284 | 299 | void c8050_fdc_t::live_sync() |
| 285 | 300 | { |
| 286 | 301 | if(!cur_live.tm.is_never()) { |
| r242339 | r242340 | |
| 322 | 337 | cur_live.error = 1; |
| 323 | 338 | } |
| 324 | 339 | |
| 325 | | |
| 326 | 340 | void c8050_fdc_t::live_run(const attotime &limit) |
| 327 | 341 | { |
| 328 | 342 | if(cur_live.state == IDLE || cur_live.next_state != -1) |
| r242339 | r242340 | |
| 340 | 354 | if(bit < 0) |
| 341 | 355 | return; |
| 342 | 356 | |
| 357 | cur_live.shift_reg <<= 1; |
| 358 | cur_live.shift_reg |= bit; |
| 359 | cur_live.shift_reg &= 0x3ff; |
| 360 | |
| 361 | // sync |
| 362 | int sync = !((cur_live.shift_reg == 0x3ff) && cur_live.rw_sel); |
| 363 | |
| 364 | // bit counter |
| 365 | if (cur_live.rw_sel) { |
| 366 | if (!sync) { |
| 367 | cur_live.bit_counter = 0; |
| 368 | } else if (cur_live.sync) { |
| 369 | cur_live.bit_counter++; |
| 370 | if (cur_live.bit_counter == 10) { |
| 371 | cur_live.bit_counter = 0; |
| 372 | } |
| 373 | } |
| 374 | } else { |
| 375 | cur_live.bit_counter++; |
| 376 | if (cur_live.bit_counter == 10) { |
| 377 | cur_live.bit_counter = 0; |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | // GCR decoder |
| 382 | if (cur_live.rw_sel) { |
| 383 | cur_live.i = cur_live.shift_reg; |
| 384 | } else { |
| 385 | cur_live.i = ((cur_live.pi & 0xf0) << 1) | (cur_live.mode_sel << 4) | (cur_live.pi & 0x0f); |
| 386 | } |
| 387 | |
| 388 | cur_live.e = m_gcr_rom->base()[cur_live.rw_sel << 10 | cur_live.i]; |
| 389 | |
| 390 | if (LOG) logerror("%s cyl %u bit %u sync %u bc %u sr %03x i %03x e %02x\n",cur_live.tm.as_string(),get_floppy()->get_cyl(),bit,sync,cur_live.bit_counter,cur_live.shift_reg,cur_live.i,cur_live.e); |
| 391 | |
| 392 | // byte ready |
| 393 | int ready = !(cur_live.bit_counter == 9); |
| 394 | |
| 395 | // GCR error |
| 396 | int error = !(ready || BIT(cur_live.e, 3)); |
| 397 | |
| 398 | // write bit |
| 399 | if (!cur_live.rw_sel) { // TODO WPS |
| 400 | int write_bit = BIT(cur_live.shift_reg_write, 9); |
| 401 | if (LOG) logerror("%s writing bit %u sr %03x\n",cur_live.tm.as_string(),write_bit,cur_live.shift_reg_write); |
| 402 | pll_write_next_bit(write_bit, cur_live.tm, get_floppy(), limit); |
| 403 | } |
| 404 | |
| 405 | if (!ready) { |
| 406 | // load write shift register |
| 407 | cur_live.shift_reg_write = GCR_ENCODE(cur_live.e, cur_live.i); |
| 408 | |
| 409 | if (LOG) logerror("%s load write shift register %03x\n",cur_live.tm.as_string(),cur_live.shift_reg_write); |
| 410 | } else { |
| 411 | // clock write shift register |
| 412 | cur_live.shift_reg_write <<= 1; |
| 413 | cur_live.shift_reg_write &= 0x3ff; |
| 414 | } |
| 415 | |
| 416 | if (ready != cur_live.ready) { |
| 417 | if (LOG) logerror("%s READY %u : %02x\n", cur_live.tm.as_string(),ready,GCR_DECODE(cur_live.e, cur_live.i)); |
| 418 | cur_live.ready = ready; |
| 419 | syncpoint = true; |
| 420 | } |
| 421 | |
| 422 | if (sync != cur_live.sync) { |
| 423 | if (LOG) logerror("%s SYNC %u\n", cur_live.tm.as_string(),sync); |
| 424 | cur_live.sync = sync; |
| 425 | syncpoint = true; |
| 426 | } |
| 427 | |
| 428 | if (error != cur_live.error) { |
| 429 | if (LOG) logerror("%s ERROR %u\n", cur_live.tm.as_string(),error); |
| 430 | cur_live.error = error; |
| 431 | syncpoint = true; |
| 432 | } |
| 433 | |
| 343 | 434 | if (syncpoint) { |
| 344 | 435 | live_delay(RUNNING_SYNCPOINT); |
| 345 | 436 | return; |
| r242339 | r242340 | |
| 367 | 458 | |
| 368 | 459 | UINT8 data = (BIT(e, 6) << 7) | (BIT(i, 7) << 6) | (e & 0x33) | (BIT(e, 2) << 3) | (i & 0x04); |
| 369 | 460 | |
| 370 | | if (LOG) logerror("%s VIA reads data %02x (%03x)\n", machine().time().as_string(), data, checkpoint_live.shift_reg); |
| 461 | if (LOG) logerror("%s %s VIA reads data %02x (%03x)\n", machine().time().as_string(), machine().describe_context(), data, checkpoint_live.shift_reg); |
| 371 | 462 | |
| 372 | 463 | return data; |
| 373 | 464 | } |
| r242339 | r242340 | |
| 379 | 470 | live_sync(); |
| 380 | 471 | m_pi = cur_live.pi = data; |
| 381 | 472 | checkpoint(); |
| 382 | | if (LOG) logerror("%s PI %02x\n", machine().time().as_string(), data); |
| 473 | if (LOG) logerror("%s %s PI %02x\n", machine().time().as_string(), machine().describe_context(), data); |
| 383 | 474 | live_run(); |
| 384 | 475 | } |
| 385 | 476 | } |
| r242339 | r242340 | |
| 391 | 482 | live_sync(); |
| 392 | 483 | m_drv_sel = cur_live.drv_sel = state; |
| 393 | 484 | checkpoint(); |
| 394 | | if (LOG) logerror("%s DRV SEL %u\n", machine().time().as_string(), state); |
| 485 | if (LOG) logerror("%s %s DRV SEL %u\n", machine().time().as_string(), machine().describe_context(), state); |
| 395 | 486 | live_run(); |
| 396 | 487 | } |
| 397 | 488 | } |
| r242339 | r242340 | |
| 403 | 494 | live_sync(); |
| 404 | 495 | m_mode_sel = cur_live.mode_sel = state; |
| 405 | 496 | checkpoint(); |
| 406 | | if (LOG) logerror("%s MODE SEL %u\n", machine().time().as_string(), state); |
| 497 | if (LOG) logerror("%s %s MODE SEL %u\n", machine().time().as_string(), machine().describe_context(), state); |
| 407 | 498 | live_run(); |
| 408 | 499 | } |
| 409 | 500 | } |
| r242339 | r242340 | |
| 415 | 506 | live_sync(); |
| 416 | 507 | m_rw_sel = cur_live.rw_sel = state; |
| 417 | 508 | checkpoint(); |
| 418 | | if (LOG) logerror("%s RW SEL %u\n", machine().time().as_string(), state); |
| 509 | if (LOG) logerror("%s %s RW SEL %u\n", machine().time().as_string(), machine().describe_context(), state); |
| 419 | 510 | if (m_rw_sel) { |
| 420 | 511 | pll_stop_writing(get_floppy(), machine().time()); |
| 421 | 512 | } else { |
| r242339 | r242340 | |
| 431 | 522 | { |
| 432 | 523 | live_sync(); |
| 433 | 524 | m_mtr0 = state; |
| 434 | | if (LOG) logerror("%s MTR0 %u\n", machine().time().as_string(), state); |
| 525 | if (LOG) logerror("%s %s MTR0 %u\n", machine().time().as_string(), machine().describe_context(), state); |
| 435 | 526 | m_floppy0->mon_w(state); |
| 436 | 527 | checkpoint(); |
| 437 | 528 | |
| r242339 | r242340 | |
| 453 | 544 | { |
| 454 | 545 | live_sync(); |
| 455 | 546 | m_mtr1 = state; |
| 456 | | if (LOG) logerror("%s MTR1 %u\n", machine().time().as_string(), state); |
| 547 | if (LOG) logerror("%s %s MTR1 %u\n", machine().time().as_string(), machine().describe_context(), state); |
| 457 | 548 | if (m_floppy1) m_floppy1->mon_w(state); |
| 458 | 549 | checkpoint(); |
| 459 | 550 | |
| r242339 | r242340 | |
| 475 | 566 | { |
| 476 | 567 | live_sync(); |
| 477 | 568 | m_odd_hd = cur_live.odd_hd = state; |
| 478 | | if (LOG) logerror("%s ODD HD %u\n", machine().time().as_string(), state); |
| 569 | if (LOG) logerror("%s %s ODD HD %u\n", machine().time().as_string(), machine().describe_context(), state); |
| 479 | 570 | m_floppy0->ss_w(!state); |
| 480 | 571 | if (m_floppy1) m_floppy1->ss_w(!state); |
| 481 | 572 | checkpoint(); |
| r242339 | r242340 | |
| 486 | 577 | WRITE_LINE_MEMBER( c8050_fdc_t::pull_sync_w ) |
| 487 | 578 | { |
| 488 | 579 | // TODO |
| 489 | | if (LOG) logerror("%s PULL SYNC %u\n", machine().time().as_string(), state); |
| 580 | if (LOG) logerror("%s %s PULL SYNC %u\n", machine().time().as_string(), machine().describe_context(), state); |
| 490 | 581 | } |