trunk/src/emu/cpu/hmcs40/hmcs40op.inc
| r244819 | r244820 | |
| 4 | 4 | |
| 5 | 5 | inline UINT8 hmcs40_cpu_device::ram_r() |
| 6 | 6 | { |
| 7 | | UINT8 address = (m_x << 4 | m_y) & m_datamask; |
| 7 | UINT16 address = (m_x << 4 | m_y) & m_datamask; |
| 8 | 8 | return m_data->read_byte(address) & 0xf; |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | inline void hmcs40_cpu_device::ram_w(UINT8 data) |
| 12 | 12 | { |
| 13 | | UINT8 address = (m_x << 4 | m_y) & m_datamask; |
| 13 | UINT16 address = (m_x << 4 | m_y) & m_datamask; |
| 14 | 14 | m_data->write_byte(address, data & 0xf); |
| 15 | 15 | } |
| 16 | 16 | |
| r244819 | r244820 | |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | if (m_is_cmos) |
| 52 | | return inp & m_r[index]; |
| 52 | return (inp & m_r[index]) & 0xf; |
| 53 | 53 | else |
| 54 | | return inp | m_r[index]; |
| 54 | return (inp | m_r[index]) & 0xf; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | void hmcs40_cpu_device::write_r(int index, UINT8 data) |
| 58 | 58 | { |
| 59 | 59 | index &= 7; |
| 60 | | m_r[index] = data & 0xf; |
| 60 | data &= 0xf; |
| 61 | m_r[index] = data; |
| 61 | 62 | |
| 62 | 63 | switch (index) |
| 63 | 64 | { |
| r244819 | r244820 | |
| 86 | 87 | { |
| 87 | 88 | index &= 15; |
| 88 | 89 | |
| 89 | | m_d = (m_d & ~(1 << index)) | (state << index); |
| 90 | m_d = (m_d & ~(1 << index)) | (((state) ? 1 : 0) << index); |
| 90 | 91 | m_write_d(index, m_d, 0xffff); |
| 91 | 92 | } |
| 92 | 93 | |
| r244819 | r244820 | |
| 96 | 97 | |
| 97 | 98 | UINT8 hmcs43_cpu_device::read_r(int index) |
| 98 | 99 | { |
| 99 | | if ((index & 7) >= 4) |
| 100 | | logerror("%s read from unknown port R%d at $%04X\n", tag(), index & 7, m_prev_pc << 1); |
| 100 | index &= 7; |
| 101 | 101 | |
| 102 | if (index >= 2) |
| 103 | logerror("%s read from %s port R%d at $%04X\n", tag(), (index >= 4) ? "unknown" : "output", index, m_prev_pc << 1); |
| 104 | |
| 102 | 105 | return hmcs40_cpu_device::read_r(index); |
| 103 | 106 | } |
| 104 | 107 | |
| r244819 | r244820 | |
| 114 | 117 | |
| 115 | 118 | int hmcs43_cpu_device::read_d(int index) |
| 116 | 119 | { |
| 117 | | if ((index & 15) >= 4) |
| 120 | index &= 15; |
| 121 | |
| 122 | if (index >= 4) |
| 123 | { |
| 124 | logerror("%s read from output pin D%d at $%04X\n", tag(), index, m_prev_pc << 1); |
| 118 | 125 | return m_d >> index & 1; |
| 126 | } |
| 119 | 127 | else |
| 120 | 128 | return hmcs40_cpu_device::read_d(index); |
| 121 | 129 | } |
| r244819 | r244820 | |
| 126 | 134 | |
| 127 | 135 | UINT8 hmcs44_cpu_device::read_r(int index) |
| 128 | 136 | { |
| 129 | | if ((index & 7) >= 6) |
| 130 | | logerror("%s read from unknown port R%d at $%04X\n", tag(), index & 7, m_prev_pc << 1); |
| 137 | index &= 7; |
| 131 | 138 | |
| 139 | if (index >= 6) |
| 140 | logerror("%s read from unknown port R%d at $%04X\n", tag(), index, m_prev_pc << 1); |
| 141 | |
| 132 | 142 | return hmcs40_cpu_device::read_r(index); |
| 133 | 143 | } |
| 134 | 144 | |
| r244819 | r244820 | |
| 148 | 158 | |
| 149 | 159 | UINT8 hmcs45_cpu_device::read_r(int index) |
| 150 | 160 | { |
| 151 | | if ((index & 7) == 7) |
| 152 | | logerror("%s read from unknown port R%d at $%04X\n", tag(), index & 7, m_prev_pc << 1); |
| 161 | index &= 7; |
| 153 | 162 | |
| 163 | if (index >= 6) |
| 164 | logerror("%s read from %s port R%d at $%04X\n", tag(), (index == 7) ? "unknown" : "output", index, m_prev_pc << 1); |
| 165 | |
| 154 | 166 | return hmcs40_cpu_device::read_r(index); |
| 155 | 167 | } |
| 156 | 168 | |
| r244819 | r244820 | |
| 215 | 227 | // determine MR(Memory Register) location |
| 216 | 228 | UINT8 y = m_op & 0xf; |
| 217 | 229 | UINT8 x = (y > 3) ? 0xf : (y + 12); |
| 218 | | UINT8 address = (x << 4 | y) & m_datamask; |
| 230 | UINT16 address = (x << 4 | y) & m_datamask; |
| 219 | 231 | |
| 220 | 232 | UINT8 old_a = m_a; |
| 221 | 233 | m_a = m_data->read_byte(address) & 0xf; |
| r244819 | r244820 | |
| 555 | 567 | void hmcs40_cpu_device::op_tm() |
| 556 | 568 | { |
| 557 | 569 | // TM n: Test Memory Bit |
| 558 | | m_s = ((ram_r() & (1 << (m_op & 3))) != 0); |
| 570 | m_s = ram_r() >> (m_op & 3) & 1; |
| 559 | 571 | } |
| 560 | 572 | |
| 561 | 573 | |
| r244819 | r244820 | |
| 594 | 606 | void hmcs40_cpu_device::op_tbr() |
| 595 | 607 | { |
| 596 | 608 | // TBR p: Table Branch |
| 597 | | m_pc = (m_a | m_b << 4 | m_c << 8 | (m_op & 7) << 9) & m_pcmask; |
| 609 | UINT16 address = m_a | m_b << 4 | m_c << 8 | (m_op & 7) << 9 | (m_pc & ~0x3f); |
| 610 | m_pc = address & m_pcmask; |
| 598 | 611 | } |
| 599 | 612 | |
| 600 | 613 | void hmcs40_cpu_device::op_rtn() |
| r244819 | r244820 | |
| 781 | 794 | { |
| 782 | 795 | // P p: Pattern Generation |
| 783 | 796 | m_icount--; |
| 784 | | UINT16 address = (m_a | m_b << 4 | m_c << 8 | (m_op & 7) << 9) | (m_pc & ~0x3f); |
| 797 | UINT16 address = m_a | m_b << 4 | m_c << 8 | (m_op & 7) << 9 | (m_pc & ~0x3f); |
| 785 | 798 | UINT16 o = m_program->read_word((address & m_prgmask) << 1); |
| 786 | 799 | |
| 787 | 800 | // destination is determined by the 2 highest bits |