src/mess/drivers/pcw.c
| r9671 | r9672 | |
| 130 | 130 | static UINT8 pcw_printer_command; |
| 131 | 131 | static UINT8 pcw_printer_data; |
| 132 | 132 | static UINT8 pcw_printer_status; |
| 133 | static UINT8 pcw_printer_headpos; // non-zero if not at left margin |
| 133 | 134 | |
| 134 | 135 | static UINT16 pcw_kb_scan_row; |
| 135 | 136 | |
| r9671 | r9672 | |
| 385 | 386 | /* check interrupts */ |
| 386 | 387 | pcw_update_irqs(space->machine); |
| 387 | 388 | /* return data */ |
| 388 | | LOG(("SYS: IRQ counter read, returning %02x\n",data)); |
| 389 | //LOG(("SYS: IRQ counter read, returning %02x\n",data)); |
| 389 | 390 | return data; |
| 390 | 391 | } |
| 391 | 392 | |
| r9671 | r9672 | |
| 677 | 678 | { |
| 678 | 679 | pcw_printer_data = data; |
| 679 | 680 | upi41_master_w(space->machine->device("printer_mcu"),0,data); |
| 680 | | logerror("PRN: Sent data %02x\n",data); |
| 681 | logerror("PRN [0xFC]: Sent command %02x\n",data); |
| 681 | 682 | } |
| 682 | 683 | |
| 683 | 684 | static WRITE8_HANDLER(pcw_printer_command_w) |
| 684 | 685 | { |
| 685 | 686 | pcw_printer_command = data; |
| 686 | 687 | upi41_master_w(space->machine->device("printer_mcu"),1,data); |
| 687 | | logerror("PRN: Sent command %02x\n",data); |
| 688 | logerror("PRN [0xFD]: Sent command %02x\n",data); |
| 688 | 689 | } |
| 689 | 690 | |
| 691 | // print error type |
| 692 | // should return 0xF8 if there are no errors |
| 693 | // 0 = underrun |
| 694 | // 1 = printer controller RAM fault |
| 695 | // 3 = bad command |
| 696 | // 5 = print error |
| 697 | // anything else = no printer |
| 690 | 698 | static READ8_HANDLER(pcw_printer_data_r) |
| 691 | 699 | { |
| 692 | | // pcw_printer_data = 0xf8; |
| 693 | | pcw_printer_data = upi41_master_r(space->machine->device("printer_mcu"),0); |
| 694 | | return pcw_printer_data; |
| 700 | return upi41_master_r(space->machine->device("printer_mcu"),0); |
| 695 | 701 | } |
| 696 | 702 | |
| 703 | // printer status |
| 704 | // bit 7 - bail bar in |
| 705 | // bit 6 - not currently executing a command |
| 706 | // bit 5 - always 0 for dot matrix printer (PCW8256/8512), 1 if a daisywheel printer(PCW9512) |
| 707 | // bit 4 - print head is not at left margin |
| 708 | // bit 3 - sheet feeder is present |
| 709 | // bit 2 - paper is present |
| 710 | // bit 1 - busy |
| 711 | // bit 0 - controller fault |
| 697 | 712 | static READ8_HANDLER(pcw_printer_status_r) |
| 698 | 713 | { |
| 699 | | pcw_printer_status = upi41_master_r(space->machine->device("printer_mcu"),1); |
| 700 | | return pcw_printer_status; |
| 714 | return upi41_master_r(space->machine->device("printer_mcu"),1); |
| 701 | 715 | } |
| 702 | 716 | |
| 703 | | #ifdef UNUSED_FUNCTION |
| 704 | 717 | /* MCU handlers */ |
| 705 | | static READ8_HANDLER(mcu_printer_data_r) |
| 718 | static READ8_HANDLER(mcu_printer_p1_r) |
| 706 | 719 | { |
| 707 | | return pcw_printer_data; |
| 720 | // logerror("PRN: MCU reading data from P1\n"); |
| 721 | return 0x00; |
| 708 | 722 | } |
| 709 | 723 | |
| 710 | | static WRITE8_HANDLER(mcu_printer_data_w) |
| 724 | static WRITE8_HANDLER(mcu_printer_p1_w) |
| 711 | 725 | { |
| 712 | | pcw_printer_data = data; |
| 726 | logerror("PRN: MCU writing %02x to P1\n",data); |
| 713 | 727 | } |
| 714 | | #endif |
| 715 | 728 | |
| 716 | | static READ8_HANDLER(mcu_printer_command_r) |
| 729 | static READ8_HANDLER(mcu_printer_p2_r) |
| 717 | 730 | { |
| 718 | | return pcw_printer_command; |
| 731 | UINT8 ret = 0x00; |
| 732 | // logerror("PRN: MCU reading data from P2\n"); |
| 733 | ret |= 0x80; |
| 734 | return ret; |
| 719 | 735 | } |
| 720 | 736 | |
| 737 | static WRITE8_HANDLER(mcu_printer_p2_w) |
| 738 | { |
| 739 | // logerror("PRN: MCU writing %02x to P2\n",data); |
| 740 | if((data & 0x20) == 0) |
| 741 | pcw_printer_headpos = 1; // move head |
| 742 | if((data & 0x10) == 0) |
| 743 | pcw_printer_headpos = 0; |
| 744 | } |
| 745 | |
| 746 | // Paper sensor? |
| 747 | static READ8_HANDLER(mcu_printer_t1_r) |
| 748 | { |
| 749 | return 1; |
| 750 | } |
| 751 | |
| 752 | // Print head location? (0 if at left margin, otherwise 1) |
| 753 | static READ8_HANDLER(mcu_printer_t0_r) |
| 754 | { |
| 755 | return pcw_printer_headpos; |
| 756 | } |
| 757 | |
| 721 | 758 | /* |
| 722 | 759 | * Keyboard MCU (i8048) |
| 723 | 760 | * P1 = keyboard scan row select (low 8 bits) |
| r9671 | r9672 | |
| 837 | 874 | logerror("pcw9512 parallel w: offs: %04x data: %02x\n",offset,data); |
| 838 | 875 | } |
| 839 | 876 | |
| 840 | | static WRITE8_DEVICE_HANDLER(pcw_printer_output_w) |
| 841 | | { |
| 842 | | // TODO: figure out the outputs and how it sends the initial Z80 code to the data bus. |
| 843 | | logerror("PRN: MCU write to P7: offset %i, data %02x\n",offset,data); |
| 844 | | } |
| 845 | | |
| 846 | 877 | static ADDRESS_MAP_START(pcw_io, ADDRESS_SPACE_IO, 8) |
| 847 | 878 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 848 | 879 | AM_RANGE(0x000, 0x07f) AM_READWRITE(pcw_fdc_r, pcw_fdc_w) |
| r9671 | r9672 | |
| 874 | 905 | |
| 875 | 906 | /* i8041 MCU */ |
| 876 | 907 | static ADDRESS_MAP_START(pcw_printer_io, ADDRESS_SPACE_IO, 8) |
| 877 | | AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_READ(mcu_printer_command_r) |
| 878 | | // AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_READWRITE(mcu_printer_data_r, mcu_printer_data_w) |
| 879 | | // AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_READ(mcu_printer_p2_r) |
| 880 | | AM_RANGE(MCS48_PORT_PROG, MCS48_PORT_PROG) AM_DEVWRITE("printer_8243",i8243_prog_w) |
| 908 | AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_READWRITE(mcu_printer_p2_r,mcu_printer_p2_w) |
| 909 | AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_READWRITE(mcu_printer_p1_r, mcu_printer_p1_w) |
| 910 | AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_READ(mcu_printer_t1_r) |
| 911 | AM_RANGE(MCS48_PORT_T0, MCS48_PORT_T0) AM_READ(mcu_printer_t0_r) |
| 881 | 912 | ADDRESS_MAP_END |
| 882 | 913 | |
| 883 | 914 | static ADDRESS_MAP_START(pcw_keyboard_io, ADDRESS_SPACE_IO, 8) |
| r9671 | r9672 | |
| 933 | 964 | pcw_printer_status = 0xff; |
| 934 | 965 | pcw_printer_command = 0xff; |
| 935 | 966 | pcw_printer_data = 0x00; |
| 967 | pcw_printer_headpos = 0x00; // bring printer head to left margin |
| 936 | 968 | } |
| 937 | 969 | |
| 938 | 970 | static DRIVER_INIT(pcw) |
| r9671 | r9672 | |
| 1172 | 1204 | MDRV_CPU_ADD("keyboard_mcu", I8048, 5000000) // 5MHz |
| 1173 | 1205 | MDRV_CPU_IO_MAP(pcw_keyboard_io) |
| 1174 | 1206 | |
| 1175 | | MDRV_I8243_ADD("printer_8243", NULL, pcw_printer_output_w) |
| 1176 | | |
| 1177 | 1207 | MDRV_MACHINE_START(pcw) |
| 1178 | 1208 | MDRV_MACHINE_RESET(pcw) |
| 1179 | 1209 | |