trunk/src/mess/drivers/px4.c
| r21147 | r21148 | |
| 17 | 17 | #include "machine/ram.h" |
| 18 | 18 | #include "machine/nvram.h" |
| 19 | 19 | #include "sound/speaker.h" |
| 20 | #include "machine/serial.h" |
| 20 | 21 | #include "px4.lh" |
| 21 | 22 | |
| 22 | 23 | |
| r21147 | r21148 | |
| 24 | 25 | // CONSTANTS |
| 25 | 26 | //************************************************************************** |
| 26 | 27 | |
| 27 | | #define VERBOSE 0 |
| 28 | #define VERBOSE 1 |
| 28 | 29 | |
| 29 | 30 | // interrupt sources |
| 30 | 31 | #define INT0_7508 0x01 |
| r21147 | r21148 | |
| 80 | 81 | m_centronics(*this, "centronics"), |
| 81 | 82 | m_ext_cas(*this, "extcas"), |
| 82 | 83 | m_speaker(*this, SPEAKER_TAG), |
| 83 | | m_sio(*this, "sio") |
| 84 | m_sio(*this, "sio"), |
| 85 | m_rs232(*this, "rs232") |
| 84 | 86 | { } |
| 85 | 87 | |
| 86 | 88 | // internal devices |
| r21147 | r21148 | |
| 90 | 92 | required_device<cassette_image_device> m_ext_cas; |
| 91 | 93 | required_device<speaker_sound_device> m_speaker; |
| 92 | 94 | required_device<epson_sio_device> m_sio; |
| 95 | required_device<rs232_port_device> m_rs232; |
| 93 | 96 | |
| 94 | 97 | /* gapnit register */ |
| 95 | 98 | UINT8 m_ctrl1; |
| r21147 | r21148 | |
| 120 | 123 | UINT8 m_artcr; |
| 121 | 124 | UINT8 m_swr; |
| 122 | 125 | |
| 126 | int rxd_r(); |
| 127 | void txd_w(int data); |
| 128 | |
| 123 | 129 | /* 7508 internal */ |
| 124 | 130 | bool m_one_sec_int_enabled; |
| 125 | 131 | bool m_alarm_int_enabled; |
| r21147 | r21148 | |
| 136 | 142 | emu_timer *m_ext_cas_timer; |
| 137 | 143 | int m_ear_last_state; |
| 138 | 144 | |
| 139 | | /* external devices */ |
| 140 | | device_t *m_sio_device; |
| 141 | | device_t *m_rs232c_device; |
| 142 | | |
| 143 | 145 | void install_rom_capsule(address_space &space, int size, const char *region); |
| 144 | 146 | |
| 145 | 147 | DECLARE_READ8_MEMBER(px4_icrlc_r); |
| r21147 | r21148 | |
| 186 | 188 | TIMER_CALLBACK_MEMBER(receive_data); |
| 187 | 189 | TIMER_DEVICE_CALLBACK_MEMBER(frc_tick); |
| 188 | 190 | TIMER_DEVICE_CALLBACK_MEMBER(upd7508_1sec_callback); |
| 189 | | |
| 190 | | void px4_rs232c_txd(device_t *device,int state); |
| 191 | | int px4_rs232c_rxd(device_t *device); |
| 192 | | void px4_rs232c_rts(device_t *device,int state); |
| 193 | | int px4_rs232c_cts(device_t *device); |
| 194 | | int px4_rs232c_dsr(device_t *device); |
| 195 | | void px4_rs232c_dtr(device_t *device,int state); |
| 196 | | int px4_rs232c_dcd(device_t *device); |
| 197 | 191 | }; |
| 198 | 192 | |
| 199 | 193 | |
| 200 | 194 | //************************************************************************** |
| 201 | | // RS232C PORT |
| 202 | | //************************************************************************** |
| 203 | | |
| 204 | | // Currently nothing is connected to this port |
| 205 | | |
| 206 | | void px4_state::px4_rs232c_txd(device_t *device,int state) |
| 207 | | { |
| 208 | | if (VERBOSE) |
| 209 | | logerror("px4_rs232c_txd: %d\n", state); |
| 210 | | } |
| 211 | | |
| 212 | | #ifdef UNUSED_FUNCTION |
| 213 | | int px4_state::px4_rs232c_rxd(device_t *device) |
| 214 | | { |
| 215 | | if (VERBOSE) |
| 216 | | logerror("px4_rs232c_rxd\n"); |
| 217 | | return ASSERT_LINE; |
| 218 | | } |
| 219 | | #endif |
| 220 | | |
| 221 | | void px4_state::px4_rs232c_rts(device_t *device,int state) |
| 222 | | { |
| 223 | | if (VERBOSE) |
| 224 | | logerror("px4_rs232c_rts: %d\n", state); |
| 225 | | } |
| 226 | | |
| 227 | | int px4_state::px4_rs232c_cts(device_t *device) |
| 228 | | { |
| 229 | | if (VERBOSE) |
| 230 | | logerror("px4_rs232c_cts\n"); |
| 231 | | |
| 232 | | return ASSERT_LINE; |
| 233 | | } |
| 234 | | |
| 235 | | int px4_state::px4_rs232c_dsr(device_t *device) |
| 236 | | { |
| 237 | | if (VERBOSE) |
| 238 | | logerror("px4_rs232c_dsr\n"); |
| 239 | | |
| 240 | | return ASSERT_LINE; |
| 241 | | } |
| 242 | | |
| 243 | | void px4_state::px4_rs232c_dtr(device_t *device,int state) |
| 244 | | { |
| 245 | | if (VERBOSE) |
| 246 | | logerror("px4_rs232c_dtr: %d\n", state); |
| 247 | | } |
| 248 | | |
| 249 | | int px4_state::px4_rs232c_dcd(device_t *device) |
| 250 | | { |
| 251 | | if (VERBOSE) |
| 252 | | logerror("px4_rs232c_dcd\n"); |
| 253 | | |
| 254 | | return ASSERT_LINE; |
| 255 | | } |
| 256 | | |
| 257 | | |
| 258 | | //************************************************************************** |
| 259 | 195 | // GAPNIT |
| 260 | 196 | //************************************************************************** |
| 261 | 197 | |
| r21147 | r21148 | |
| 518 | 454 | default: |
| 519 | 455 | if (VERBOSE) |
| 520 | 456 | logerror("invalid bank switch value: 0x%02x\n", data >> 4); |
| 521 | | |
| 457 | break; |
| 522 | 458 | } |
| 523 | 459 | } |
| 524 | 460 | |
| r21147 | r21148 | |
| 698 | 634 | // GAPNIO |
| 699 | 635 | //************************************************************************** |
| 700 | 636 | |
| 637 | // helper function to read from selected serial port |
| 638 | int px4_state::rxd_r() |
| 639 | { |
| 640 | if (BIT(m_swr, 3)) |
| 641 | // from rs232 |
| 642 | return m_rs232->rx(); |
| 643 | else |
| 644 | if (BIT(m_swr, 2)) |
| 645 | // from sio |
| 646 | return m_sio->rx_r(); |
| 647 | else |
| 648 | // from cartridge |
| 649 | return 0; |
| 650 | } |
| 651 | |
| 652 | // helper function to write to selected serial port |
| 653 | void px4_state::txd_w(int data) |
| 654 | { |
| 655 | if (BIT(m_swr, 2)) |
| 656 | // from sio |
| 657 | m_sio->tx_w(data); |
| 658 | else |
| 659 | if (BIT(m_swr, 3)) |
| 660 | // from rs232 |
| 661 | m_rs232->tx(data); |
| 662 | // else from cartridge |
| 663 | } |
| 664 | |
| 701 | 665 | TIMER_CALLBACK_MEMBER(px4_state::transmit_data) |
| 702 | 666 | { |
| 703 | 667 | if (ART_TX_ENABLED) |
| r21147 | r21148 | |
| 760 | 724 | if (VERBOSE) |
| 761 | 725 | logerror("%s: px4_artsr_r\n", machine().describe_context()); |
| 762 | 726 | |
| 763 | | result |= px4_rs232c_dsr(m_rs232c_device) << 7; |
| 727 | result |= m_rs232->dsr_r() << 7; |
| 764 | 728 | |
| 765 | 729 | return result | m_artsr; |
| 766 | 730 | } |
| r21147 | r21148 | |
| 782 | 746 | if (VERBOSE) |
| 783 | 747 | logerror("%s: px4_iostr_r\n", machine().describe_context()); |
| 784 | 748 | |
| 749 | // centronics status |
| 785 | 750 | result |= m_centronics->busy_r() << 0; |
| 786 | 751 | result |= !m_centronics->pe_r() << 1; |
| 752 | |
| 753 | // sio status |
| 787 | 754 | result |= !m_sio->pin_r() << 2; |
| 788 | | result |= m_sio->rx_r() << 3; |
| 789 | | result |= px4_rs232c_dcd(m_rs232c_device) << 4; |
| 790 | | result |= px4_rs232c_cts(m_rs232c_device) << 5; |
| 755 | |
| 756 | // serial data |
| 757 | result |= rxd_r() << 3; |
| 758 | |
| 759 | // rs232 status |
| 760 | result |= m_rs232->dcd_r() << 4; |
| 761 | result |= m_rs232->cts_r() << 5; |
| 762 | |
| 791 | 763 | result |= 1 << 6; // bit 6, csel, cartridge option select signal, set to 'other mode' |
| 792 | 764 | result |= 0 << 7; // bit 7, caud - audio input from cartridge |
| 793 | 765 | |
| r21147 | r21148 | |
| 804 | 776 | |
| 805 | 777 | // bit 0, txe - transmit enable |
| 806 | 778 | if (!ART_TX_ENABLED) |
| 807 | | { |
| 808 | | // force high when disabled |
| 809 | | m_sio->tx_w(1); |
| 810 | | px4_rs232c_txd(m_rs232c_device, ASSERT_LINE); |
| 811 | | } |
| 779 | txd_w(1); // force high when disabled |
| 812 | 780 | |
| 813 | 781 | // bit 3, sbrk - break output |
| 814 | 782 | if (ART_TX_ENABLED && BIT(data, 3)) |
| 815 | | { |
| 816 | | // force low when enabled and transmit enabled |
| 817 | | m_sio->tx_w(0); |
| 818 | | px4_rs232c_txd(m_rs232c_device, CLEAR_LINE); |
| 819 | | } |
| 783 | txd_w(0); // force low when enabled and transmit enabled |
| 820 | 784 | |
| 821 | 785 | // error reset |
| 822 | 786 | if (BIT(data, 4)) |
| 823 | 787 | m_artsr &= ~(ART_PE | ART_OE | ART_FE); |
| 824 | 788 | |
| 825 | | px4_rs232c_dtr(m_rs232c_device, BIT(data, 1)); |
| 826 | | px4_rs232c_rts(m_rs232c_device, BIT(data, 5)); |
| 789 | // rs232 |
| 790 | m_rs232->dtr_w(BIT(data, 1)); |
| 791 | m_rs232->rts_w(BIT(data, 5)); |
| 827 | 792 | } |
| 828 | 793 | |
| 829 | 794 | // switch register |
| r21147 | r21148 | |
| 1027 | 992 | m_ext_cas_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(px4_state::ext_cassette_read), this)); |
| 1028 | 993 | m_ear_last_state = 0; |
| 1029 | 994 | |
| 1030 | | // external devices |
| 1031 | | m_sio_device = machine().device("floppy"); |
| 1032 | | m_rs232c_device = NULL; |
| 1033 | | |
| 1034 | 995 | // map os rom and last half of memory |
| 1035 | 996 | membank("bank1")->set_base(memregion("os")->base()); |
| 1036 | 997 | membank("bank2")->set_base(m_ram->pointer() + 0x8000); |
| r21147 | r21148 | |
| 1276 | 1237 | // MACHINE DRIVERS |
| 1277 | 1238 | //************************************************************************** |
| 1278 | 1239 | |
| 1240 | static const rs232_port_interface rs232_intf = |
| 1241 | { |
| 1242 | DEVCB_NULL, |
| 1243 | DEVCB_NULL, |
| 1244 | DEVCB_NULL, |
| 1245 | DEVCB_NULL, |
| 1246 | DEVCB_NULL |
| 1247 | }; |
| 1248 | |
| 1279 | 1249 | static const cassette_interface px4_cassette_interface = |
| 1280 | 1250 | { |
| 1281 | 1251 | cassette_default_formats, |
| r21147 | r21148 | |
| 1323 | 1293 | // sio port |
| 1324 | 1294 | MCFG_EPSON_SIO_ADD("sio") |
| 1325 | 1295 | |
| 1296 | // rs232 port |
| 1297 | MCFG_RS232_PORT_ADD("rs232", rs232_intf, default_rs232_devices, NULL, NULL) |
| 1298 | |
| 1326 | 1299 | // rom capsules |
| 1327 | 1300 | MCFG_CARTSLOT_ADD("capsule1") |
| 1328 | 1301 | MCFG_CARTSLOT_EXTENSION_LIST("bin") |