src/mess/drivers/super80.c
| r3472 | r3473 | |
| 8 | 8 | #include "devices/cassette.h" |
| 9 | 9 | #include "devices/z80bin.h" |
| 10 | 10 | #include "sound/speaker.h" |
| 11 | #include "machine/centroni.h" |
| 12 | #include "devices/printer.h" |
| 11 | 13 | |
| 12 | 14 | static UINT8 super80_mhz=2; /* state of bit 2 of port F0 */ |
| 13 | 15 | static UINT16 vidpg=0xfe00; /* Home position of video page being displayed */ |
| r3472 | r3473 | |
| 414 | 416 | |
| 415 | 417 | static UINT8 cass_data[]={ 0, 0, 0, 0 }; |
| 416 | 418 | |
| 417 | | /* this timer runs at 200khz and does 1 job: |
| 418 | | 1. Emulate the 2 chips in the cassette input circuit |
| 419 | /* This timer runs at 200khz and emulates the 2 chips in the cassette input circuit |
| 420 | They are U79 CD4046BCN PLL chip and U1 LM311P op-amp. U79 converts a frequency to a voltage, |
| 421 | and U1 amplifies that voltage to digital levels. U1 has a trimpot connected, to set the midpoint. |
| 419 | 422 | |
| 420 | | Reasons why it is necessary: |
| 421 | | 1. This "emulates" U79 CD4046BCN PLL chip and U1 LM311P op-amp. U79 converts a frequency to a voltage, |
| 422 | | and U1 amplifies that voltage to digital levels. U1 has a trimpot connected, to set the midpoint. */ |
| 423 | The MDS homebrew input circuit consists of 2 op-amps followed by a D-flipflop. |
| 424 | My "read-any-system" cassette circuit was a CA3140 op-amp, the smarts being done in software. |
| 423 | 425 | |
| 426 | bit 0 = original system (U79 and U1) |
| 427 | bit 1 = MDS fast system |
| 428 | bit 2 = CA3140 */ |
| 429 | |
| 424 | 430 | static TIMER_CALLBACK( super80_timer ) |
| 425 | 431 | { |
| 426 | 432 | UINT8 cass_ws=0; |
| r3472 | r3473 | |
| 430 | 436 | |
| 431 | 437 | if (cass_ws != cass_data[0]) |
| 432 | 438 | { |
| 433 | | if (cass_ws) cass_data[3] ^= 2; |
| 439 | if (cass_ws) cass_data[3] ^= 2; // the MDS flipflop |
| 434 | 440 | cass_data[0] = cass_ws; |
| 435 | 441 | cass_data[2] = ((cass_data[1] < 0x40) ? 1 : 0) | cass_ws | cass_data[3]; |
| 436 | 442 | cass_data[1] = 0; |
| 437 | 443 | } |
| 438 | 444 | } |
| 439 | 445 | |
| 446 | /*************************************** PRINTER ********************************************************/ |
| 447 | |
| 448 | /* The Super80 had an optional I/O card that plugged into the S-100 slot. The card had facility for running |
| 449 | an 8-bit Centronics printer, and a serial device at 300, 600, or 1200 baud. The I/O address range |
| 450 | was selectable via 4 dipswitches. The serial parameters (baud rate, parity, stop bits, etc) was |
| 451 | chosen with more dipswitches. Regretably, no parameters could be set by software. Currently, the |
| 452 | Centronics printer is emulated; the serial side of things may be done later, as will the dipswitches. |
| 453 | |
| 454 | The most commonly used I/O range is DC-DE (DC = centronics, DD = serial data, DE = serial control |
| 455 | All the home-brew roms use this, except for super80e which uses BC-BE (which we don't support yet). */ |
| 456 | |
| 457 | static void super80_printer_handshake_in(int number, int data, int mask) |
| 458 | { |
| 459 | if (mask & CENTRONICS_ACKNOWLEDGE) |
| 460 | { |
| 461 | if (data & CENTRONICS_ACKNOWLEDGE) |
| 462 | { |
| 463 | } |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | static const CENTRONICS_CONFIG super80_cent_config[1]={ |
| 468 | { |
| 469 | PRINTER_CENTRONICS, |
| 470 | super80_printer_handshake_in |
| 471 | }, |
| 472 | }; |
| 473 | |
| 474 | static const device_config *printer_device(running_machine *machine) |
| 475 | { |
| 476 | return device_list_find_by_tag(machine->config->devicelist, PRINTER, "printer"); |
| 477 | } |
| 478 | |
| 479 | |
| 440 | 480 | /**************************** I/O PORTS *****************************************************************/ |
| 441 | 481 | |
| 442 | 482 | static READ8_HANDLER( super80v_11_r ) |
| r3472 | r3473 | |
| 447 | 487 | return 0; |
| 448 | 488 | } |
| 449 | 489 | |
| 490 | static READ8_HANDLER( super80_dc_r ) |
| 491 | { |
| 492 | UINT8 data=0x7f; |
| 493 | |
| 494 | /* bit 7 = printer busy |
| 495 | 0 = printer is not busy */ |
| 496 | |
| 497 | if (printer_is_ready(printer_device(machine))==0 ) |
| 498 | data |= 0x80; |
| 499 | |
| 500 | return data; |
| 501 | } |
| 502 | |
| 450 | 503 | static READ8_HANDLER( super80_f2_r ) |
| 451 | 504 | { |
| 452 | 505 | UINT8 data = input_port_read(machine, "DSW") & 0xf0; // dip switches on pcb |
| 453 | | data |= cass_data[2]; // bit 0 = output of U1, bit 2 = current wave_state |
| 506 | data |= cass_data[2]; // bit 0 = output of U1, bit 1 = MDS cass state, bit 2 = current wave_state |
| 454 | 507 | data |= 0x08; // bit 3 - not used |
| 455 | 508 | return data; |
| 456 | 509 | } |
| r3472 | r3473 | |
| 467 | 520 | if ((mc6845_ind > 8) && (mc6845_ind < 12)) mc6845_cursor_configure(); /* adjust cursor shape */ |
| 468 | 521 | } |
| 469 | 522 | |
| 523 | static WRITE8_HANDLER( super80_dc_w ) |
| 524 | { |
| 525 | /* hardware strobe driven from port select, bit 7..0 = data */ |
| 526 | centronics_write_handshake(0, CENTRONICS_SELECT | CENTRONICS_NO_RESET, CENTRONICS_SELECT| CENTRONICS_NO_RESET); |
| 527 | centronics_write_handshake(0, 1, CENTRONICS_STROBE); |
| 528 | centronics_write_data(0, data); |
| 529 | centronics_write_handshake(0, 0, CENTRONICS_STROBE); |
| 530 | } |
| 531 | |
| 470 | 532 | static UINT8 last_data; |
| 471 | 533 | |
| 472 | 534 | static WRITE8_HANDLER( super80_f0_w ) |
| r3472 | r3473 | |
| 476 | 538 | if (bits & 0x20) set_led_status(2,(data & 32) ? 0 : 1); /* bit 5 - LED - scroll lock led is used */ |
| 477 | 539 | speaker_level_w(0, (data & 8) ? 0 : 1); /* bit 3 - speaker */ |
| 478 | 540 | super80_mhz = (data & 4) ? 1 : 2; /* bit 2 - video on/off */ |
| 479 | | if (bits & 0x02) cassette_motor( machine, data & 2 ? 1 : 0); /* bit 1 - cassette motor */ |
| 480 | | if (bits & 0x01) cassette_output(cassette_device_image(machine), (data & 1) ? -1.0 : +1.0); /* bit 0 - cass out */ |
| 541 | if (bits & 2) cassette_motor( machine, data & 2 ? 1 : 0); /* bit 1 - cassette motor */ |
| 542 | if (bits & 1) cassette_output(cassette_device_image(machine), (data & 1) ? -1.0 : +1.0); /* bit 0 - cass out */ |
| 481 | 543 | |
| 482 | 544 | last_data = data; |
| 483 | 545 | } |
| r3472 | r3473 | |
| 488 | 550 | |
| 489 | 551 | if (bits & 0x20) set_led_status(2,(data & 32) ? 0 : 1); /* bit 5 - LED - scroll lock led is used */ |
| 490 | 552 | speaker_level_w(0, (data & 8) ? 0 : 1); /* bit 3 - speaker */ |
| 491 | | if (bits & 0x02) cassette_motor( machine, data & 2 ? 1 : 0); /* bit 1 - cassette motor */ |
| 492 | | if (bits & 0x01) cassette_output(cassette_device_image(machine), (data & 1) ? -1.0 : +1.0); /* bit 0 - cass out */ |
| 553 | if (bits & 2) cassette_motor( machine, data & 2 ? 1 : 0); /* bit 1 - cassette motor */ |
| 554 | if (bits & 1) cassette_output(cassette_device_image(machine), (data & 1) ? -1.0 : +1.0); /* bit 0 - cass out */ |
| 493 | 555 | |
| 494 | 556 | last_data = data; |
| 495 | 557 | } |
| r3472 | r3473 | |
| 502 | 564 | super80v_rom_pcg = data & 0x10; /* bit 4 - bankswitch gfx rom or pcg */ |
| 503 | 565 | speaker_level_w(0, (data & 8) ? 0 : 1); /* bit 3 - speaker */ |
| 504 | 566 | super80v_vid_col = data & 4; /* bit 2 - bankswitch video or colour ram */ |
| 505 | | if (bits & 0x02) cassette_motor( machine, data & 2 ? 1 : 0); /* bit 1 - cassette motor */ |
| 506 | | if (bits & 0x01) cassette_output(cassette_device_image(machine), (data & 1) ? -1.0 : +1.0); /* bit 0 - cass out */ |
| 567 | if (bits & 2) cassette_motor( machine, data & 2 ? 1 : 0); /* bit 1 - cassette motor */ |
| 568 | if (bits & 1) cassette_output(cassette_device_image(machine), (data & 1) ? -1.0 : +1.0); /* bit 0 - cass out */ |
| 507 | 569 | |
| 508 | 570 | last_data = data; |
| 509 | 571 | } |
| r3472 | r3473 | |
| 553 | 615 | static ADDRESS_MAP_START( super80_io, ADDRESS_SPACE_IO, 8 ) |
| 554 | 616 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 555 | 617 | ADDRESS_MAP_UNMAP_HIGH |
| 618 | AM_RANGE(0xdc, 0xdc) AM_READWRITE(super80_dc_r, super80_dc_w) |
| 556 | 619 | AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x14) AM_WRITE(super80_f0_w) |
| 557 | 620 | AM_RANGE(0xe1, 0xe1) AM_MIRROR(0x14) AM_WRITE(super80_f1_w) |
| 558 | 621 | AM_RANGE(0xe2, 0xe2) AM_MIRROR(0x14) AM_READ(super80_f2_r) |
| r3472 | r3473 | |
| 567 | 630 | ADDRESS_MAP_UNMAP_HIGH |
| 568 | 631 | AM_RANGE(0x10, 0x10) AM_WRITE(super80v_10_w) |
| 569 | 632 | AM_RANGE(0x11, 0x11) AM_READWRITE(super80v_11_r, super80v_11_w) |
| 633 | AM_RANGE(0xdc, 0xdc) AM_READWRITE(super80_dc_r, super80_dc_w) |
| 570 | 634 | AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x14) AM_WRITE(super80r_f0_w) |
| 571 | 635 | AM_RANGE(0xe2, 0xe2) AM_MIRROR(0x14) AM_READ(super80_f2_r) |
| 572 | 636 | AM_RANGE(0xf8, 0xf8) AM_MIRROR(0x04) AM_READWRITE(super80_f8_r,super80_f8_w) |
| r3472 | r3473 | |
| 580 | 644 | ADDRESS_MAP_UNMAP_HIGH |
| 581 | 645 | AM_RANGE(0x10, 0x10) AM_WRITE(super80v_10_w) |
| 582 | 646 | AM_RANGE(0x11, 0x11) AM_READWRITE(super80v_11_r, super80v_11_w) |
| 647 | AM_RANGE(0xdc, 0xdc) AM_READWRITE(super80_dc_r, super80_dc_w) |
| 583 | 648 | AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x14) AM_WRITE(super80v_f0_w) |
| 584 | 649 | AM_RANGE(0xe2, 0xe2) AM_MIRROR(0x14) AM_READ(super80_f2_r) |
| 585 | 650 | AM_RANGE(0xf8, 0xf8) AM_MIRROR(0x04) AM_READWRITE(super80_f8_r,super80_f8_w) |
| r3472 | r3473 | |
| 935 | 1000 | static MACHINE_RESET( super80 ) |
| 936 | 1001 | { |
| 937 | 1002 | super80_z80pio = device_list_find_by_tag( machine->config->devicelist, Z80PIO, "z80pio" ); |
| 1003 | centronics_config(0, super80_cent_config); |
| 1004 | /* assumption: select is tied low */ |
| 1005 | centronics_write_handshake(0, CENTRONICS_SELECT | CENTRONICS_NO_RESET, CENTRONICS_SELECT| CENTRONICS_NO_RESET); |
| 938 | 1006 | timer_set(ATTOTIME_IN_USEC(10), NULL, 0, super80_reset); |
| 939 | 1007 | memory_set_bank(1, 1); |
| 940 | 1008 | } |
| r3472 | r3473 | |
| 974 | 1042 | MDRV_SOUND_ADD("speaker", SPEAKER, 0) |
| 975 | 1043 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 976 | 1044 | |
| 1045 | /* printer */ |
| 1046 | MDRV_DEVICE_ADD("printer", PRINTER) |
| 1047 | |
| 977 | 1048 | /* quickload */ |
| 978 | 1049 | MDRV_Z80BIN_QUICKLOAD_ADD(default, 1) |
| 979 | 1050 | |
| r3472 | r3473 | |
| 1027 | 1098 | MDRV_SOUND_ADD("speaker", SPEAKER, 0) |
| 1028 | 1099 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 1029 | 1100 | |
| 1101 | /* printer */ |
| 1102 | MDRV_DEVICE_ADD("printer", PRINTER) |
| 1103 | |
| 1030 | 1104 | /* quickload */ |
| 1031 | 1105 | MDRV_Z80BIN_QUICKLOAD_ADD(default, 1) |
| 1032 | 1106 | |