src/mess/includes/abc80x.h
| r15736 | r15737 | |
| 51 | 51 | #define ABC800_CHAR_WIDTH 6 |
| 52 | 52 | #define ABC800_CCLK ABC800_X01/ABC800_CHAR_WIDTH |
| 53 | 53 | |
| 54 | | #define SCREEN_TAG "screen" |
| 55 | | #define Z80_TAG "z80" |
| 56 | | #define E0516_TAG "j13" |
| 57 | | #define MC6845_TAG "b12" |
| 58 | | #define SAA5052_TAG "5c" |
| 59 | | #define Z80CTC_TAG "z80ctc" |
| 60 | | #define Z80SIO_TAG "z80sio" |
| 61 | | #define Z80DART_TAG "z80dart" |
| 62 | | #define ABCBUS_TAG "abcbus" |
| 54 | #define SCREEN_TAG "screen" |
| 55 | #define Z80_TAG "z80" |
| 56 | #define E0516_TAG "j13" |
| 57 | #define MC6845_TAG "b12" |
| 58 | #define SAA5052_TAG "5c" |
| 59 | #define Z80CTC_TAG "z80ctc" |
| 60 | #define Z80SIO_TAG "z80sio" |
| 61 | #define Z80DART_TAG "z80dart" |
| 62 | #define ABCBUS_TAG "abcbus" |
| 63 | #define TIMER_CASSETTE_TAG "cass" |
| 63 | 64 | |
| 64 | 65 | |
| 65 | | |
| 66 | 66 | //************************************************************************** |
| 67 | 67 | // TYPE DEFINITIONS |
| 68 | 68 | //************************************************************************** |
| r15736 | r15737 | |
| 79 | 79 | m_dart(*this, Z80DART_TAG), |
| 80 | 80 | m_sio(*this, Z80SIO_TAG), |
| 81 | 81 | m_discrete(*this, "discrete"), |
| 82 | m_cassette(*this, CASSETTE_TAG), |
| 82 | 83 | m_ram(*this, RAM_TAG), |
| 84 | m_cassette_timer(*this, TIMER_CASSETTE_TAG), |
| 83 | 85 | m_video_ram(*this, "video_ram"), |
| 84 | | m_char_ram(*this, "char_ram") |
| 86 | m_char_ram(*this, "char_ram"), |
| 87 | m_ctc_z0(0), |
| 88 | m_sio_rxdb(1), |
| 89 | m_sio_txcb(0), |
| 90 | m_sio_txdb(1), |
| 91 | m_sio_rtsb(1), |
| 92 | m_dfd_out(0), |
| 93 | m_tape_ctr(4) |
| 85 | 94 | { } |
| 86 | 95 | |
| 87 | 96 | required_device<cpu_device> m_maincpu; |
| r15736 | r15737 | |
| 89 | 98 | required_device<z80dart_device> m_dart; |
| 90 | 99 | required_device<z80dart_device> m_sio; |
| 91 | 100 | optional_device<device_t> m_discrete; |
| 101 | required_device<cassette_image_device> m_cassette; |
| 92 | 102 | required_device<ram_device> m_ram; |
| 103 | required_device<timer_device> m_cassette_timer; |
| 93 | 104 | |
| 94 | 105 | virtual void machine_start(); |
| 95 | 106 | virtual void machine_reset(); |
| r15736 | r15737 | |
| 97 | 108 | virtual void video_start(); |
| 98 | 109 | |
| 99 | 110 | void bankswitch(); |
| 111 | void clock_cassette(int state); |
| 100 | 112 | |
| 101 | 113 | DECLARE_READ8_MEMBER( pling_r ); |
| 102 | 114 | DECLARE_READ_LINE_MEMBER( keyboard_txd_r ); |
| r15736 | r15737 | |
| 109 | 121 | DECLARE_WRITE_LINE_MEMBER( ctc_z0_w ); |
| 110 | 122 | DECLARE_WRITE_LINE_MEMBER( ctc_z1_w ); |
| 111 | 123 | DECLARE_WRITE_LINE_MEMBER( ctc_z2_w ); |
| 124 | DECLARE_READ_LINE_MEMBER( sio_rxdb_r ); |
| 125 | DECLARE_WRITE_LINE_MEMBER( sio_txdb_w ); |
| 126 | DECLARE_WRITE_LINE_MEMBER( sio_dtrb_w ); |
| 127 | DECLARE_WRITE_LINE_MEMBER( sio_rtsb_w ); |
| 112 | 128 | |
| 113 | 129 | // cpu state |
| 114 | 130 | int m_fetch_charram; // opcode fetched from character RAM region (0x7800-0x7fff) |
| r15736 | r15737 | |
| 126 | 142 | |
| 127 | 143 | // serial state |
| 128 | 144 | UINT8 m_sb; |
| 145 | int m_ctc_z0; |
| 146 | int m_sio_rxdb; |
| 129 | 147 | int m_sio_rxcb; |
| 130 | 148 | int m_sio_txcb; |
| 149 | int m_sio_txdb; |
| 150 | int m_sio_rtsb; |
| 151 | int m_dfd_out; |
| 152 | int m_dfd_in; |
| 153 | int m_tape_ctr; |
| 131 | 154 | }; |
| 132 | 155 | |
| 133 | 156 | class abc800m_state : public abc800_state |
src/mess/drivers/abc80x.c
| r15736 | r15737 | |
| 646 | 646 | { |
| 647 | 647 | if (BIT(m_sb, 2)) |
| 648 | 648 | { |
| 649 | | // connected to SIO/2 TxCA, CTC CLK/TRG3 |
| 650 | 649 | z80dart_txca_w(m_sio, state); |
| 651 | 650 | z80ctc_trg3_w(m_ctc, state); |
| 652 | 651 | } |
| 653 | 652 | |
| 654 | | // connected to SIO/2 RxCB through a thingy |
| 655 | | //m_sio_rxcb = ? |
| 656 | | z80dart_rxcb_w(m_sio, m_sio_rxcb); |
| 657 | | |
| 658 | | // connected to SIO/2 TxCB through a JK divide by 2 |
| 659 | | m_sio_txcb = !m_sio_txcb; |
| 660 | | z80dart_txcb_w(m_sio, m_sio_txcb); |
| 653 | clock_cassette(state); |
| 661 | 654 | } |
| 662 | 655 | |
| 663 | 656 | WRITE_LINE_MEMBER( abc800_state::ctc_z1_w ) |
| 664 | 657 | { |
| 665 | 658 | if (BIT(m_sb, 3)) |
| 666 | 659 | { |
| 667 | | // connected to SIO/2 RxCA |
| 668 | 660 | z80dart_rxca_w(m_sio, state); |
| 669 | 661 | } |
| 670 | 662 | |
| 671 | 663 | if (BIT(m_sb, 4)) |
| 672 | 664 | { |
| 673 | | // connected to SIO/2 TxCA, CTC CLK/TRG3 |
| 674 | 665 | z80dart_txca_w(m_sio, state); |
| 675 | 666 | z80ctc_trg3_w(m_ctc, state); |
| 676 | 667 | } |
| r15736 | r15737 | |
| 678 | 669 | |
| 679 | 670 | WRITE_LINE_MEMBER( abc800_state::ctc_z2_w ) |
| 680 | 671 | { |
| 681 | | // connected to DART channel A clock inputs |
| 682 | 672 | z80dart_rxca_w(m_dart, state); |
| 683 | 673 | z80dart_txca_w(m_dart, state); |
| 684 | 674 | } |
| 685 | 675 | |
| 686 | 676 | static Z80CTC_INTERFACE( ctc_intf ) |
| 687 | 677 | { |
| 688 | | 0, // timer disables |
| 689 | | DEVCB_CPU_INPUT_LINE(Z80_TAG, INPUT_LINE_IRQ0), // interrupt handler |
| 678 | 0, // timer disables |
| 679 | DEVCB_CPU_INPUT_LINE(Z80_TAG, INPUT_LINE_IRQ0), // interrupt handler |
| 690 | 680 | DEVCB_DRIVER_LINE_MEMBER(abc800_state, ctc_z0_w), // ZC/TO0 callback |
| 691 | 681 | DEVCB_DRIVER_LINE_MEMBER(abc800_state, ctc_z1_w), // ZC/TO1 callback |
| 692 | 682 | DEVCB_DRIVER_LINE_MEMBER(abc800_state, ctc_z2_w), // ZC/TO2 callback |
| r15736 | r15737 | |
| 697 | 687 | // Z80DART_INTERFACE( sio_intf ) |
| 698 | 688 | //------------------------------------------------- |
| 699 | 689 | |
| 700 | | static READ_LINE_DEVICE_HANDLER( dfd_in_r ) |
| 690 | void abc800_state::clock_cassette(int state) |
| 701 | 691 | { |
| 702 | | return dynamic_cast<cassette_image_device *>(device)->input() > 0.0; |
| 692 | if (m_ctc_z0 && !state) |
| 693 | { |
| 694 | m_sio_txcb = !m_sio_txcb; |
| 695 | z80dart_txcb_w(m_sio, !m_sio_txcb); |
| 696 | |
| 697 | if (m_sio_txdb || m_sio_txcb) |
| 698 | { |
| 699 | m_dfd_out = !m_dfd_out; |
| 700 | m_cassette->output((m_dfd_out & m_sio_rtsb) ? +1.0 : -1.0); |
| 701 | } |
| 702 | |
| 703 | if (m_tape_ctr < 15) |
| 704 | { |
| 705 | m_tape_ctr++; |
| 706 | } |
| 707 | |
| 708 | z80dart_rxcb_w(m_sio, m_tape_ctr == 15); |
| 709 | } |
| 710 | |
| 711 | m_ctc_z0 = state; |
| 703 | 712 | } |
| 704 | 713 | |
| 705 | | static WRITE_LINE_DEVICE_HANDLER( dfd_out_w ) |
| 714 | static TIMER_DEVICE_CALLBACK( cassette_tick ) |
| 706 | 715 | { |
| 707 | | dynamic_cast<cassette_image_device *>(device)->output(state ? +1.0 : -1.0); |
| 716 | abc800_state *state = timer.machine().driver_data<abc800_state>(); |
| 717 | |
| 718 | int dfd_in = state->m_cassette->input() > 0; |
| 719 | |
| 720 | if (state->m_dfd_in && !dfd_in) |
| 721 | { |
| 722 | state->m_sio_rxdb = !(state->m_tape_ctr == 15); |
| 723 | } |
| 724 | |
| 725 | if (!dfd_in && (state->m_tape_ctr == 15)) |
| 726 | { |
| 727 | state->m_tape_ctr = 4; |
| 728 | } |
| 729 | |
| 730 | state->m_dfd_in = dfd_in; |
| 708 | 731 | } |
| 709 | 732 | |
| 710 | | static WRITE_LINE_DEVICE_HANDLER( motor_control_w ) |
| 733 | READ_LINE_MEMBER( abc800_state::sio_rxdb_r ) |
| 711 | 734 | { |
| 712 | | dynamic_cast<cassette_image_device *>(device)->change_state(state ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR); |
| 735 | return m_sio_rxdb; |
| 713 | 736 | } |
| 714 | 737 | |
| 738 | WRITE_LINE_MEMBER( abc800_state::sio_txdb_w ) |
| 739 | { |
| 740 | m_sio_txdb = state; |
| 741 | } |
| 742 | |
| 743 | WRITE_LINE_MEMBER( abc800_state::sio_dtrb_w ) |
| 744 | { |
| 745 | if (state) |
| 746 | { |
| 747 | m_cassette->change_state(CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR); |
| 748 | m_cassette_timer->enable(true); |
| 749 | } |
| 750 | else |
| 751 | { |
| 752 | m_cassette->change_state(CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); |
| 753 | m_cassette_timer->enable(false); |
| 754 | } |
| 755 | } |
| 756 | |
| 757 | WRITE_LINE_MEMBER( abc800_state::sio_rtsb_w ) |
| 758 | { |
| 759 | m_sio_rtsb = state; |
| 760 | |
| 761 | if (!m_sio_rtsb) |
| 762 | { |
| 763 | m_cassette->output(-1.0); |
| 764 | } |
| 765 | } |
| 766 | |
| 715 | 767 | static Z80DART_INTERFACE( sio_intf ) |
| 716 | 768 | { |
| 717 | 769 | 0, 0, 0, 0, |
| r15736 | r15737 | |
| 723 | 775 | DEVCB_NULL, |
| 724 | 776 | DEVCB_NULL, |
| 725 | 777 | |
| 726 | | DEVCB_DEVICE_LINE(CASSETTE_TAG, dfd_in_r), |
| 727 | | DEVCB_DEVICE_LINE(CASSETTE_TAG, dfd_out_w), |
| 728 | | DEVCB_DEVICE_LINE(CASSETTE_TAG, motor_control_w), |
| 778 | DEVCB_DRIVER_LINE_MEMBER(abc800_state, sio_rxdb_r), |
| 779 | DEVCB_DRIVER_LINE_MEMBER(abc800_state, sio_txdb_w), |
| 780 | DEVCB_DRIVER_LINE_MEMBER(abc800_state, sio_dtrb_w), |
| 781 | DEVCB_DRIVER_LINE_MEMBER(abc800_state, sio_rtsb_w), |
| 729 | 782 | DEVCB_NULL, |
| 730 | 783 | DEVCB_NULL, |
| 731 | | DEVCB_NULL, |
| 732 | 784 | |
| 733 | 785 | DEVCB_CPU_INPUT_LINE(Z80_TAG, INPUT_LINE_IRQ0) |
| 734 | 786 | }; |
| r15736 | r15737 | |
| 916 | 968 | // register for state saving |
| 917 | 969 | save_item(NAME(m_fetch_charram)); |
| 918 | 970 | save_item(NAME(m_pling)); |
| 971 | save_item(NAME(m_sb)); |
| 972 | save_item(NAME(m_ctc_z0)); |
| 973 | save_item(NAME(m_sio_rxdb)); |
| 919 | 974 | save_item(NAME(m_sio_rxcb)); |
| 920 | 975 | save_item(NAME(m_sio_txcb)); |
| 976 | save_item(NAME(m_sio_txdb)); |
| 977 | save_item(NAME(m_sio_rtsb)); |
| 978 | save_item(NAME(m_dfd_out)); |
| 979 | save_item(NAME(m_dfd_in)); |
| 980 | save_item(NAME(m_tape_ctr)); |
| 921 | 981 | } |
| 922 | 982 | |
| 923 | 983 | |
| r15736 | r15737 | |
| 948 | 1008 | // register for state saving |
| 949 | 1009 | save_item(NAME(m_lrs)); |
| 950 | 1010 | save_item(NAME(m_pling)); |
| 1011 | save_item(NAME(m_sb)); |
| 1012 | save_item(NAME(m_ctc_z0)); |
| 1013 | save_item(NAME(m_sio_rxdb)); |
| 1014 | save_item(NAME(m_sio_rxcb)); |
| 1015 | save_item(NAME(m_sio_txcb)); |
| 1016 | save_item(NAME(m_sio_txdb)); |
| 1017 | save_item(NAME(m_sio_rtsb)); |
| 1018 | save_item(NAME(m_dfd_out)); |
| 1019 | save_item(NAME(m_dfd_in)); |
| 1020 | save_item(NAME(m_tape_ctr)); |
| 951 | 1021 | } |
| 952 | 1022 | |
| 953 | 1023 | |
| r15736 | r15737 | |
| 1005 | 1075 | save_item(NAME(m_eme)); |
| 1006 | 1076 | save_item(NAME(m_fetch_charram)); |
| 1007 | 1077 | save_item(NAME(m_map)); |
| 1078 | save_item(NAME(m_ctc_z0)); |
| 1079 | save_item(NAME(m_sio_rxdb)); |
| 1080 | save_item(NAME(m_sio_rxcb)); |
| 1081 | save_item(NAME(m_sio_txcb)); |
| 1082 | save_item(NAME(m_sio_txdb)); |
| 1083 | save_item(NAME(m_sio_rtsb)); |
| 1084 | save_item(NAME(m_dfd_out)); |
| 1085 | save_item(NAME(m_dfd_in)); |
| 1086 | save_item(NAME(m_tape_ctr)); |
| 1008 | 1087 | } |
| 1009 | 1088 | |
| 1010 | 1089 | |
| r15736 | r15737 | |
| 1070 | 1149 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) |
| 1071 | 1150 | |
| 1072 | 1151 | // peripheral hardware |
| 1152 | MCFG_TIMER_ADD_PERIODIC(TIMER_CASSETTE_TAG, cassette_tick, attotime::from_hz(44100)) |
| 1073 | 1153 | MCFG_Z80CTC_ADD(Z80CTC_TAG, ABC800_X01/2/2, ctc_intf) |
| 1074 | 1154 | MCFG_TIMER_ADD_PERIODIC("ctc", ctc_tick, attotime::from_hz(ABC800_X01/2/2/2)) |
| 1075 | 1155 | MCFG_Z80SIO2_ADD(Z80SIO_TAG, ABC800_X01/2/2, sio_intf) |
| r15736 | r15737 | |
| 1113 | 1193 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) |
| 1114 | 1194 | |
| 1115 | 1195 | // peripheral hardware |
| 1196 | MCFG_TIMER_ADD_PERIODIC(TIMER_CASSETTE_TAG, cassette_tick, attotime::from_hz(44100)) |
| 1116 | 1197 | MCFG_Z80CTC_ADD(Z80CTC_TAG, ABC800_X01/2/2, ctc_intf) |
| 1117 | 1198 | MCFG_TIMER_ADD_PERIODIC("ctc", ctc_tick, attotime::from_hz(ABC800_X01/2/2/2)) |
| 1118 | 1199 | MCFG_Z80SIO2_ADD(Z80SIO_TAG, ABC800_X01/2/2, sio_intf) |
| r15736 | r15737 | |
| 1156 | 1237 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) |
| 1157 | 1238 | |
| 1158 | 1239 | // peripheral hardware |
| 1240 | MCFG_TIMER_ADD_PERIODIC(TIMER_CASSETTE_TAG, cassette_tick, attotime::from_hz(44100)) |
| 1159 | 1241 | MCFG_Z80CTC_ADD(Z80CTC_TAG, ABC800_X01/2/2, ctc_intf) |
| 1160 | 1242 | MCFG_TIMER_ADD_PERIODIC("ctc", ctc_tick, attotime::from_hz(ABC800_X01/2/2/2)) |
| 1161 | 1243 | MCFG_Z80SIO2_ADD(Z80SIO_TAG, ABC800_X01/2/2, sio_intf) |
| r15736 | r15737 | |
| 1189 | 1271 | MCFG_FRAGMENT_ADD(abc806_video) |
| 1190 | 1272 | |
| 1191 | 1273 | // peripheral hardware |
| 1274 | MCFG_TIMER_ADD_PERIODIC(TIMER_CASSETTE_TAG, cassette_tick, attotime::from_hz(44100)) |
| 1192 | 1275 | MCFG_E0516_ADD(E0516_TAG, ABC806_X02) |
| 1193 | 1276 | MCFG_Z80CTC_ADD(Z80CTC_TAG, ABC800_X01/2/2, ctc_intf) |
| 1194 | 1277 | MCFG_TIMER_ADD_PERIODIC("ctc", ctc_tick, attotime::from_hz(ABC800_X01/2/2/2)) |