src/mess/machine/conkort.c
| r6571 | r6572 | |
| 71 | 71 | |
| 72 | 72 | Slow Controller |
| 73 | 73 | --------------- |
| 74 | - FD1791 HLD/HLT callbacks |
| 75 | - copy protection device |
| 74 | 76 | - DS/DD SS/DS jumpers |
| 75 | 77 | - S1-S5 jumpers |
| 76 | | - protection device @ 8B |
| 77 | | - FDC DRQ |
| 78 | | - Z80 wait logic |
| 79 | 78 | |
| 80 | 79 | Fast Controller |
| 81 | 80 | --------------- |
| r6571 | r6572 | |
| 116 | 115 | UINT8 status; /* ABC BUS status */ |
| 117 | 116 | UINT8 data; /* ABC BUS data */ |
| 118 | 117 | int pio_ardy; /* PIO port A ready */ |
| 119 | | int fdc_irq; /* FDC interrupt */ |
| 118 | int fdc_irq; /* floppy interrupt */ |
| 119 | int fdc_drq; /* floppy data request */ |
| 120 | int fdc_dden; /* floppy density */ |
| 121 | int wait_enable; /* wait enable */ |
| 120 | 122 | |
| 121 | 123 | /* devices */ |
| 122 | 124 | const device_config *cpu; |
| r6571 | r6572 | |
| 256 | 258 | |
| 257 | 259 | bit description |
| 258 | 260 | |
| 259 | | 0 _SEL 0 |
| 260 | | 1 _SEL 1 |
| 261 | | 2 _SEL 2 |
| 262 | | 3 _MOT |
| 263 | | 4 _SIDE |
| 264 | | 5 8B pin 2 (if S4 shorted) |
| 265 | | 6 8A pin 13 |
| 261 | 0 SEL 0 |
| 262 | 1 SEL 1 |
| 263 | 2 SEL 2 |
| 264 | 3 MOT ON |
| 265 | 4 SIDE |
| 266 | 5 _PRECOMP ON |
| 267 | 6 _WAIT ENABLE |
| 266 | 268 | 7 FDC _MR |
| 267 | 269 | |
| 268 | 270 | */ |
| r6571 | r6572 | |
| 270 | 272 | slow_t *conkort = get_safe_token_machine_slow(space->machine); |
| 271 | 273 | |
| 272 | 274 | /* drive selection */ |
| 273 | | if (!BIT(data, 0)) wd17xx_set_drive(conkort->wd1791, 0); |
| 274 | | if (!BIT(data, 1)) wd17xx_set_drive(conkort->wd1791, 1); |
| 275 | | // if (!BIT(data, 2)) wd17xx_set_drive(conkort->wd1791, 2); |
| 275 | if (BIT(data, 0)) wd17xx_set_drive(conkort->wd1791, 0); |
| 276 | if (BIT(data, 1)) wd17xx_set_drive(conkort->wd1791, 1); |
| 277 | // if (BIT(data, 2)) wd17xx_set_drive(conkort->wd1791, 2); |
| 276 | 278 | |
| 277 | 279 | /* motor enable */ |
| 278 | | floppy_drive_set_motor_state(get_floppy_image(space->machine, 0), !BIT(data, 3)); |
| 279 | | floppy_drive_set_motor_state(get_floppy_image(space->machine, 1), !BIT(data, 3)); |
| 280 | floppy_drive_set_motor_state(get_floppy_image(space->machine, 0), BIT(data, 3)); |
| 281 | floppy_drive_set_motor_state(get_floppy_image(space->machine, 1), BIT(data, 3)); |
| 280 | 282 | floppy_drive_set_ready_state(get_floppy_image(space->machine, 0), 1, 1); |
| 281 | 283 | floppy_drive_set_ready_state(get_floppy_image(space->machine, 1), 1, 1); |
| 282 | 284 | |
| 283 | 285 | /* disk side selection */ |
| 284 | | wd17xx_set_side(conkort->wd1791,!BIT(data, 4)); |
| 286 | wd17xx_set_side(conkort->wd1791, BIT(data, 4)); |
| 285 | 287 | |
| 288 | /* wait enable */ |
| 289 | conkort->wait_enable = BIT(data, 6); |
| 290 | |
| 286 | 291 | if (!BIT(data, 7)) |
| 287 | 292 | { |
| 288 | 293 | /* FDC master reset */ |
| r6571 | r6572 | |
| 315 | 320 | cpu_set_input_line(conkort->cpu, INPUT_LINE_IRQ0, BIT(data, 7) ? ASSERT_LINE : CLEAR_LINE); |
| 316 | 321 | } |
| 317 | 322 | |
| 323 | static READ8_DEVICE_HANDLER( slow_fdc_r ) |
| 324 | { |
| 325 | slow_t *conkort = get_safe_token_machine_slow(device->machine); |
| 326 | UINT8 data = 0; |
| 327 | |
| 328 | switch (offset & 0x03) |
| 329 | { |
| 330 | case 0: data = wd17xx_status_r(device, 0); |
| 331 | case 1: data = wd17xx_track_r(device, 0); |
| 332 | case 2: data = wd17xx_sector_r(device, 0); |
| 333 | case 3: data = wd17xx_data_r(device, 0); |
| 334 | } |
| 335 | |
| 336 | if (!conkort->wait_enable && !conkort->fdc_irq && !conkort->fdc_drq) |
| 337 | { |
| 338 | logerror("WAIT\n"); |
| 339 | /* TODO: this is really connected to the Z80 _RDY line */ |
| 340 | cpu_set_input_line(conkort->cpu, INPUT_LINE_HALT, ASSERT_LINE); |
| 341 | } |
| 342 | |
| 343 | return data; |
| 344 | } |
| 345 | |
| 346 | static WRITE8_DEVICE_HANDLER( slow_fdc_w ) |
| 347 | { |
| 348 | slow_t *conkort = get_safe_token_machine_slow(device->machine); |
| 349 | |
| 350 | switch (offset & 0x03) |
| 351 | { |
| 352 | case 0: wd17xx_command_w(device, 0, data); break; |
| 353 | case 1: wd17xx_track_w(device, 0, data); break; |
| 354 | case 2: wd17xx_sector_w(device, 0, data); break; |
| 355 | case 3: wd17xx_data_w(device, 0, data); break; |
| 356 | } |
| 357 | |
| 358 | if (!conkort->wait_enable && !conkort->fdc_irq && !conkort->fdc_drq) |
| 359 | { |
| 360 | logerror("WAIT\n"); |
| 361 | /* TODO: this is really connected to the Z80 _RDY line */ |
| 362 | cpu_set_input_line(conkort->cpu, INPUT_LINE_HALT, ASSERT_LINE); |
| 363 | } |
| 364 | } |
| 365 | |
| 318 | 366 | /* Fast Controller */ |
| 319 | 367 | |
| 320 | 368 | static READ8_HANDLER( fast_bus_data_r ) |
| r6571 | r6572 | |
| 433 | 481 | |
| 434 | 482 | static ADDRESS_MAP_START( slow_io_map, ADDRESS_SPACE_IO, 8 ) |
| 435 | 483 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 436 | | AM_RANGE(0x7c, 0x7f) AM_DEVREADWRITE(Z80PIO_TAG, z80pio_alt_r, z80pio_alt_w) |
| 437 | | AM_RANGE(0xbc, 0xbf) AM_DEVREADWRITE(WD1791_TAG, wd17xx_r, wd17xx_w) |
| 438 | | AM_RANGE(0xdf, 0xdf) AM_WRITE(slow_status_w) |
| 439 | | AM_RANGE(0xef, 0xef) AM_WRITE(slow_ctrl_w) |
| 484 | AM_RANGE(0x70, 0x73) AM_MIRROR(0x0c) AM_DEVREADWRITE(Z80PIO_TAG, z80pio_alt_r, z80pio_alt_w) |
| 485 | AM_RANGE(0xb0, 0xb3) AM_MIRROR(0x0c) AM_DEVREADWRITE(WD1791_TAG, wd17xx_r, wd17xx_w) |
| 486 | AM_RANGE(0xd0, 0xd0) AM_MIRROR(0x0f) AM_WRITE(slow_status_w) |
| 487 | AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x0f) AM_WRITE(slow_ctrl_w) |
| 440 | 488 | ADDRESS_MAP_END |
| 441 | 489 | |
| 442 | 490 | // Fast Controller |
| r6571 | r6572 | |
| 454 | 502 | // AM_RANGE(0x30, 0x30) AM_MIRROR(0x0f) AM_WRITE() |
| 455 | 503 | // AM_RANGE(0x40, 0x40) AM_MIRROR(0x0f) AM_WRITE() |
| 456 | 504 | AM_RANGE(0x50, 0x50) AM_MIRROR(0x0f) AM_READ(fast_ctrl_r) |
| 457 | | AM_RANGE(0x60, 0x63) AM_MIRROR(0x0c) AM_DEVREAD(SAB1793_TAG, wd17xx_r) |
| 458 | | AM_RANGE(0x70, 0x73) AM_MIRROR(0x0c) AM_DEVWRITE(SAB1793_TAG, wd17xx_w) |
| 505 | AM_RANGE(0x60, 0x63) AM_MIRROR(0x0c) AM_DEVREAD(SAB1793_TAG, slow_fdc_r) |
| 506 | AM_RANGE(0x70, 0x73) AM_MIRROR(0x0c) AM_DEVWRITE(SAB1793_TAG, slow_fdc_w) |
| 459 | 507 | AM_RANGE(0x80, 0x80) AM_MIRROR(0x0f) AM_DEVREADWRITE(Z80DMA_TAG, z80dma_r, z80dma_w) |
| 460 | 508 | ADDRESS_MAP_END |
| 461 | 509 | |
| r6571 | r6572 | |
| 545 | 593 | |
| 546 | 594 | slow_t *conkort = get_safe_token_machine_slow(device->machine); |
| 547 | 595 | |
| 548 | | return conkort->fdc_irq << 7; |
| 596 | return conkort->fdc_irq << 7 | 0x10 | !conkort->fdc_dden << 2; |
| 549 | 597 | } |
| 550 | 598 | |
| 551 | 599 | static WRITE8_DEVICE_HANDLER( conkort_pio_port_b_w ) |
| r6571 | r6572 | |
| 557 | 605 | 0 !(_DS0 & _DS1) |
| 558 | 606 | 1 !(_DD0 & _DD1) |
| 559 | 607 | 2 8B pin 10 |
| 560 | | 3 FDC DDEN |
| 608 | 3 FDC _DDEN |
| 561 | 609 | 4 _R/BS |
| 562 | 610 | 5 FDC HLT |
| 563 | 611 | 6 FDC _HDLD |
| r6571 | r6572 | |
| 565 | 613 | |
| 566 | 614 | */ |
| 567 | 615 | |
| 616 | slow_t *conkort = get_safe_token_machine_slow(device->machine); |
| 617 | |
| 618 | /* disk density */ |
| 619 | wd17xx_set_density(conkort->wd1791, BIT(data, 3) ? DEN_FM_HI : DEN_FM_LO); |
| 620 | conkort->fdc_dden = BIT(data, 3); |
| 568 | 621 | } |
| 569 | 622 | |
| 570 | 623 | static WRITE_LINE_DEVICE_HANDLER( conkort_pio_ardy_w ) |
| r6571 | r6572 | |
| 662 | 715 | slow_t *conkort = get_safe_token_machine_slow(device->machine); |
| 663 | 716 | |
| 664 | 717 | conkort->fdc_irq = state; |
| 718 | |
| 719 | if (state) |
| 720 | { |
| 721 | /* TODO: this is really connected to the Z80 _RDY line */ |
| 722 | cpu_set_input_line(conkort->cpu, INPUT_LINE_HALT, CLEAR_LINE); |
| 723 | } |
| 665 | 724 | } |
| 666 | 725 | |
| 726 | static WRITE_LINE_DEVICE_HANDLER( slow_wd1791_drq_w ) |
| 727 | { |
| 728 | slow_t *conkort = get_safe_token_machine_slow(device->machine); |
| 729 | |
| 730 | conkort->fdc_drq = state; |
| 731 | |
| 732 | if (state) |
| 733 | { |
| 734 | /* TODO: this is really connected to the Z80 _RDY line */ |
| 735 | cpu_set_input_line(conkort->cpu, INPUT_LINE_HALT, CLEAR_LINE); |
| 736 | } |
| 737 | } |
| 738 | |
| 667 | 739 | static const wd17xx_interface slow_wd17xx_interface = |
| 668 | 740 | { |
| 669 | 741 | DEVCB_LINE(slow_wd1791_intrq_w), |
| 670 | | DEVCB_NULL, |
| 742 | DEVCB_LINE(slow_wd1791_drq_w), |
| 671 | 743 | { FLOPPY_0, FLOPPY_1, NULL, NULL } |
| 672 | 744 | }; |
| 673 | 745 | |
| r6571 | r6572 | |
| 769 | 841 | state_save_register_device_item(device, 0, conkort->data); |
| 770 | 842 | state_save_register_device_item(device, 0, conkort->pio_ardy); |
| 771 | 843 | state_save_register_device_item(device, 0, conkort->fdc_irq); |
| 844 | state_save_register_device_item(device, 0, conkort->fdc_drq); |
| 845 | state_save_register_device_item(device, 0, conkort->fdc_dden); |
| 846 | state_save_register_device_item(device, 0, conkort->wait_enable); |
| 772 | 847 | } |
| 773 | 848 | |
| 774 | 849 | /*------------------------------------------------- |