diff --git a/src/devices/cpu/e132xs/e132xs.cpp b/src/devices/cpu/e132xs/e132xs.cpp index 2ce0f55884c..0e3c58626a2 100644 --- a/src/devices/cpu/e132xs/e132xs.cpp +++ b/src/devices/cpu/e132xs/e132xs.cpp @@ -1839,14 +1839,14 @@ void hyperstone_device::execute_run() case 0xcd: execute_software(); break; // fcvtd case 0xce: hyperstone_extend(); break; case 0xcf: hyperstone_do(); break; - case 0xd0: hyperstone_ldwr_global(); break; - case 0xd1: hyperstone_ldwr_local(); break; - case 0xd2: hyperstone_lddr_global(); break; - case 0xd3: hyperstone_lddr_local(); break; - case 0xd4: hypesrtone_ldwp_global(); break; - case 0xd5: hypesrtone_ldwp_local(); break; - case 0xd6: hyperstone_lddp_global(); break; - case 0xd7: hyperstone_lddp_local(); break; + case 0xd0: hyperstone_ldwr(); break; + case 0xd1: hyperstone_ldwr(); break; + case 0xd2: hyperstone_lddr(); break; + case 0xd3: hyperstone_lddr(); break; + case 0xd4: hypesrtone_ldwp(); break; + case 0xd5: hypesrtone_ldwp(); break; + case 0xd6: hyperstone_lddp(); break; + case 0xd7: hyperstone_lddp(); break; case 0xd8: hyperstone_stwr_global(); break; case 0xd9: hyperstone_stwr_local(); break; case 0xda: hyperstone_stdr_global(); break; diff --git a/src/devices/cpu/e132xs/e132xs.h b/src/devices/cpu/e132xs/e132xs.h index 95313eb19fd..6ad97ea56a2 100644 --- a/src/devices/cpu/e132xs/e132xs.h +++ b/src/devices/cpu/e132xs/e132xs.h @@ -289,14 +289,10 @@ private: template void hyperstone_set(); - void hyperstone_ldwr_global(); - void hyperstone_ldwr_local(); - void hyperstone_lddr_global(); - void hyperstone_lddr_local(); - void hypesrtone_ldwp_global(); - void hypesrtone_ldwp_local(); - void hyperstone_lddp_global(); - void hyperstone_lddp_local(); + template void hyperstone_ldwr(); + template void hyperstone_lddr(); + template void hypesrtone_ldwp(); + template void hyperstone_lddp(); void hyperstone_stwr_global(); void hyperstone_stwr_local(); diff --git a/src/devices/cpu/e132xs/e132xsop.hxx b/src/devices/cpu/e132xs/e132xsop.hxx index 64bad9f74fe..00b230aedd3 100644 --- a/src/devices/cpu/e132xs/e132xsop.hxx +++ b/src/devices/cpu/e132xs/e132xsop.hxx @@ -4101,112 +4101,94 @@ void hyperstone_device::hyperstone_extend() } - -void hyperstone_device::hyperstone_ldwr_global() -{ - check_delay_PC(); - set_global_register(SRC_CODE, READ_W(m_local_regs[(DST_CODE + GET_FP) & 0x3f])); - m_icount -= m_clock_cycles_1; -} - -void hyperstone_device::hyperstone_ldwr_local() // ldwr local,local +template +void hyperstone_device::hyperstone_ldwr() { check_delay_PC(); const uint32_t fp = GET_FP; - m_local_regs[(SRC_CODE + fp) & 0x3f] = READ_W(m_local_regs[(DST_CODE + fp) & 0x3f]); + if (SRC_GLOBAL) + set_global_register(SRC_CODE, READ_W(m_local_regs[(DST_CODE + fp) & 0x3f])); + else + m_local_regs[(SRC_CODE + fp) & 0x3f] = READ_W(m_local_regs[(DST_CODE + fp) & 0x3f]); m_icount -= m_clock_cycles_1; } -void hyperstone_device::hyperstone_lddr_global() -{ - check_delay_PC(); - - const uint32_t src_code = SRC_CODE; - const uint32_t dreg = m_local_regs[(DST_CODE + GET_FP) & 0x3f]; - set_global_register(src_code, READ_W(dreg)); - set_global_register(src_code + 1, READ_W(dreg + 4)); - - m_icount -= m_clock_cycles_2; -} - -void hyperstone_device::hyperstone_lddr_local() +template +void hyperstone_device::hyperstone_lddr() { check_delay_PC(); const uint32_t fp = GET_FP; - const uint32_t src_code = SRC_CODE + fp; + const uint32_t src_code = SRC_GLOBAL ? SRC_CODE : ((SRC_CODE + fp) & 0x3f); const uint32_t dreg = m_local_regs[(DST_CODE + fp) & 0x3f]; - m_local_regs[src_code & 0x3f] = READ_W(dreg); - m_local_regs[(src_code + 1) & 0x3f] = READ_W(dreg + 4); - - m_icount -= m_clock_cycles_2; -} - -void hyperstone_device::hypesrtone_ldwp_global() -{ - check_delay_PC(); - - const uint32_t dst_code = (DST_CODE + GET_FP) & 0x3f; - set_global_register(SRC_CODE, READ_W(m_local_regs[dst_code])); - m_local_regs[dst_code] += 4; - - m_icount -= m_clock_cycles_1; -} - -void hyperstone_device::hypesrtone_ldwp_local() -{ - check_delay_PC(); - - const uint32_t fp = GET_FP; - const uint32_t src_code = (SRC_CODE + fp) & 0x3f; - const uint32_t dst_code = (DST_CODE + fp) & 0x3f; - - m_local_regs[src_code] = READ_W(m_local_regs[dst_code]); - - // post increment the destination register if it's different from the source one - // (needed by Hidden Catch) - if (src_code != dst_code) - m_local_regs[dst_code] += 4; - - m_icount -= m_clock_cycles_1; -} - -void hyperstone_device::hyperstone_lddp_global() -{ - check_delay_PC(); - - const uint32_t src_code = SRC_CODE; - const uint32_t dst_code = (DST_CODE + GET_FP) & 0x3f; - const uint32_t dreg = m_local_regs[dst_code]; - - set_global_register(src_code, READ_W(dreg)); - set_global_register(src_code + 1, READ_W(dreg + 4)); - - m_local_regs[dst_code] += 8; - - m_icount -= m_clock_cycles_2; -} - -void hyperstone_device::hyperstone_lddp_local() -{ - check_delay_PC(); - - const uint32_t fp = GET_FP; - const uint32_t src_code = SRC_CODE + fp; - const uint32_t dst_code = (DST_CODE + fp) & 0x3f; - const uint32_t dreg = m_local_regs[dst_code]; - const bool same_srcf_dst = (((src_code + 1) & 0x3f) == dst_code); - - m_local_regs[src_code & 0x3f] = READ_W(dreg); - m_local_regs[(src_code + 1) & 0x3f] = READ_W(dreg + 4); - - // post increment the destination register if it's different from the source one - // and from the "next source" one - if (src_code != dst_code && !same_srcf_dst) + if (SRC_GLOBAL) { + set_global_register(src_code, READ_W(dreg)); + set_global_register(src_code + 1, READ_W(dreg + 4)); + } + else + { + m_local_regs[src_code] = READ_W(dreg); + m_local_regs[(src_code + 1) & 0x3f] = READ_W(dreg + 4); + } + + m_icount -= m_clock_cycles_2; +} + +template +void hyperstone_device::hypesrtone_ldwp() +{ + check_delay_PC(); + + const uint32_t fp = GET_FP; + const uint32_t dst_code = (DST_CODE + fp) & 0x3f; + + if (SRC_GLOBAL) + { + set_global_register(SRC_CODE, READ_W(m_local_regs[dst_code])); + m_local_regs[dst_code] += 4; + } + else + { + const uint32_t src_code = (SRC_CODE + fp) & 0x3f; + m_local_regs[src_code] = READ_W(m_local_regs[dst_code]); + // post increment the destination register if it's different from the source one + // (needed by Hidden Catch) + if (src_code != dst_code) + m_local_regs[dst_code] += 4; + } + + m_icount -= m_clock_cycles_1; +} + +template +void hyperstone_device::hyperstone_lddp() +{ + check_delay_PC(); + + const uint32_t fp = GET_FP; + const uint32_t src_code = SRC_GLOBAL ? SRC_CODE : ((SRC_CODE + fp) & 0x3f); + const uint32_t dst_code = (DST_CODE + fp) & 0x3f; + const uint32_t dreg = m_local_regs[dst_code]; + + if (SRC_GLOBAL) + { + set_global_register(src_code, READ_W(dreg)); + set_global_register(src_code + 1, READ_W(dreg + 4)); m_local_regs[dst_code] += 8; } + else + { + const uint32_t srcf_code = (src_code + 1) & 0x3f; + m_local_regs[src_code] = READ_W(dreg); + m_local_regs[srcf_code] = READ_W(dreg + 4); + + // post increment the destination register if it's different from the source one + // and from the "next source" one + if (src_code != dst_code && srcf_code != dst_code) + m_local_regs[dst_code] += 8; + } m_icount -= m_clock_cycles_2; }