trunk/src/emu/cpu/m6800/m6800.h
| r24852 | r24853 | |
| 46 | 46 | |
| 47 | 47 | #define MCFG_M6801_SC2(_devcb) \ |
| 48 | 48 | m6800_cpu_device::set_out_sc2_func(*device, DEVCB2_##_devcb); |
| 49 | #define MCFG_M6801_SER_TX(_devcb) \ |
| 50 | m6800_cpu_device::set_out_sertx_func(*device, DEVCB2_##_devcb); |
| 49 | 51 | |
| 50 | | |
| 51 | 52 | class m6800_cpu_device : public cpu_device |
| 52 | 53 | { |
| 53 | 54 | public: |
| r24852 | r24853 | |
| 59 | 60 | |
| 60 | 61 | // static configuration helpers |
| 61 | 62 | template<class _Object> static devcb2_base &set_out_sc2_func(device_t &device, _Object object) { return downcast<m6800_cpu_device &>(device).m_out_sc2_func.set_callback(object); } |
| 63 | template<class _Object> static devcb2_base &set_out_sertx_func(device_t &device, _Object object) { return downcast<m6800_cpu_device &>(device).m_out_sertx_func.set_callback(object); } |
| 62 | 64 | |
| 63 | 65 | DECLARE_READ8_MEMBER( m6801_io_r ); |
| 64 | 66 | DECLARE_WRITE8_MEMBER( m6801_io_w ); |
| r24852 | r24853 | |
| 92 | 94 | bool m_has_io; |
| 93 | 95 | |
| 94 | 96 | devcb2_write_line m_out_sc2_func; |
| 97 | devcb2_write_line m_out_sertx_func; |
| 95 | 98 | |
| 96 | 99 | PAIR m_ppc; /* Previous program counter */ |
| 97 | 100 | PAIR m_pc; /* Program counter */ |
| r24852 | r24853 | |
| 135 | 138 | |
| 136 | 139 | int m_clock_divider; |
| 137 | 140 | UINT8 m_trcsr, m_rmcr, m_rdr, m_tdr, m_rsr, m_tsr; |
| 138 | | int m_rxbits, m_txbits, m_txstate, m_trcsr_read_tdre, m_trcsr_read_orfe, m_trcsr_read_rdrf, m_tx; |
| 141 | int m_rxbits, m_txbits, m_txstate, m_trcsr_read_tdre, m_trcsr_read_orfe, m_trcsr_read_rdrf, m_tx, m_ext_serclock; |
| 142 | bool m_use_ext_serclock; |
| 139 | 143 | int m_port2_written; |
| 140 | 144 | |
| 141 | 145 | int m_icount; |
| r24852 | r24853 | |
| 425 | 429 | m6801_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 426 | 430 | m6801_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source, const m6800_cpu_device::op_func *insn, const UINT8 *cycles, address_map_constructor internal = NULL); |
| 427 | 431 | |
| 432 | void m6801_clock_serial(); |
| 433 | |
| 428 | 434 | protected: |
| 429 | 435 | virtual UINT64 execute_clocks_to_cycles(UINT64 clocks) const { return (clocks + 4 - 1) / 4; } |
| 430 | 436 | virtual UINT64 execute_cycles_to_clocks(UINT64 cycles) const { return (cycles * 4); } |
trunk/src/emu/cpu/m6800/m6800.c
| r24852 | r24853 | |
| 536 | 536 | , m_io_config("io", ENDIANNESS_BIG, 8, 9, 0) |
| 537 | 537 | , m_has_io(false) |
| 538 | 538 | , m_out_sc2_func(*this) |
| 539 | , m_out_sertx_func(*this) |
| 539 | 540 | , m_insn(m6800_insn) |
| 540 | 541 | , m_cycles(cycles_6800) |
| 541 | 542 | { |
| r24852 | r24853 | |
| 548 | 549 | , m_io_config("io", ENDIANNESS_BIG, 8, 9, 0) |
| 549 | 550 | , m_has_io(has_io) |
| 550 | 551 | , m_out_sc2_func(*this) |
| 552 | , m_out_sertx_func(*this) |
| 551 | 553 | , m_insn(insn) |
| 552 | 554 | , m_cycles(cycles) |
| 553 | 555 | { |
| r24852 | r24853 | |
| 730 | 732 | m_wai_state &= ~M6800_SLP; |
| 731 | 733 | if ( !(CC & 0x10) && (m_tcsr & TCSR_EOCI)) |
| 732 | 734 | TAKE_OCI; |
| 735 | |
| 736 | // if output on P21 is enabled, let's do it |
| 737 | if (m_port2_ddr & 2) |
| 738 | { |
| 739 | m_port2_data &= ~2; |
| 740 | m_port2_data |= (m_tcsr & TCSR_OLVL) << 1; |
| 741 | m_port2_written = 1; |
| 742 | write_port2(); |
| 743 | } |
| 733 | 744 | } |
| 734 | 745 | /* TOI */ |
| 735 | 746 | if( CTD >= TOD) |
| r24852 | r24853 | |
| 767 | 778 | switch ((m_rmcr & M6800_RMCR_CC_MASK) >> 2) |
| 768 | 779 | { |
| 769 | 780 | case 0: |
| 770 | | case 3: // not implemented |
| 771 | 781 | m_sci_timer->enable(false); |
| 782 | m_use_ext_serclock = false; |
| 772 | 783 | break; |
| 773 | 784 | |
| 785 | case 3: // external clock |
| 786 | m_use_ext_serclock = true; |
| 787 | m_sci_timer->enable(false); |
| 788 | break; |
| 789 | |
| 774 | 790 | case 1: |
| 775 | 791 | case 2: |
| 776 | 792 | { |
| r24852 | r24853 | |
| 778 | 794 | int clock = m_clock / m_clock_divider; |
| 779 | 795 | |
| 780 | 796 | m_sci_timer->adjust(attotime::from_hz(clock / divisor), 0, attotime::from_hz(clock / divisor)); |
| 797 | m_use_ext_serclock = false; |
| 781 | 798 | } |
| 782 | 799 | break; |
| 783 | 800 | } |
| r24852 | r24853 | |
| 844 | 861 | case M6800_SERIAL_START: |
| 845 | 862 | if (m_trcsr & M6800_TRCSR_TDRE) |
| 846 | 863 | { |
| 847 | | // transmit buffer is empty, send consecutive '1's |
| 848 | | m_tx = 1; |
| 864 | // transmit buffer is empty, send nothing |
| 865 | return; |
| 849 | 866 | } |
| 850 | 867 | else |
| 851 | 868 | { |
| r24852 | r24853 | |
| 892 | 909 | break; |
| 893 | 910 | } |
| 894 | 911 | |
| 912 | m_out_sertx_func((m_tx == 1) ? ASSERT_LINE : CLEAR_LINE); |
| 895 | 913 | m_port2_written = 1; |
| 896 | 914 | write_port2(); |
| 897 | 915 | } |
| r24852 | r24853 | |
| 1023 | 1041 | m_io = &space(AS_IO); |
| 1024 | 1042 | |
| 1025 | 1043 | m_out_sc2_func.resolve_safe(); |
| 1044 | m_out_sertx_func.resolve_safe(); |
| 1026 | 1045 | m_sci_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(m6800_cpu_device::sci_tick),this)); |
| 1027 | 1046 | |
| 1028 | 1047 | save_item(NAME(m_ppc.w.l)); |
| r24852 | r24853 | |
| 1144 | 1163 | m_trcsr_read_tdre = 0; |
| 1145 | 1164 | m_trcsr_read_orfe = 0; |
| 1146 | 1165 | m_trcsr_read_rdrf = 0; |
| 1166 | m_ext_serclock = 0; |
| 1167 | m_use_ext_serclock = false; |
| 1147 | 1168 | |
| 1148 | 1169 | set_rmcr(0); |
| 1149 | 1170 | } |
| r24852 | r24853 | |
| 1479 | 1500 | { |
| 1480 | 1501 | m_port2_ddr = data; |
| 1481 | 1502 | write_port2(); |
| 1482 | | |
| 1483 | | if (m_port2_ddr & 2) |
| 1484 | | logerror("CPU '%s' PC %04x: warning - port 2 bit 1 set as output (OLVL) - not supported\n",space.device().tag(),space.device().safe_pc()); |
| 1485 | 1503 | } |
| 1486 | 1504 | break; |
| 1487 | 1505 | |
| r24852 | r24853 | |
| 1683 | 1701 | } |
| 1684 | 1702 | } |
| 1685 | 1703 | |
| 1704 | void m6801_cpu_device::m6801_clock_serial() |
| 1705 | { |
| 1706 | if (m_use_ext_serclock) |
| 1707 | { |
| 1708 | m_ext_serclock++; |
| 1686 | 1709 | |
| 1710 | if (m_ext_serclock >= 8) |
| 1711 | { |
| 1712 | m_ext_serclock = 0; |
| 1713 | serial_transmit(); |
| 1714 | serial_receive(); |
| 1715 | } |
| 1716 | } |
| 1717 | } |
| 1718 | |
| 1687 | 1719 | offs_t m6800_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) |
| 1688 | 1720 | { |
| 1689 | 1721 | extern CPU_DISASSEMBLE( m6800 ); |
| r24852 | r24853 | |
| 1739 | 1771 | return CPU_DISASSEMBLE_NAME(nsc8105)(this, buffer, pc, oprom, opram, options); |
| 1740 | 1772 | } |
| 1741 | 1773 | |
| 1742 | | |