From 4f1f9878db93033d2fbb555359bca853c69b4467 Mon Sep 17 00:00:00 2001 From: FlykeSpice Date: Wed, 28 Jan 2026 02:19:31 -0400 Subject: [PATCH 1/4] tms320c2x: Small optimizations --- src/devices/cpu/tms320c2x/tms320c2x.cpp | 357 +++++++++++------------- src/devices/cpu/tms320c2x/tms320c2x.h | 58 ++-- src/mame/misc/coolpool.cpp | 12 +- src/mame/namco/namcos21_dsp.cpp | 1 - src/mame/namco/namcos21_dsp_c67.cpp | 1 - src/mame/namco/namcos22.cpp | 28 +- src/mame/namco/namcos22.h | 3 - 7 files changed, 184 insertions(+), 276 deletions(-) diff --git a/src/devices/cpu/tms320c2x/tms320c2x.cpp b/src/devices/cpu/tms320c2x/tms320c2x.cpp index 396ad3cfaab38..ef27a9a38e343 100644 --- a/src/devices/cpu/tms320c2x/tms320c2x.cpp +++ b/src/devices/cpu/tms320c2x/tms320c2x.cpp @@ -312,7 +312,7 @@ void tms320c2x_device::dxr_w(uint16_t data) if(TXM) { if(FSM) - m_waiting_for_serial_frame = 1; + m_waiting_for_serial_frame = true; else m_IFR |= 0x20; } @@ -370,12 +370,14 @@ inline void tms320c2x_device::MODIFY_DP(int data) m_STR0 |= (data & DP_REG); m_STR0 |= 0x0400; } + inline void tms320c2x_device::MODIFY_PM(int data) { m_STR1 &= ~PM_REG; m_STR1 |= (data & PM_REG); m_STR1 |= m_fixed_STR1; } + inline void tms320c2x_device::MODIFY_ARP(int data) { m_STR1 &= ~ARB_REG; @@ -386,12 +388,11 @@ inline void tms320c2x_device::MODIFY_ARP(int data) m_STR0 |= 0x0400; } -uint16_t tms320c2x_device::reverse_carry_add(uint16_t arg0, uint16_t arg1 ) +uint16_t tms320c2x_device::reverse_carry_add(uint16_t arg0, uint16_t arg1) { uint16_t result = 0; int carry = 0; - int count; - for (count = 0; count < 16; count++) + for (int count = 0; count < 16; count++) { int sum = (arg0 >> 15) + (arg1 >> 15) + carry; result = (result << 1) | (sum & 1); @@ -402,6 +403,7 @@ uint16_t tms320c2x_device::reverse_carry_add(uint16_t arg0, uint16_t arg1 ) return result; } +template inline void tms320c2x_device::MODIFY_AR_ARP() { /* modify address register referenced by ARP */ switch (m_opcode.b.l & 0x70) /* Cases ordered by predicted useage */ @@ -437,7 +439,7 @@ inline void tms320c2x_device::MODIFY_AR_ARP() break; } - if (!m_mHackIgnoreARP) + if (!IgnoreARPHack) { if (m_opcode.b.l & 8) { /* bit 3 determines if new value is loaded into ARP */ @@ -484,7 +486,7 @@ inline void tms320c2x_device::CALCULATE_ADD_OVERFLOW(int32_t addval) inline void tms320c2x_device::CALCULATE_SUB_OVERFLOW(int32_t subval) { - if ((int32_t)((m_oldacc.d ^ subval) & (m_oldacc.d ^ m_ACC.d)) < 0) + if (int32_t((m_oldacc.d ^ subval) & (m_oldacc.d ^ m_ACC.d)) < 0) { SET0(OV_FLAG); if (OVM) @@ -497,13 +499,14 @@ inline void tms320c2x_device::CALCULATE_SUB_OVERFLOW(int32_t subval) inline uint16_t tms320c2x_device::POP_STACK() { uint16_t const data = m_STACK[m_stack_limit]; - for (unsigned i = m_stack_limit; 0 < i; --i) + for (unsigned i = m_stack_limit; i > 0; --i) m_STACK[i] = m_STACK[i - 1]; return data; } + inline void tms320c2x_device::PUSH_STACK(uint16_t data) { - for (unsigned i = 0; m_stack_limit > i; ++i) + for (unsigned i = 0; i < m_stack_limit; ++i) m_STACK[i] = m_STACK[i + 1]; m_STACK[m_stack_limit] = data; } @@ -520,7 +523,8 @@ inline void tms320c2x_device::SHIFT_Preg_TO_ALU() } } -inline void tms320c2x_device::GETDATA(int shift,int signext) +template +inline void tms320c2x_device::GETDATA() { if (m_opcode.b.l & 0x80) { /* indirect memory access */ @@ -531,49 +535,40 @@ inline void tms320c2x_device::GETDATA(int shift,int signext) m_memaccess = DMA; } - if (m_memaccess >= 0x800) - { - m_external_mem_access = 1; /* Pause if hold pin is active */ - } - else - { - m_external_mem_access = 0; - } - m_ALU.d = (uint16_t)m_data.read_word(m_memaccess); - if (signext) m_ALU.d = (int16_t)m_ALU.d; - m_ALU.d <<= shift; /* next ARP */ - if (m_opcode.b.l & 0x80) MODIFY_AR_ARP(); + if (m_opcode.b.l & 0x80) MODIFY_AR_ARP(); +} + +inline void tms320c2x_device::GETDATA(int shift, int signext) +{ + GETDATA(); + + if (signext) + m_ALU.d = (int16_t)m_ALU.d; + + m_ALU.d <<= shift; } inline void tms320c2x_device::PUTDATA(uint16_t data) { if (m_opcode.b.l & 0x80) { - if (m_memaccess >= 0x800) m_external_mem_access = 1; /* Pause if hold pin is active */ - else m_external_mem_access = 0; - m_data.write_word(IND, data); MODIFY_AR_ARP(); } else { - if (m_memaccess >= 0x800) m_external_mem_access = 1; /* Pause if hold pin is active */ - else m_external_mem_access = 0; - m_data.write_word(DMA, data); } } + inline void tms320c2x_device::PUTDATA_SST(uint16_t data) { if (m_opcode.b.l & 0x80) m_memaccess = IND; else m_memaccess = DMApg0; - if (m_memaccess >= 0x800) m_external_mem_access = 1; /* Pause if hold pin is active */ - else m_external_mem_access = 0; - if (m_opcode.b.l & 0x80) { m_opcode.b.l &= 0xf7; /* Stop ARP changes */ MODIFY_AR_ARP(); @@ -599,7 +594,7 @@ void tms320c2x_device::illegal() void tms320c2x_device::abst() { - if ( (int32_t)(m_ACC.d) < 0 ) { + if ((int32_t)m_ACC.d < 0) { m_ACC.d = -m_ACC.d; if (m_ACC.d == 0x80000000) { SET0(OV_FLAG); @@ -619,7 +614,7 @@ void tms320c2x_device::add() void tms320c2x_device::addc() { m_oldacc.d = m_ACC.d; - GETDATA(0, 0); + GETDATA(); if (CARRY) m_ACC.d++; m_ACC.d += m_ALU.d; CALCULATE_ADD_OVERFLOW(m_ALU.d); @@ -629,12 +624,12 @@ void tms320c2x_device::addc() void tms320c2x_device::addh() { m_oldacc.d = m_ACC.d; - GETDATA(0, 0); + GETDATA(); m_ACC.w.h += m_ALU.w.l; - if ( (uint16_t)(m_oldacc.w.h) > (uint16_t)(m_ACC.w.h) ) { + if ((uint16_t)m_oldacc.w.h > (uint16_t)m_ACC.w.h) { SET1(C_FLAG); /* Carry flag is not cleared, if no carry occurred */ } - if ((int16_t)((m_ACC.w.h ^ m_ALU.w.l) & (m_oldacc.w.h ^ m_ACC.w.h)) < 0) { + if (int16_t((m_ACC.w.h ^ m_ALU.w.l) & (m_oldacc.w.h ^ m_ACC.w.h)) < 0) { SET0(OV_FLAG); if (OVM) m_ACC.w.h = ((int16_t)m_oldacc.w.h < 0) ? 0x8000 : 0x7fff; } @@ -650,7 +645,7 @@ void tms320c2x_device::addk() void tms320c2x_device::adds() { m_oldacc.d = m_ACC.d; - GETDATA(0, 0); + GETDATA(); m_ACC.d += m_ALU.d; CALCULATE_ADD_OVERFLOW(m_ALU.d); CALCULATE_ADD_CARRY(); @@ -680,7 +675,7 @@ void tms320c2x_device::adrk() } void tms320c2x_device::and_() { - GETDATA(0, 0); + GETDATA(); m_ACC.d &= m_ALU.d; } void tms320c2x_device::andk() @@ -734,13 +729,13 @@ void tms320c2x_device::bc() } void tms320c2x_device::bgez() { - if ( (int32_t)(m_ACC.d) >= 0 ) m_PC = m_cache.read_word(m_PC); + if ((int32_t)m_ACC.d >= 0) m_PC = m_cache.read_word(m_PC); else m_PC++; MODIFY_AR_ARP(); } void tms320c2x_device::bgz() { - if ( (int32_t)(m_ACC.d) > 0 ) m_PC = m_cache.read_word(m_PC); + if ((int32_t)m_ACC.d > 0) m_PC = m_cache.read_word(m_PC); else m_PC++; MODIFY_AR_ARP(); } @@ -752,19 +747,19 @@ void tms320c2x_device::bioz() } void tms320c2x_device::bit() { - GETDATA(0, 0); + GETDATA(); if (m_ALU.d & (0x8000 >> (m_opcode.b.h & 0xf))) SET1(TC_FLAG); else CLR1(TC_FLAG); } void tms320c2x_device::bitt() { - GETDATA(0, 0); + GETDATA(); if (m_ALU.d & (0x8000 >> (m_Treg & 0xf))) SET1(TC_FLAG); else CLR1(TC_FLAG); } void tms320c2x_device::blez() { - if ( (int32_t)(m_ACC.d) <= 0 ) m_PC = m_cache.read_word(m_PC); + if ((int32_t)m_ACC.d <= 0) m_PC = m_cache.read_word(m_PC); else m_PC++; MODIFY_AR_ARP(); } @@ -792,7 +787,7 @@ void tms320c2x_device::blkp() } void tms320c2x_device::blz() { - if ( (int32_t)(m_ACC.d) < 0 ) m_PC = m_cache.read_word(m_PC); + if ((int32_t)m_ACC.d < 0) m_PC = m_cache.read_word(m_PC); else m_PC++; MODIFY_AR_ARP(); } @@ -853,19 +848,19 @@ void tms320c2x_device::cmpr() switch (m_opcode.b.l & 3) { case 0: - if ( (uint16_t)(m_AR[ARP]) == (uint16_t)(m_AR[0]) ) SET1(TC_FLAG); + if (m_AR[ARP] == m_AR[0]) SET1(TC_FLAG); else CLR1(TC_FLAG); break; case 1: - if ( (uint16_t)(m_AR[ARP]) < (uint16_t)(m_AR[0]) ) SET1(TC_FLAG); + if (m_AR[ARP] < m_AR[0]) SET1(TC_FLAG); else CLR1(TC_FLAG); break; case 2: - if ( (uint16_t)(m_AR[ARP]) > (uint16_t)(m_AR[0]) ) SET1(TC_FLAG); + if (m_AR[ARP] > m_AR[0]) SET1(TC_FLAG); else CLR1(TC_FLAG); break; case 3: - if ( (uint16_t)(m_AR[ARP]) != (uint16_t)(m_AR[0]) ) SET1(TC_FLAG); + if (m_AR[ARP] != m_AR[0]) SET1(TC_FLAG); else CLR1(TC_FLAG); break; } @@ -889,17 +884,17 @@ void tms320c2x_device::cnfp() /** next two fetches need to use previous CNF val void tms320c2x_device::conf() { - // Disabled on TMS320C25 + // Disabled on tms320c2x } void tms320c26_device::cnfd() { - // Disabled on TMS320C26 + // Disabled on tms320c26 } void tms320c26_device::cnfp() { - // Disabled on TMS320C26 + // Disabled on tms320c26 } void tms320c26_device::conf() /** Need to reconfigure the memory blocks */ @@ -947,7 +942,7 @@ void tms320c2x_device::dint() } void tms320c2x_device::dmov() /** Careful with how memory is configured !! */ { - GETDATA(0, 0); + GETDATA(); m_data.write_word(m_memaccess + 1, m_ALU.w.l); } void tms320c2x_device::eint() @@ -962,7 +957,7 @@ void tms320c2x_device::fort() void tms320c2x_device::idle() { CLR0(INTM_FLAG); - m_idle = 1; + m_idle = true; } void tms320c2x_device::in() { @@ -991,25 +986,16 @@ void tms320c2x_device::lalk() m_ALU.d <<= (m_opcode.b.h & 0xf); m_ACC.d = m_ALU.d; } -void tms320c2x_device::lar_ar0() { GETDATA(0, 0); m_AR[0] = m_ALU.w.l; } -void tms320c2x_device::lar_ar1() { GETDATA(0, 0); m_AR[1] = m_ALU.w.l; } -void tms320c2x_device::lar_ar2() { GETDATA(0, 0); m_AR[2] = m_ALU.w.l; } -void tms320c2x_device::lar_ar3() { GETDATA(0, 0); m_AR[3] = m_ALU.w.l; } -void tms320c2x_device::lar_ar4() { GETDATA(0, 0); m_AR[4] = m_ALU.w.l; } -void tms320c2x_device::lar_ar5() { GETDATA(0, 0); m_AR[5] = m_ALU.w.l; } -void tms320c2x_device::lar_ar6() { GETDATA(0, 0); m_AR[6] = m_ALU.w.l; } -void tms320c2x_device::lar_ar7() { GETDATA(0, 0); m_AR[7] = m_ALU.w.l; } -void tms320c2x_device::lark_ar0() { m_AR[0] = m_opcode.b.l; } -void tms320c2x_device::lark_ar1() { m_AR[1] = m_opcode.b.l; } -void tms320c2x_device::lark_ar2() { m_AR[2] = m_opcode.b.l; } -void tms320c2x_device::lark_ar3() { m_AR[3] = m_opcode.b.l; } -void tms320c2x_device::lark_ar4() { m_AR[4] = m_opcode.b.l; } -void tms320c2x_device::lark_ar5() { m_AR[5] = m_opcode.b.l; } -void tms320c2x_device::lark_ar6() { m_AR[6] = m_opcode.b.l; } -void tms320c2x_device::lark_ar7() { m_AR[7] = m_opcode.b.l; } + +template +void tms320c2x_device::lar_ar() { GETDATA(); m_AR[N] = m_ALU.w.l; } + +template +void tms320c2x_device::lark_ar() { m_AR[N] = m_opcode.b.l; } + void tms320c2x_device::ldp() { - GETDATA(0, 0); + GETDATA(); MODIFY_DP(m_ALU.d & 0x1ff); } void tms320c2x_device::ldpk() @@ -1018,7 +1004,7 @@ void tms320c2x_device::ldpk() } void tms320c2x_device::lph() { - GETDATA(0, 0); + GETDATA(); m_Preg.w.h = m_ALU.w.l; } void tms320c2x_device::lrlk() @@ -1029,9 +1015,7 @@ void tms320c2x_device::lrlk() } void tms320c2x_device::lst() { - m_mHackIgnoreARP = 1; - GETDATA(0, 0); - m_mHackIgnoreARP = 0; + GETDATA(); m_ALU.w.l &= (~INTM_FLAG); m_STR0 &= INTM_FLAG; @@ -1040,9 +1024,7 @@ void tms320c2x_device::lst() } void tms320c2x_device::lst1() { - m_mHackIgnoreARP = 1; - GETDATA(0, 0); - m_mHackIgnoreARP = 0; + GETDATA(); m_STR1 = m_ALU.w.l | m_fixed_STR1; m_STR0 &= (~ARP_REG); /* ARB also gets copied to ARP */ @@ -1050,13 +1032,13 @@ void tms320c2x_device::lst1() } void tms320c2x_device::lt() { - GETDATA(0, 0); + GETDATA(); m_Treg = m_ALU.w.l; } void tms320c2x_device::lta() { m_oldacc.d = m_ACC.d; - GETDATA(0, 0); + GETDATA(); m_Treg = m_ALU.w.l; SHIFT_Preg_TO_ALU(); m_ACC.d += m_ALU.d; @@ -1066,7 +1048,7 @@ void tms320c2x_device::lta() void tms320c2x_device::ltd() /** Careful with how memory is configured !! */ { m_oldacc.d = m_ACC.d; - GETDATA(0, 0); + GETDATA(); m_Treg = m_ALU.w.l; m_data.write_word(m_memaccess+1, m_ALU.w.l); SHIFT_Preg_TO_ALU(); @@ -1077,7 +1059,7 @@ void tms320c2x_device::ltd() /** Careful with how memory is configured !! */ void tms320c2x_device::ltp() { m_oldacc.d = m_ACC.d; - GETDATA(0, 0); + GETDATA(); m_Treg = m_ALU.w.l; SHIFT_Preg_TO_ALU(); m_ACC.d = m_ALU.d; @@ -1085,7 +1067,7 @@ void tms320c2x_device::ltp() void tms320c2x_device::lts() { m_oldacc.d = m_ACC.d; - GETDATA(0, 0); + GETDATA(); m_Treg = m_ALU.w.l; SHIFT_Preg_TO_ALU(); m_ACC.d -= m_ALU.d; @@ -1103,9 +1085,9 @@ void tms320c2x_device::mac() /** RAM blocks B0,B1,B2 may be important m_ACC.d += m_ALU.d; CALCULATE_ADD_OVERFLOW(m_ALU.d); CALCULATE_ADD_CARRY(); - GETDATA(0, 0); + GETDATA(); m_Treg = m_ALU.w.l; - m_Preg.d = ( (int16_t)m_ALU.w.l * (int16_t)m_cache.read_word(m_PFC) ); + m_Preg.d = (int16_t)m_ALU.w.l * (int16_t)m_cache.read_word(m_PFC); m_PFC++; m_tms320c2x_dec_cycles += (2*CLK); } @@ -1120,12 +1102,12 @@ void tms320c2x_device::macd() /** RAM blocks B0,B1,B2 may be important m_ACC.d += m_ALU.d; CALCULATE_ADD_OVERFLOW(m_ALU.d); CALCULATE_ADD_CARRY(); - GETDATA(0, 0); - if ( (m_opcode.b.l & 0x80) || m_init_load_addr ) { /* No writing during repetition, or DMA mode */ + GETDATA(); + if ((m_opcode.b.l & 0x80) || m_init_load_addr) { /* No writing during repetition, or DMA mode */ m_data.write_word(m_memaccess+1, m_ALU.w.l); } m_Treg = m_ALU.w.l; - m_Preg.d = ( (int16_t)m_ALU.w.l * (int16_t)m_cache.read_word(m_PFC) ); + m_Preg.d = (int16_t)m_ALU.w.l * (int16_t)m_cache.read_word(m_PFC); m_PFC++; m_tms320c2x_dec_cycles += (2*CLK); } @@ -1135,8 +1117,8 @@ void tms320c2x_device::mar() /* LARP and NOP are a subset of this instruct } void tms320c2x_device::mpy() { - GETDATA(0, 0); - m_Preg.d = (int16_t)(m_ALU.w.l) * (int16_t)(m_Treg); + GETDATA(); + m_Preg.d = (int16_t)m_ALU.w.l * (int16_t)m_Treg; } void tms320c2x_device::mpya() { @@ -1145,13 +1127,12 @@ void tms320c2x_device::mpya() m_ACC.d += m_ALU.d; CALCULATE_ADD_OVERFLOW(m_ALU.d); CALCULATE_ADD_CARRY(); - GETDATA(0, 0); - m_Preg.d = (int16_t)(m_ALU.w.l) * (int16_t)(m_Treg); + GETDATA(); + m_Preg.d = (int16_t)m_ALU.w.l * (int16_t)m_Treg; } void tms320c2x_device::mpyk() { - m_Preg.d = (int16_t)m_Treg * ((int16_t)(m_opcode.w.l << 3) >> 3); - + m_Preg.d = (int16_t)m_Treg * (int16_t(m_opcode.w.l << 3) >> 3); } void tms320c2x_device::mpys() { @@ -1160,13 +1141,13 @@ void tms320c2x_device::mpys() m_ACC.d -= m_ALU.d; CALCULATE_SUB_OVERFLOW(m_ALU.d); CALCULATE_SUB_CARRY(); - GETDATA(0, 0); - m_Preg.d = (int16_t)(m_ALU.w.l) * (int16_t)(m_Treg); + GETDATA(); + m_Preg.d = (int16_t)m_ALU.w.l * (int16_t)m_Treg; } void tms320c2x_device::mpyu() { - GETDATA(0, 0); - m_Preg.d = (uint16_t)(m_ALU.w.l) * (uint16_t)(m_Treg); + GETDATA(); + m_Preg.d = (uint16_t)m_ALU.w.l * (uint16_t)m_Treg; } void tms320c2x_device::neg() { @@ -1183,7 +1164,7 @@ void tms320c2x_device::nop() { } // NOP is a subset of the MAR instruction */ void tms320c2x_device::norm() { - if (m_ACC.d !=0 && (int32_t)(m_ACC.d ^ (m_ACC.d << 1)) >= 0) + if (m_ACC.d !=0 && int32_t(m_ACC.d ^ (m_ACC.d << 1)) >= 0) { CLR1(TC_FLAG); m_ACC.d <<= 1; @@ -1193,7 +1174,7 @@ void tms320c2x_device::norm() } void tms320c2x_device::or_() { - GETDATA(0, 0); + GETDATA(); m_ACC.w.l |= m_ALU.w.l; } void tms320c2x_device::ork() @@ -1205,7 +1186,7 @@ void tms320c2x_device::ork() } void tms320c2x_device::out() { - GETDATA(0, 0); + GETDATA(); m_io.write_word(m_opcode.b.h & 0xf, m_ALU.w.l ); } void tms320c2x_device::pac() @@ -1224,7 +1205,7 @@ void tms320c2x_device::popd() } void tms320c2x_device::pshd() { - GETDATA(0, 0); + GETDATA(); PUSH_STACK(m_ALU.w.l); } void tms320c2x_device::push() @@ -1269,7 +1250,7 @@ void tms320c2x_device::rovm() } void tms320c2x_device::rpt() { - GETDATA(0, 0); + GETDATA(); m_RPTC = m_ALU.b.l; m_init_load_addr = 2; /* Initiate repeat mode */ } @@ -1305,14 +1286,9 @@ void tms320c2x_device::sacl() m_ALU.d = (m_ACC.d << (m_opcode.b.h & 7)); PUTDATA(m_ALU.w.l); } -void tms320c2x_device::sar_ar0() { PUTDATA(m_AR[0]); } -void tms320c2x_device::sar_ar1() { PUTDATA(m_AR[1]); } -void tms320c2x_device::sar_ar2() { PUTDATA(m_AR[2]); } -void tms320c2x_device::sar_ar3() { PUTDATA(m_AR[3]); } -void tms320c2x_device::sar_ar4() { PUTDATA(m_AR[4]); } -void tms320c2x_device::sar_ar5() { PUTDATA(m_AR[5]); } -void tms320c2x_device::sar_ar6() { PUTDATA(m_AR[6]); } -void tms320c2x_device::sar_ar7() { PUTDATA(m_AR[7]); } + +template +void tms320c2x_device::sar_ar() { PUTDATA(m_AR[N]); } void tms320c2x_device::sblk() { @@ -1391,9 +1367,9 @@ void tms320c2x_device::sqra() m_ACC.d += m_ALU.d; CALCULATE_ADD_OVERFLOW(m_ALU.d); CALCULATE_ADD_CARRY(); - GETDATA(0, 0); + GETDATA(); m_Treg = m_ALU.w.l; - m_Preg.d = ((int16_t)m_ALU.w.l * (int16_t)m_ALU.w.l); + m_Preg.d = (int16_t)m_ALU.w.l * (int16_t)m_ALU.w.l; } void tms320c2x_device::sqrs() { @@ -1402,9 +1378,9 @@ void tms320c2x_device::sqrs() m_ACC.d -= m_ALU.d; CALCULATE_SUB_OVERFLOW(m_ALU.d); CALCULATE_SUB_CARRY(); - GETDATA(0, 0); + GETDATA(); m_Treg = m_ALU.w.l; - m_Preg.d = ((int16_t)m_ALU.w.l * (int16_t)m_ALU.w.l); + m_Preg.d = (int16_t)m_ALU.w.l * (int16_t)m_ALU.w.l; } void tms320c2x_device::sst() { @@ -1437,7 +1413,7 @@ void tms320c2x_device::sub() void tms320c2x_device::subb() { m_oldacc.d = m_ACC.d; - GETDATA(0, 0); + GETDATA(); if (CARRY == 0) m_ACC.d--; m_ACC.d -= m_ALU.d; CALCULATE_SUB_OVERFLOW(m_ALU.d); @@ -1449,7 +1425,7 @@ void tms320c2x_device::subc() m_oldacc.d = m_ACC.d; GETDATA(15, SXM); m_ACC.d -= m_ALU.d; /* Temporary switch to ACC. Actual calculation is done as (ACC)-[mem] -> ALU, will be preserved later on. */ - if ((int32_t)((m_oldacc.d ^ m_ALU.d) & (m_oldacc.d ^ m_ACC.d)) < 0) { + if (int32_t((m_oldacc.d ^ m_ALU.d) & (m_oldacc.d ^ m_ACC.d)) < 0) { SET0(OV_FLAG); /* Not affected by OVM */ } CALCULATE_SUB_CARRY(); @@ -1465,12 +1441,12 @@ void tms320c2x_device::subc() void tms320c2x_device::subh() { m_oldacc.d = m_ACC.d; - GETDATA(0, 0); + GETDATA(); m_ACC.w.h -= m_ALU.w.l; - if ( (uint16_t)(m_oldacc.w.h) < (uint16_t)(m_ACC.w.h) ) { + if ((uint16_t)m_oldacc.w.h < (uint16_t)m_ACC.w.h) { CLR1(C_FLAG); /* Carry flag is not affected, if no borrow occurred */ } - if ((int16_t)((m_oldacc.w.h ^ m_ALU.w.l) & (m_oldacc.w.h ^ m_ACC.w.h)) < 0) { + if (int16_t((m_oldacc.w.h ^ m_ALU.w.l) & (m_oldacc.w.h ^ m_ACC.w.h)) < 0) { SET0(OV_FLAG); if (OVM) m_ACC.w.h = ((int16_t)m_oldacc.w.h < 0) ? 0x8000 : 0x7fff; } @@ -1486,7 +1462,7 @@ void tms320c2x_device::subk() void tms320c2x_device::subs() { m_oldacc.d = m_ACC.d; - GETDATA(0, 0); + GETDATA(); m_ACC.d -= m_ALU.w.l; CALCULATE_SUB_OVERFLOW(m_ALU.d); CALCULATE_SUB_CARRY(); @@ -1510,7 +1486,7 @@ void tms320c2x_device::tblr() m_PFC = m_ACC.w.l; } m_ALU.w.l = m_cache.read_word(m_PFC); - if ( (CNF0) && ( (uint16_t)(m_PFC) >= 0xff00 ) ) {} /** TMS320C25 only */ + if (CNF0 && (uint16_t)m_PFC >= 0xff00) {} /** TMS320C25 only */ else m_tms320c2x_dec_cycles += (1*CLK); PUTDATA(m_ALU.w.l); m_PFC++; @@ -1521,8 +1497,8 @@ void tms320c2x_device::tblw() m_PFC = m_ACC.w.l; } m_tms320c2x_dec_cycles += (1*CLK); - GETDATA(0, 0); - if (m_external_mem_access) m_tms320c2x_dec_cycles += (1*CLK); + GETDATA(); + if (is_mem_access_external()) m_tms320c2x_dec_cycles += (1*CLK); m_program.write_word(m_PFC, m_ALU.w.l); m_PFC++; } @@ -1533,7 +1509,7 @@ void tms320c2x_device::trap() } void tms320c2x_device::xor_() { - GETDATA(0, 0); + GETDATA(); m_ACC.w.l ^= m_ALU.w.l; } void tms320c2x_device::xork() @@ -1545,19 +1521,19 @@ void tms320c2x_device::xork() } void tms320c2x_device::zalh() { - GETDATA(0, 0); + GETDATA(); m_ACC.w.h = m_ALU.w.l; m_ACC.w.l = 0x0000; } void tms320c2x_device::zalr() { - GETDATA(0, 0); + GETDATA(); m_ACC.w.h = m_ALU.w.l; m_ACC.w.l = 0x8000; } void tms320c2x_device::zals() { - GETDATA(0, 0); + GETDATA(); m_ACC.w.l = m_ALU.w.l; m_ACC.w.h = 0x0000; } @@ -1575,7 +1551,7 @@ const tms320c2x_device::tms320c2x_opcode tms320c2x_device::s_opcode_main[256]= /*18*/ {1*CLK, &tms320c2x_device::sub },{1*CLK, &tms320c2x_device::sub },{1*CLK, &tms320c2x_device::sub },{1*CLK, &tms320c2x_device::sub },{1*CLK, &tms320c2x_device::sub },{1*CLK, &tms320c2x_device::sub },{1*CLK, &tms320c2x_device::sub },{1*CLK, &tms320c2x_device::sub }, /*20*/ {1*CLK, &tms320c2x_device::lac },{1*CLK, &tms320c2x_device::lac },{1*CLK, &tms320c2x_device::lac },{1*CLK, &tms320c2x_device::lac },{1*CLK, &tms320c2x_device::lac },{1*CLK, &tms320c2x_device::lac },{1*CLK, &tms320c2x_device::lac },{1*CLK, &tms320c2x_device::lac }, /*28*/ {1*CLK, &tms320c2x_device::lac },{1*CLK, &tms320c2x_device::lac },{1*CLK, &tms320c2x_device::lac },{1*CLK, &tms320c2x_device::lac },{1*CLK, &tms320c2x_device::lac },{1*CLK, &tms320c2x_device::lac },{1*CLK, &tms320c2x_device::lac },{1*CLK, &tms320c2x_device::lac }, -/*30*/ {1*CLK, &tms320c2x_device::lar_ar0 },{1*CLK, &tms320c2x_device::lar_ar1 },{1*CLK, &tms320c2x_device::lar_ar2 },{1*CLK, &tms320c2x_device::lar_ar3 },{1*CLK, &tms320c2x_device::lar_ar4 },{1*CLK, &tms320c2x_device::lar_ar5 },{1*CLK, &tms320c2x_device::lar_ar6 },{1*CLK, &tms320c2x_device::lar_ar7 }, +/*30*/ {1*CLK, &tms320c2x_device::lar_ar<0>},{1*CLK, &tms320c2x_device::lar_ar<1> },{1*CLK, &tms320c2x_device::lar_ar<2> },{1*CLK, &tms320c2x_device::lar_ar<3> },{1*CLK, &tms320c2x_device::lar_ar<4> },{1*CLK, &tms320c2x_device::lar_ar<5>},{1*CLK, &tms320c2x_device::lar_ar<6> },{1*CLK, &tms320c2x_device::lar_ar<7> }, /*38*/ {1*CLK, &tms320c2x_device::mpy },{1*CLK, &tms320c2x_device::sqra },{1*CLK, &tms320c2x_device::mpya },{1*CLK, &tms320c2x_device::mpys },{1*CLK, &tms320c2x_device::lt },{1*CLK, &tms320c2x_device::lta },{1*CLK, &tms320c2x_device::ltp },{1*CLK, &tms320c2x_device::ltd }, /*40*/ {1*CLK, &tms320c2x_device::zalh },{1*CLK, &tms320c2x_device::zals },{1*CLK, &tms320c2x_device::lact },{1*CLK, &tms320c2x_device::addc },{1*CLK, &tms320c2x_device::subh },{1*CLK, &tms320c2x_device::subs },{1*CLK, &tms320c2x_device::subt },{1*CLK, &tms320c2x_device::subc }, /*48*/ {1*CLK, &tms320c2x_device::addh },{1*CLK, &tms320c2x_device::adds },{1*CLK, &tms320c2x_device::addt },{1*CLK, &tms320c2x_device::rpt },{1*CLK, &tms320c2x_device::xor_ },{1*CLK, &tms320c2x_device::or_ },{1*CLK, &tms320c2x_device::and_ },{1*CLK, &tms320c2x_device::subb }, @@ -1583,7 +1559,7 @@ const tms320c2x_device::tms320c2x_opcode tms320c2x_device::s_opcode_main[256]= /*58*/ {3*CLK, &tms320c2x_device::tblr },{2*CLK, &tms320c2x_device::tblw },{1*CLK, &tms320c2x_device::sqrs },{1*CLK, &tms320c2x_device::lts },{2*CLK, &tms320c2x_device::macd },{2*CLK, &tms320c2x_device::mac },{2*CLK, &tms320c2x_device::bc },{2*CLK, &tms320c2x_device::bnc }, /*60*/ {1*CLK, &tms320c2x_device::sacl },{1*CLK, &tms320c2x_device::sacl },{1*CLK, &tms320c2x_device::sacl },{1*CLK, &tms320c2x_device::sacl },{1*CLK, &tms320c2x_device::sacl },{1*CLK, &tms320c2x_device::sacl },{1*CLK, &tms320c2x_device::sacl },{1*CLK, &tms320c2x_device::sacl }, /*68*/ {1*CLK, &tms320c2x_device::sach },{1*CLK, &tms320c2x_device::sach },{1*CLK, &tms320c2x_device::sach },{1*CLK, &tms320c2x_device::sach },{1*CLK, &tms320c2x_device::sach },{1*CLK, &tms320c2x_device::sach },{1*CLK, &tms320c2x_device::sach },{1*CLK, &tms320c2x_device::sach }, -/*70*/ {1*CLK, &tms320c2x_device::sar_ar0 },{1*CLK, &tms320c2x_device::sar_ar1 },{1*CLK, &tms320c2x_device::sar_ar2 },{1*CLK, &tms320c2x_device::sar_ar3 },{1*CLK, &tms320c2x_device::sar_ar4 },{1*CLK, &tms320c2x_device::sar_ar5 },{1*CLK, &tms320c2x_device::sar_ar6 },{1*CLK, &tms320c2x_device::sar_ar7 }, +/*70*/ {1*CLK, &tms320c2x_device::sar_ar<0>},{1*CLK, &tms320c2x_device::sar_ar<1> },{1*CLK, &tms320c2x_device::sar_ar<2> },{1*CLK, &tms320c2x_device::sar_ar<3> },{1*CLK, &tms320c2x_device::sar_ar<4> },{1*CLK, &tms320c2x_device::sar_ar<5> },{1*CLK, &tms320c2x_device::sar_ar<6> },{1*CLK, &tms320c2x_device::sar_ar<7> }, /*78*/ {1*CLK, &tms320c2x_device::sst },{1*CLK, &tms320c2x_device::sst1 },{1*CLK, &tms320c2x_device::popd },{1*CLK, &tms320c2x_device::zalr },{1*CLK, &tms320c2x_device::spl },{1*CLK, &tms320c2x_device::sph },{1*CLK, &tms320c2x_device::adrk },{1*CLK, &tms320c2x_device::sbrk_ar }, /*80*/ {2*CLK, &tms320c2x_device::in },{2*CLK, &tms320c2x_device::in },{2*CLK, &tms320c2x_device::in },{2*CLK, &tms320c2x_device::in },{2*CLK, &tms320c2x_device::in },{2*CLK, &tms320c2x_device::in },{2*CLK, &tms320c2x_device::in },{2*CLK, &tms320c2x_device::in }, /*88*/ {2*CLK, &tms320c2x_device::in },{2*CLK, &tms320c2x_device::in },{2*CLK, &tms320c2x_device::in },{2*CLK, &tms320c2x_device::in },{2*CLK, &tms320c2x_device::in },{2*CLK, &tms320c2x_device::in },{2*CLK, &tms320c2x_device::in },{2*CLK, &tms320c2x_device::in }, @@ -1593,7 +1569,7 @@ const tms320c2x_device::tms320c2x_opcode tms320c2x_device::s_opcode_main[256]= /*A8*/ {1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk }, /*B0*/ {1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk }, /*B8*/ {1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk },{1*CLK, &tms320c2x_device::mpyk }, -/*C0*/ {1*CLK, &tms320c2x_device::lark_ar0 },{1*CLK, &tms320c2x_device::lark_ar1 },{1*CLK, &tms320c2x_device::lark_ar2 },{1*CLK, &tms320c2x_device::lark_ar3 },{1*CLK, &tms320c2x_device::lark_ar4 },{1*CLK, &tms320c2x_device::lark_ar5 },{1*CLK, &tms320c2x_device::lark_ar6 },{1*CLK, &tms320c2x_device::lark_ar7 }, +/*C0*/ {1*CLK, &tms320c2x_device::lark_ar<0>},{1*CLK, &tms320c2x_device::lark_ar<1>},{1*CLK, &tms320c2x_device::lark_ar<2>},{1*CLK, &tms320c2x_device::lark_ar<3>},{1*CLK, &tms320c2x_device::lark_ar<4>},{1*CLK, &tms320c2x_device::lark_ar<5>},{1*CLK, &tms320c2x_device::lark_ar<6>},{1*CLK, &tms320c2x_device::lark_ar<7>}, /*C8*/ {1*CLK, &tms320c2x_device::ldpk },{1*CLK, &tms320c2x_device::ldpk },{1*CLK, &tms320c2x_device::lack },{1*CLK, &tms320c2x_device::rptk },{1*CLK, &tms320c2x_device::addk },{1*CLK, &tms320c2x_device::subk },{1*CLK, &tms320c2x_device::opcodes_CE},{1*CLK, &tms320c2x_device::mpyu }, /*D0*/ {1*CLK, &tms320c2x_device::opcodes_Dx},{1*CLK, &tms320c2x_device::opcodes_Dx},{1*CLK, &tms320c2x_device::opcodes_Dx},{1*CLK, &tms320c2x_device::opcodes_Dx},{1*CLK, &tms320c2x_device::opcodes_Dx},{1*CLK, &tms320c2x_device::opcodes_Dx},{1*CLK, &tms320c2x_device::opcodes_Dx},{0*CLK, &tms320c2x_device::opcodes_Dx}, /*D8*/ {1*CLK, &tms320c2x_device::opcodes_Dx},{1*CLK, &tms320c2x_device::opcodes_Dx},{1*CLK, &tms320c2x_device::opcodes_Dx},{1*CLK, &tms320c2x_device::opcodes_Dx},{1*CLK, &tms320c2x_device::opcodes_Dx},{1*CLK, &tms320c2x_device::opcodes_Dx},{1*CLK, &tms320c2x_device::opcodes_Dx},{1*CLK, &tms320c2x_device::opcodes_Dx}, @@ -1670,12 +1646,8 @@ void tms320c2x_device::device_start() m_dxr = 0; m_timerover = 0; m_opcode.d = 0; - m_external_mem_access = 0; - m_tms320c2x_irq_cycles = 0; - m_oldacc.d = 0; m_memaccess = 0; - m_mHackIgnoreARP = 0; - m_waiting_for_serial_frame = 0; + m_waiting_for_serial_frame = false; save_item(NAME(m_PREVPC)); save_item(NAME(m_PC)); @@ -1701,10 +1673,8 @@ void tms320c2x_device::device_start() save_item(NAME(m_idle)); save_item(NAME(m_hold)); - save_item(NAME(m_external_mem_access)); save_item(NAME(m_init_load_addr)); - save_item(NAME(m_oldacc.d)); save_item(NAME(m_memaccess)); save_item(NAME(m_waiting_for_serial_frame)); @@ -1811,8 +1781,8 @@ void tms320c2x_device::common_reset() m_prd = 0xffff; m_imr = 0xffc0; - m_idle = 0; - m_hold = 0; + m_idle = false; + m_hold = false; m_tms320c2x_dec_cycles = 0; m_init_load_addr = 1; } @@ -1843,70 +1813,68 @@ inline int tms320c2x_device::process_IRQs() | XINT| RINT| TINT| INT2| INT1| INT0| */ - m_tms320c2x_irq_cycles = 0; - /* Dont service Interrupts if masked, or prev instruction was EINT ! */ if ( (INTM == 0) && (m_opcode.w.l != 0xce00) && (m_IFR & m_imr) ) { - m_tms320c2x_irq_cycles = (3*CLK); /* 3 clock cycles used due to PUSH and DINT operation ? */ + const int irq_cycles = (3*CLK); /* 3 clock cycles used due to PUSH and DINT operation ? */ PUSH_STACK(m_PC); if ((m_IFR & 0x01) && (m_imr & 0x01)) { /* IRQ line 0 */ //logerror("TMS320C2x: Active INT0\n"); standard_irq_callback(0, m_PC); m_PC = 0x0002; - m_idle = 0; + m_idle = false; m_IFR &= (~0x01); SET0(INTM_FLAG); - return m_tms320c2x_irq_cycles; + return irq_cycles; } if ((m_IFR & 0x02) && (m_imr & 0x02)) { /* IRQ line 1 */ //logerror("TMS320C2x: Active INT1\n"); standard_irq_callback(1, m_PC); m_PC = 0x0004; - m_idle = 0; + m_idle = false; m_IFR &= (~0x02); SET0(INTM_FLAG); - return m_tms320c2x_irq_cycles; + return irq_cycles; } if ((m_IFR & 0x04) && (m_imr & 0x04)) { /* IRQ line 2 */ //logerror("TMS320C2x: Active INT2\n"); standard_irq_callback(2, m_PC); m_PC = 0x0006; - m_idle = 0; + m_idle = false; m_IFR &= (~0x04); SET0(INTM_FLAG); - return m_tms320c2x_irq_cycles; + return irq_cycles; } if ((m_IFR & 0x08) && (m_imr & 0x08)) { /* Timer IRQ (internal) */ -// logerror("TMS320C2x: Active TINT (Timer)\n"); + //logerror("TMS320C2x: Active TINT (Timer)\n"); m_PC = 0x0018; - m_idle = 0; + m_idle = false; m_IFR &= (~0x08); SET0(INTM_FLAG); - return m_tms320c2x_irq_cycles; + return irq_cycles; } if ((m_IFR & 0x10) && (m_imr & 0x10)) { /* Serial port receive IRQ (internal) */ -// logerror("TMS320C2x: Active RINT (Serial receive)\n"); + //logerror("TMS320C2x: Active RINT (Serial receive)\n"); m_drr = m_dr_in(); m_PC = 0x001A; - m_idle = 0; + m_idle = false; m_IFR &= (~0x10); SET0(INTM_FLAG); - return m_tms320c2x_irq_cycles; + return irq_cycles; } if ((m_IFR & 0x20) && (m_imr & 0x20)) { /* Serial port transmit IRQ (internal) */ -// logerror("TMS320C2x: Active XINT (Serial transmit)\n"); + //logerror("TMS320C2x: Active XINT (Serial transmit)\n"); m_dx_out(m_dxr); m_PC = 0x001C; - m_idle = 0; + m_idle = false; m_IFR &= (~0x20); SET0(INTM_FLAG); - return m_tms320c2x_irq_cycles; + return irq_cycles; } } - return m_tms320c2x_irq_cycles; + return 0; } @@ -1950,26 +1918,23 @@ inline void tms320c2x_device::process_timer(int clocks) void tms320c2x_device::execute_run() { /**** Respond to external hold signal */ - if (m_hold_in() == ASSERT_LINE) { - if (m_hold == 0) { - m_hold_ack_out(ASSERT_LINE); /* Hold-Ack (active low) */ - } - m_hold = 1; - if (HM) { - m_icount = 0; /* Exit */ - } - else { - if (m_external_mem_access) { + if (!m_hold_in.isunset()) { + if (m_hold_in() == ASSERT_LINE) { + if (!m_hold) { + m_hold_ack_out(ASSERT_LINE); /* Hold-Ack (active low) */ + m_hold = true; + } + + if (HM || is_mem_access_external()) { m_icount = 0; /* Exit */ + return; } } - } - else { - if (m_hold == 1) { + else if (m_hold) { m_hold_ack_out(CLEAR_LINE); /* Hold-Ack (active low) */ process_timer(3); + m_hold = false; } - m_hold = 0; } /**** If idling, update timer and/or exit execution, but test for irqs first */ @@ -2030,33 +1995,24 @@ void tms320c2x_device::execute_run() m_opcode.d = m_cache.read_word(m_PC); m_PC++; - m_tms320c2x_dec_cycles += (1*CLK); - - do { - if (m_opcode.b.h == 0xCE) - { /* Do all 0xCExx Opcodes */ - if (m_init_load_addr) { - m_tms320c2x_dec_cycles += (1*CLK); - } - else { - m_tms320c2x_dec_cycles += (1*CLK); - } - (this->*s_opcode_CE_subset[m_opcode.b.l].function)(); - } - else - { /* Do all other opcodes */ - if (m_init_load_addr) { - m_tms320c2x_dec_cycles += (1*CLK); - } - else { - m_tms320c2x_dec_cycles += (1*CLK); - } - (this->*s_opcode_main[m_opcode.b.h].function)(); - } - m_init_load_addr = 0; + m_tms320c2x_dec_cycles += (m_RPTC+2) * CLK; + + opcode_func op_func; + if (m_opcode.b.h == 0xCE) + /* Do all 0xCExx Opcodes */ + op_func = s_opcode_CE_subset[m_opcode.b.l].function; + else + /* Do all other opcodes */ + op_func = s_opcode_main[m_opcode.b.h].function; + + (this->*op_func)(); + m_init_load_addr = 0; + + while (m_RPTC != 0) { + (this->*op_func)(); m_RPTC--; - } while ((int8_t)(m_RPTC) != -1); - m_RPTC = 0; + } + m_PFC = m_PC; m_init_load_addr = 1; } @@ -2070,10 +2026,11 @@ void tms320c2x_device::execute_run() /**** If hold pin is active, exit if accessing external memory or if HM is set */ if (m_hold) { - if (m_external_mem_access || (HM)) { + if (is_mem_access_external() || HM) { if (m_icount > 0) { m_icount = 0; } + return; } } } @@ -2086,10 +2043,10 @@ void tms320c2x_device::execute_run() ****************************************************************************/ void tms320c2x_device::execute_set_input(int irqline, int state) { - if ( irqline == TMS320C2X_FSX ) { + if (irqline == TMS320C2X_FSX) { if (state != CLEAR_LINE && m_waiting_for_serial_frame) { - m_waiting_for_serial_frame = 0; + m_waiting_for_serial_frame = false; m_IFR = 0x20; } } diff --git a/src/devices/cpu/tms320c2x/tms320c2x.h b/src/devices/cpu/tms320c2x/tms320c2x.h index 513b6bd7c0be2..61608650efde0 100644 --- a/src/devices/cpu/tms320c2x/tms320c2x.h +++ b/src/devices/cpu/tms320c2x/tms320c2x.h @@ -139,32 +139,30 @@ class tms320c2x_device : public cpu_device uint16_t m_STR0, m_STR1; uint8_t m_IFR; uint8_t m_RPTC; - PAIR m_ACC; - PAIR m_Preg; + PAIR m_ACC; + PAIR m_Preg; uint16_t m_Treg; uint16_t m_AR[8]; // 5 for TMS32020, 8 for rest uint16_t m_STACK[8]; // 4 level for TMS32020, 8 level for rest - PAIR m_ALU; + PAIR m_ALU; uint16_t m_drr, m_dxr, m_tim, m_prd, m_imr, m_greg; - uint16_t m_fixed_STR1; + uint16_t m_fixed_STR1; uint8_t m_timerover; /********************** Status data ****************************/ PAIR m_opcode; - int m_idle; - int m_hold; - int m_external_mem_access; /** required for hold mode. Implement it ! */ + bool m_idle; + bool m_hold; int m_init_load_addr; /* 0=No, 1=Yes, 2=Once for repeat mode */ - int m_tms320c2x_irq_cycles; int m_tms320c2x_dec_cycles; - PAIR m_oldacc; + PAIR m_oldacc; uint32_t m_memaccess; - int m_icount; - int m_mHackIgnoreARP; /* special handling for lst, lst1 instructions */ - int m_waiting_for_serial_frame; + bool is_mem_access_external() { return m_memaccess >= 0x800; } + int m_icount; + bool m_waiting_for_serial_frame; uint16_t drr_r(); void drr_w(uint16_t data); @@ -186,8 +184,8 @@ class tms320c2x_device : public cpu_device void MODIFY_DP(int data); void MODIFY_PM(int data); void MODIFY_ARP(int data); - uint16_t reverse_carry_add(uint16_t arg0, uint16_t arg1 ); - void MODIFY_AR_ARP(); + uint16_t reverse_carry_add(uint16_t arg0, uint16_t arg1); + template void MODIFY_AR_ARP(); void CALCULATE_ADD_CARRY(); void CALCULATE_SUB_CARRY(); void CALCULATE_ADD_OVERFLOW(int32_t addval); @@ -195,9 +193,11 @@ class tms320c2x_device : public cpu_device uint16_t POP_STACK(); void PUSH_STACK(uint16_t data); void SHIFT_Preg_TO_ALU(); - void GETDATA(int shift,int signext); + template void GETDATA(); + void GETDATA(int shift, int signext); void PUTDATA(uint16_t data); void PUTDATA_SST(uint16_t data); + void opcodes_CE(); void opcodes_Dx(); void illegal(); @@ -250,22 +250,8 @@ class tms320c2x_device : public cpu_device void lack(); void lact(); void lalk(); - void lar_ar0(); - void lar_ar1(); - void lar_ar2(); - void lar_ar3(); - void lar_ar4(); - void lar_ar5(); - void lar_ar6(); - void lar_ar7(); - void lark_ar0(); - void lark_ar1(); - void lark_ar2(); - void lark_ar3(); - void lark_ar4(); - void lark_ar5(); - void lark_ar6(); - void lark_ar7(); + template void lar_ar(); + template void lark_ar(); void ldp(); void ldpk(); void lph(); @@ -310,14 +296,7 @@ class tms320c2x_device : public cpu_device void rxf(); void sach(); void sacl(); - void sar_ar0(); - void sar_ar1(); - void sar_ar2(); - void sar_ar3(); - void sar_ar4(); - void sar_ar5(); - void sar_ar6(); - void sar_ar7(); + template void sar_ar(); void sblk(); void sbrk_ar(); void sc(); @@ -353,6 +332,7 @@ class tms320c2x_device : public cpu_device void zalh(); void zalr(); void zals(); + int process_IRQs(); void process_timer(int clocks); }; diff --git a/src/mame/misc/coolpool.cpp b/src/mame/misc/coolpool.cpp index 924316c240052..4087a60d732b7 100644 --- a/src/mame/misc/coolpool.cpp +++ b/src/mame/misc/coolpool.cpp @@ -174,7 +174,6 @@ class _9ballsht_state : public coolpool_base_state void misc_w(uint16_t data); uint16_t dsp_bio_line_r(); - uint16_t dsp_hold_line_r(); TMS340X0_SCANLINE_RGB32_CB_MEMBER(scanline); @@ -627,13 +626,6 @@ uint16_t _9ballsht_state::dsp_bio_line_r() return m_main2dsp->pending_r() ? CLEAR_LINE : ASSERT_LINE; } - -uint16_t _9ballsht_state::dsp_hold_line_r() -{ - return CLEAR_LINE; // ??? -} - - /************************************* * * IOP ROM and DAC access @@ -985,8 +977,8 @@ void _9ballsht_state::_9ballsht(machine_config &config) dsp.set_addrmap(AS_PROGRAM, &_9ballsht_state::dsp_pgm_map); dsp.set_addrmap(AS_IO, &_9ballsht_state::nballsht_dsp_io_map); dsp.bio_in_cb().set(FUNC(_9ballsht_state::dsp_bio_line_r)); - dsp.hold_in_cb().set(FUNC(_9ballsht_state::dsp_hold_line_r)); -// dsp.hold_ack_out_cb().set(FUNC(_9ballsht_state::dsp_HOLDA_signal_w)); + //dsp.hold_in_cb().set(FUNC(_9ballsht_state::dsp_hold_line_r)); + //dsp.hold_ack_out_cb().set(FUNC(_9ballsht_state::dsp_HOLDA_signal_w)); GENERIC_LATCH_16(config, m_main2dsp); // ??? I have no idea who should generate this! diff --git a/src/mame/namco/namcos21_dsp.cpp b/src/mame/namco/namcos21_dsp.cpp index 4119934ffaa57..074ba8558ce00 100644 --- a/src/mame/namco/namcos21_dsp.cpp +++ b/src/mame/namco/namcos21_dsp.cpp @@ -264,7 +264,6 @@ void namcos21_dsp_device::device_add_mconfig(machine_config &config) dsp.set_addrmap(AS_DATA, &namcos21_dsp_device::winrun_dsp_data); dsp.set_addrmap(AS_IO, &namcos21_dsp_device::winrun_dsp_io); dsp.bio_in_cb().set(FUNC(namcos21_dsp_device::winrun_poly_reset_r)); - dsp.hold_in_cb().set_constant(0); dsp.hold_ack_out_cb().set_nop(); dsp.xf_out_cb().set_nop(); } diff --git a/src/mame/namco/namcos21_dsp_c67.cpp b/src/mame/namco/namcos21_dsp_c67.cpp index 6e4b5567f62e3..9db1385f42b65 100644 --- a/src/mame/namco/namcos21_dsp_c67.cpp +++ b/src/mame/namco/namcos21_dsp_c67.cpp @@ -129,7 +129,6 @@ void namcos21_dsp_c67_device::device_add_mconfig(machine_config &config) dspmaster.set_addrmap(AS_PROGRAM, &namcos21_dsp_c67_device::master_dsp_program); dspmaster.set_addrmap(AS_DATA, &namcos21_dsp_c67_device::master_dsp_data); dspmaster.set_addrmap(AS_IO, &namcos21_dsp_c67_device::master_dsp_io); - dspmaster.hold_in_cb().set_constant(0); dspmaster.hold_ack_out_cb().set_nop(); dspmaster.xf_out_cb().set(FUNC(namcos21_dsp_c67_device::dsp_xf_w)); diff --git a/src/mame/namco/namcos22.cpp b/src/mame/namco/namcos22.cpp index 3e2ef606d091d..b19617ae5da3c 100644 --- a/src/mame/namco/namcos22.cpp +++ b/src/mame/namco/namcos22.cpp @@ -2242,22 +2242,6 @@ void namcos22_state::pdp_handle_commands(u16 offs) } } -u16 namcos22_state::dsp_hold_signal_r() -{ - /* STUB */ - return 0; -} - -void namcos22_state::dsp_hold_ack_w(u16 data) -{ - /* STUB */ -} - -void namcos22_state::dsp_xf_output_w(u16 data) -{ - /* STUB */ -} - void namcos22_state::dsp_unk2_w(u16 data) { /** @@ -3760,9 +3744,9 @@ void namcos22_state::namcos22(machine_config &config) master.set_addrmap(AS_DATA, &namcos22_state::master_dsp_data); master.set_addrmap(AS_IO, &namcos22_state::master_dsp_io); master.bio_in_cb().set(FUNC(namcos22_state::pdp_status_r)); - master.hold_in_cb().set(FUNC(namcos22_state::dsp_hold_signal_r)); - master.hold_ack_out_cb().set(FUNC(namcos22_state::dsp_hold_ack_w)); - master.xf_out_cb().set(FUNC(namcos22_state::dsp_xf_output_w)); + //master.hold_in_cb().set(FUNC(namcos22_state::dsp_hold_signal_r)); + //master.hold_ack_out_cb().set(FUNC(namcos22_state::dsp_hold_ack_w)); + //master.xf_out_cb().set(FUNC(namcos22_state::dsp_xf_output_w)); master.dr_in_cb().set(FUNC(namcos22_state::master_serial_io_r)); master.set_vblank_int("screen", FUNC(namcos22_state::dsp_vblank_irq)); TIMER(config, "dsp_serial").configure_periodic(FUNC(namcos22_state::dsp_serial_pulse), attotime::from_hz(SERIAL_IO_PERIOD)); @@ -3772,9 +3756,9 @@ void namcos22_state::namcos22(machine_config &config) slave.set_addrmap(AS_DATA, &namcos22_state::slave_dsp_data); slave.set_addrmap(AS_IO, &namcos22_state::slave_dsp_io); slave.bio_in_cb().set(FUNC(namcos22_state::dsp_slave_bioz_r)); - slave.hold_in_cb().set(FUNC(namcos22_state::dsp_hold_signal_r)); - slave.hold_ack_out_cb().set(FUNC(namcos22_state::dsp_hold_ack_w)); - slave.xf_out_cb().set(FUNC(namcos22_state::dsp_xf_output_w)); + //slave.hold_in_cb().set(FUNC(namcos22_state::dsp_hold_signal_r)); + //slave.hold_ack_out_cb().set(FUNC(namcos22_state::dsp_hold_ack_w)); + //slave.xf_out_cb().set(FUNC(namcos22_state::dsp_xf_output_w)); slave.dx_out_cb().set(FUNC(namcos22_state::slave_serial_io_w)); NAMCO_C74(config, m_mcu, 49.152_MHz_XTAL/3); // C74 on the CPU board has no periodic interrupts, it runs entirely off Timer A0 diff --git a/src/mame/namco/namcos22.h b/src/mame/namco/namcos22.h index 4e61c790f5723..becc7b9cf45d2 100644 --- a/src/mame/namco/namcos22.h +++ b/src/mame/namco/namcos22.h @@ -289,9 +289,6 @@ class namcos22_state : public driver_device void namcos22_dspram16_w(offs_t offset, u16 data, u16 mem_mask = ~0); u16 pdp_status_r(); u16 pdp_begin_r(); - u16 dsp_hold_signal_r(); - void dsp_hold_ack_w(u16 data); - void dsp_xf_output_w(u16 data); void point_address_w(u16 data); void point_loword_iw(u16 data); void point_hiword_w(u16 data); From 87afcf8db7502834d5e569b511836ba7241c2bb4 Mon Sep 17 00:00:00 2001 From: FlykeSpice Date: Mon, 2 Feb 2026 15:19:35 -0400 Subject: [PATCH 2/4] Address PR feedback & reformat most casts to C++ style --- src/devices/cpu/tms320c2x/tms320c2x.cpp | 144 ++++++++++++------------ 1 file changed, 70 insertions(+), 74 deletions(-) diff --git a/src/devices/cpu/tms320c2x/tms320c2x.cpp b/src/devices/cpu/tms320c2x/tms320c2x.cpp index ef27a9a38e343..94e5b062306e2 100644 --- a/src/devices/cpu/tms320c2x/tms320c2x.cpp +++ b/src/devices/cpu/tms320c2x/tms320c2x.cpp @@ -499,7 +499,7 @@ inline void tms320c2x_device::CALCULATE_SUB_OVERFLOW(int32_t subval) inline uint16_t tms320c2x_device::POP_STACK() { uint16_t const data = m_STACK[m_stack_limit]; - for (unsigned i = m_stack_limit; i > 0; --i) + for (unsigned i = m_stack_limit; 0 < i; --i) m_STACK[i] = m_STACK[i - 1]; return data; } @@ -524,7 +524,7 @@ inline void tms320c2x_device::SHIFT_Preg_TO_ALU() } template -inline void tms320c2x_device::GETDATA() +inline void tms320c2x_device::GETDATA(int shift, int signext) { if (m_opcode.b.l & 0x80) { /* indirect memory access */ @@ -537,18 +537,12 @@ inline void tms320c2x_device::GETDATA() m_ALU.d = (uint16_t)m_data.read_word(m_memaccess); + if (signext) m_ALU.d = (int16_t)m_ALU.d; + m_ALU.d <<= shift; + /* next ARP */ if (m_opcode.b.l & 0x80) MODIFY_AR_ARP(); -} - -inline void tms320c2x_device::GETDATA(int shift, int signext) -{ - GETDATA(); - - if (signext) - m_ALU.d = (int16_t)m_ALU.d; - m_ALU.d <<= shift; } inline void tms320c2x_device::PUTDATA(uint16_t data) @@ -594,7 +588,7 @@ void tms320c2x_device::illegal() void tms320c2x_device::abst() { - if ((int32_t)m_ACC.d < 0) { + if (int32_t(m_ACC.d) < 0) { m_ACC.d = -m_ACC.d; if (m_ACC.d == 0x80000000) { SET0(OV_FLAG); @@ -614,7 +608,7 @@ void tms320c2x_device::add() void tms320c2x_device::addc() { m_oldacc.d = m_ACC.d; - GETDATA(); + GETDATA(0, 0); if (CARRY) m_ACC.d++; m_ACC.d += m_ALU.d; CALCULATE_ADD_OVERFLOW(m_ALU.d); @@ -624,14 +618,14 @@ void tms320c2x_device::addc() void tms320c2x_device::addh() { m_oldacc.d = m_ACC.d; - GETDATA(); + GETDATA(0, 0); m_ACC.w.h += m_ALU.w.l; - if ((uint16_t)m_oldacc.w.h > (uint16_t)m_ACC.w.h) { + if (uint16_t(m_oldacc.w.h) > uint16_t(m_ACC.w.h)) { SET1(C_FLAG); /* Carry flag is not cleared, if no carry occurred */ } if (int16_t((m_ACC.w.h ^ m_ALU.w.l) & (m_oldacc.w.h ^ m_ACC.w.h)) < 0) { SET0(OV_FLAG); - if (OVM) m_ACC.w.h = ((int16_t)m_oldacc.w.h < 0) ? 0x8000 : 0x7fff; + if (OVM) m_ACC.w.h = (int16_t(m_oldacc.w.h) < 0) ? 0x8000 : 0x7fff; } } void tms320c2x_device::addk() @@ -645,7 +639,7 @@ void tms320c2x_device::addk() void tms320c2x_device::adds() { m_oldacc.d = m_ACC.d; - GETDATA(); + GETDATA(0, 0); m_ACC.d += m_ALU.d; CALCULATE_ADD_OVERFLOW(m_ALU.d); CALCULATE_ADD_CARRY(); @@ -675,7 +669,7 @@ void tms320c2x_device::adrk() } void tms320c2x_device::and_() { - GETDATA(); + GETDATA(0, 0); m_ACC.d &= m_ALU.d; } void tms320c2x_device::andk() @@ -729,13 +723,13 @@ void tms320c2x_device::bc() } void tms320c2x_device::bgez() { - if ((int32_t)m_ACC.d >= 0) m_PC = m_cache.read_word(m_PC); + if (int32_t(m_ACC.d) >= 0) m_PC = m_cache.read_word(m_PC); else m_PC++; MODIFY_AR_ARP(); } void tms320c2x_device::bgz() { - if ((int32_t)m_ACC.d > 0) m_PC = m_cache.read_word(m_PC); + if (int32_t(m_ACC.d) > 0) m_PC = m_cache.read_word(m_PC); else m_PC++; MODIFY_AR_ARP(); } @@ -747,19 +741,19 @@ void tms320c2x_device::bioz() } void tms320c2x_device::bit() { - GETDATA(); + GETDATA(0, 0); if (m_ALU.d & (0x8000 >> (m_opcode.b.h & 0xf))) SET1(TC_FLAG); else CLR1(TC_FLAG); } void tms320c2x_device::bitt() { - GETDATA(); + GETDATA(0, 0); if (m_ALU.d & (0x8000 >> (m_Treg & 0xf))) SET1(TC_FLAG); else CLR1(TC_FLAG); } void tms320c2x_device::blez() { - if ((int32_t)m_ACC.d <= 0) m_PC = m_cache.read_word(m_PC); + if (int32_t(m_ACC.d) <= 0) m_PC = m_cache.read_word(m_PC); else m_PC++; MODIFY_AR_ARP(); } @@ -787,7 +781,7 @@ void tms320c2x_device::blkp() } void tms320c2x_device::blz() { - if ((int32_t)m_ACC.d < 0) m_PC = m_cache.read_word(m_PC); + if (int32_t(m_ACC.d) < 0) m_PC = m_cache.read_word(m_PC); else m_PC++; MODIFY_AR_ARP(); } @@ -848,19 +842,19 @@ void tms320c2x_device::cmpr() switch (m_opcode.b.l & 3) { case 0: - if (m_AR[ARP] == m_AR[0]) SET1(TC_FLAG); + if (uint16_t(m_AR[ARP]) == uint16_t(m_AR[0])) SET1(TC_FLAG); else CLR1(TC_FLAG); break; case 1: - if (m_AR[ARP] < m_AR[0]) SET1(TC_FLAG); + if (uint16_t(m_AR[ARP]) < uint16_t(m_AR[0])) SET1(TC_FLAG); else CLR1(TC_FLAG); break; case 2: - if (m_AR[ARP] > m_AR[0]) SET1(TC_FLAG); + if (uint16_t(m_AR[ARP]) > uint16_t(m_AR[0])) SET1(TC_FLAG); else CLR1(TC_FLAG); break; case 3: - if (m_AR[ARP] != m_AR[0]) SET1(TC_FLAG); + if (uint16_t(m_AR[ARP]) != uint16_t(m_AR[0])) SET1(TC_FLAG); else CLR1(TC_FLAG); break; } @@ -884,17 +878,17 @@ void tms320c2x_device::cnfp() /** next two fetches need to use previous CNF val void tms320c2x_device::conf() { - // Disabled on tms320c2x + // Disabled on TMS320C2X } void tms320c26_device::cnfd() { - // Disabled on tms320c26 + // Disabled on TMS320C26 } void tms320c26_device::cnfp() { - // Disabled on tms320c26 + // Disabled on TMS320C26 } void tms320c26_device::conf() /** Need to reconfigure the memory blocks */ @@ -942,7 +936,7 @@ void tms320c2x_device::dint() } void tms320c2x_device::dmov() /** Careful with how memory is configured !! */ { - GETDATA(); + GETDATA(0, 0); m_data.write_word(m_memaccess + 1, m_ALU.w.l); } void tms320c2x_device::eint() @@ -988,14 +982,14 @@ void tms320c2x_device::lalk() } template -void tms320c2x_device::lar_ar() { GETDATA(); m_AR[N] = m_ALU.w.l; } +void tms320c2x_device::lar_ar() { GETDATA(0, 0); m_AR[N] = m_ALU.w.l; } template void tms320c2x_device::lark_ar() { m_AR[N] = m_opcode.b.l; } void tms320c2x_device::ldp() { - GETDATA(); + GETDATA(0, 0); MODIFY_DP(m_ALU.d & 0x1ff); } void tms320c2x_device::ldpk() @@ -1004,7 +998,7 @@ void tms320c2x_device::ldpk() } void tms320c2x_device::lph() { - GETDATA(); + GETDATA(0, 0); m_Preg.w.h = m_ALU.w.l; } void tms320c2x_device::lrlk() @@ -1015,7 +1009,7 @@ void tms320c2x_device::lrlk() } void tms320c2x_device::lst() { - GETDATA(); + GETDATA(0, 0); m_ALU.w.l &= (~INTM_FLAG); m_STR0 &= INTM_FLAG; @@ -1024,7 +1018,7 @@ void tms320c2x_device::lst() } void tms320c2x_device::lst1() { - GETDATA(); + GETDATA(0, 0); m_STR1 = m_ALU.w.l | m_fixed_STR1; m_STR0 &= (~ARP_REG); /* ARB also gets copied to ARP */ @@ -1032,13 +1026,13 @@ void tms320c2x_device::lst1() } void tms320c2x_device::lt() { - GETDATA(); + GETDATA(0, 0); m_Treg = m_ALU.w.l; } void tms320c2x_device::lta() { m_oldacc.d = m_ACC.d; - GETDATA(); + GETDATA(0, 0); m_Treg = m_ALU.w.l; SHIFT_Preg_TO_ALU(); m_ACC.d += m_ALU.d; @@ -1048,7 +1042,7 @@ void tms320c2x_device::lta() void tms320c2x_device::ltd() /** Careful with how memory is configured !! */ { m_oldacc.d = m_ACC.d; - GETDATA(); + GETDATA(0, 0); m_Treg = m_ALU.w.l; m_data.write_word(m_memaccess+1, m_ALU.w.l); SHIFT_Preg_TO_ALU(); @@ -1059,7 +1053,7 @@ void tms320c2x_device::ltd() /** Careful with how memory is configured !! */ void tms320c2x_device::ltp() { m_oldacc.d = m_ACC.d; - GETDATA(); + GETDATA(0, 0); m_Treg = m_ALU.w.l; SHIFT_Preg_TO_ALU(); m_ACC.d = m_ALU.d; @@ -1067,7 +1061,7 @@ void tms320c2x_device::ltp() void tms320c2x_device::lts() { m_oldacc.d = m_ACC.d; - GETDATA(); + GETDATA(0, 0); m_Treg = m_ALU.w.l; SHIFT_Preg_TO_ALU(); m_ACC.d -= m_ALU.d; @@ -1085,9 +1079,9 @@ void tms320c2x_device::mac() /** RAM blocks B0,B1,B2 may be important m_ACC.d += m_ALU.d; CALCULATE_ADD_OVERFLOW(m_ALU.d); CALCULATE_ADD_CARRY(); - GETDATA(); + GETDATA(0, 0); m_Treg = m_ALU.w.l; - m_Preg.d = (int16_t)m_ALU.w.l * (int16_t)m_cache.read_word(m_PFC); + m_Preg.d = int16_t(m_ALU.w.l) * int16_t(m_cache.read_word(m_PFC)); m_PFC++; m_tms320c2x_dec_cycles += (2*CLK); } @@ -1102,12 +1096,12 @@ void tms320c2x_device::macd() /** RAM blocks B0,B1,B2 may be important m_ACC.d += m_ALU.d; CALCULATE_ADD_OVERFLOW(m_ALU.d); CALCULATE_ADD_CARRY(); - GETDATA(); + GETDATA(0, 0); if ((m_opcode.b.l & 0x80) || m_init_load_addr) { /* No writing during repetition, or DMA mode */ m_data.write_word(m_memaccess+1, m_ALU.w.l); } m_Treg = m_ALU.w.l; - m_Preg.d = (int16_t)m_ALU.w.l * (int16_t)m_cache.read_word(m_PFC); + m_Preg.d = int16_t(m_ALU.w.l) * int16_t(m_cache.read_word(m_PFC)); m_PFC++; m_tms320c2x_dec_cycles += (2*CLK); } @@ -1117,8 +1111,8 @@ void tms320c2x_device::mar() /* LARP and NOP are a subset of this instruct } void tms320c2x_device::mpy() { - GETDATA(); - m_Preg.d = (int16_t)m_ALU.w.l * (int16_t)m_Treg; + GETDATA(0, 0); + m_Preg.d = int16_t(m_ALU.w.l) * int16_t(m_Treg); } void tms320c2x_device::mpya() { @@ -1127,12 +1121,12 @@ void tms320c2x_device::mpya() m_ACC.d += m_ALU.d; CALCULATE_ADD_OVERFLOW(m_ALU.d); CALCULATE_ADD_CARRY(); - GETDATA(); - m_Preg.d = (int16_t)m_ALU.w.l * (int16_t)m_Treg; + GETDATA(0, 0); + m_Preg.d = int16_t(m_ALU.w.l) * int16_t(m_Treg); } void tms320c2x_device::mpyk() { - m_Preg.d = (int16_t)m_Treg * (int16_t(m_opcode.w.l << 3) >> 3); + m_Preg.d = int16_t(m_Treg) * (int16_t(m_opcode.w.l << 3) >> 3); } void tms320c2x_device::mpys() { @@ -1141,13 +1135,13 @@ void tms320c2x_device::mpys() m_ACC.d -= m_ALU.d; CALCULATE_SUB_OVERFLOW(m_ALU.d); CALCULATE_SUB_CARRY(); - GETDATA(); - m_Preg.d = (int16_t)m_ALU.w.l * (int16_t)m_Treg; + GETDATA(0, 0); + m_Preg.d = int16_t(m_ALU.w.l) * int16_t(m_Treg); } void tms320c2x_device::mpyu() { - GETDATA(); - m_Preg.d = (uint16_t)m_ALU.w.l * (uint16_t)m_Treg; + GETDATA(0, 0); + m_Preg.d = uint16_t(m_ALU.w.l) * uint16_t(m_Treg); } void tms320c2x_device::neg() { @@ -1174,7 +1168,7 @@ void tms320c2x_device::norm() } void tms320c2x_device::or_() { - GETDATA(); + GETDATA(0, 0); m_ACC.w.l |= m_ALU.w.l; } void tms320c2x_device::ork() @@ -1186,7 +1180,7 @@ void tms320c2x_device::ork() } void tms320c2x_device::out() { - GETDATA(); + GETDATA(0, 0); m_io.write_word(m_opcode.b.h & 0xf, m_ALU.w.l ); } void tms320c2x_device::pac() @@ -1205,7 +1199,7 @@ void tms320c2x_device::popd() } void tms320c2x_device::pshd() { - GETDATA(); + GETDATA(0, 0); PUSH_STACK(m_ALU.w.l); } void tms320c2x_device::push() @@ -1250,7 +1244,7 @@ void tms320c2x_device::rovm() } void tms320c2x_device::rpt() { - GETDATA(); + GETDATA(0, 0); m_RPTC = m_ALU.b.l; m_init_load_addr = 2; /* Initiate repeat mode */ } @@ -1367,9 +1361,9 @@ void tms320c2x_device::sqra() m_ACC.d += m_ALU.d; CALCULATE_ADD_OVERFLOW(m_ALU.d); CALCULATE_ADD_CARRY(); - GETDATA(); + GETDATA(0, 0); m_Treg = m_ALU.w.l; - m_Preg.d = (int16_t)m_ALU.w.l * (int16_t)m_ALU.w.l; + m_Preg.d = int16_t(m_ALU.w.l) * int16_t(m_ALU.w.l); } void tms320c2x_device::sqrs() { @@ -1378,9 +1372,9 @@ void tms320c2x_device::sqrs() m_ACC.d -= m_ALU.d; CALCULATE_SUB_OVERFLOW(m_ALU.d); CALCULATE_SUB_CARRY(); - GETDATA(); + GETDATA(0, 0); m_Treg = m_ALU.w.l; - m_Preg.d = (int16_t)m_ALU.w.l * (int16_t)m_ALU.w.l; + m_Preg.d = int16_t(m_ALU.w.l) * int16_t(m_ALU.w.l); } void tms320c2x_device::sst() { @@ -1413,7 +1407,7 @@ void tms320c2x_device::sub() void tms320c2x_device::subb() { m_oldacc.d = m_ACC.d; - GETDATA(); + GETDATA(0, 0); if (CARRY == 0) m_ACC.d--; m_ACC.d -= m_ALU.d; CALCULATE_SUB_OVERFLOW(m_ALU.d); @@ -1441,14 +1435,14 @@ void tms320c2x_device::subc() void tms320c2x_device::subh() { m_oldacc.d = m_ACC.d; - GETDATA(); + GETDATA(0, 0); m_ACC.w.h -= m_ALU.w.l; - if ((uint16_t)m_oldacc.w.h < (uint16_t)m_ACC.w.h) { + if (uint16_t(m_oldacc.w.h) < uint16_t(m_ACC.w.h)) { CLR1(C_FLAG); /* Carry flag is not affected, if no borrow occurred */ } if (int16_t((m_oldacc.w.h ^ m_ALU.w.l) & (m_oldacc.w.h ^ m_ACC.w.h)) < 0) { SET0(OV_FLAG); - if (OVM) m_ACC.w.h = ((int16_t)m_oldacc.w.h < 0) ? 0x8000 : 0x7fff; + if (OVM) m_ACC.w.h = (int16_t(m_oldacc.w.h) < 0) ? 0x8000 : 0x7fff; } } void tms320c2x_device::subk() @@ -1462,7 +1456,7 @@ void tms320c2x_device::subk() void tms320c2x_device::subs() { m_oldacc.d = m_ACC.d; - GETDATA(); + GETDATA(0, 0); m_ACC.d -= m_ALU.w.l; CALCULATE_SUB_OVERFLOW(m_ALU.d); CALCULATE_SUB_CARRY(); @@ -1486,7 +1480,7 @@ void tms320c2x_device::tblr() m_PFC = m_ACC.w.l; } m_ALU.w.l = m_cache.read_word(m_PFC); - if (CNF0 && (uint16_t)m_PFC >= 0xff00) {} /** TMS320C25 only */ + if (CNF0 && (uint16_t(m_PFC) >= 0xff00)) {} /** TMS320C25 only */ else m_tms320c2x_dec_cycles += (1*CLK); PUTDATA(m_ALU.w.l); m_PFC++; @@ -1497,7 +1491,7 @@ void tms320c2x_device::tblw() m_PFC = m_ACC.w.l; } m_tms320c2x_dec_cycles += (1*CLK); - GETDATA(); + GETDATA(0, 0); if (is_mem_access_external()) m_tms320c2x_dec_cycles += (1*CLK); m_program.write_word(m_PFC, m_ALU.w.l); m_PFC++; @@ -1509,7 +1503,7 @@ void tms320c2x_device::trap() } void tms320c2x_device::xor_() { - GETDATA(); + GETDATA(0, 0); m_ACC.w.l ^= m_ALU.w.l; } void tms320c2x_device::xork() @@ -1521,19 +1515,19 @@ void tms320c2x_device::xork() } void tms320c2x_device::zalh() { - GETDATA(); + GETDATA(0, 0); m_ACC.w.h = m_ALU.w.l; m_ACC.w.l = 0x0000; } void tms320c2x_device::zalr() { - GETDATA(); + GETDATA(0, 0); m_ACC.w.h = m_ALU.w.l; m_ACC.w.l = 0x8000; } void tms320c2x_device::zals() { - GETDATA(); + GETDATA(0, 0); m_ACC.w.l = m_ALU.w.l; m_ACC.w.h = 0x0000; } @@ -1873,6 +1867,8 @@ inline int tms320c2x_device::process_IRQs() SET0(INTM_FLAG); return irq_cycles; } + + fatalerror("TMS320C2x: IRQ fallthrough (IFR=%02x IMR=%02x PC=%04x)\n", m_IFR, m_imr, m_PC); } return 0; } From d1cc809c6565da4c0cc844ad840558d0f6df1e89 Mon Sep 17 00:00:00 2001 From: FlykeSpice Date: Mon, 2 Feb 2026 17:44:27 -0400 Subject: [PATCH 3/4] Oops, forgot to include header changes too --- src/devices/cpu/tms320c2x/tms320c2x.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/devices/cpu/tms320c2x/tms320c2x.h b/src/devices/cpu/tms320c2x/tms320c2x.h index 61608650efde0..5800ca7696ab1 100644 --- a/src/devices/cpu/tms320c2x/tms320c2x.h +++ b/src/devices/cpu/tms320c2x/tms320c2x.h @@ -193,8 +193,7 @@ class tms320c2x_device : public cpu_device uint16_t POP_STACK(); void PUSH_STACK(uint16_t data); void SHIFT_Preg_TO_ALU(); - template void GETDATA(); - void GETDATA(int shift, int signext); + template void GETDATA(int shift, int signext); void PUTDATA(uint16_t data); void PUTDATA_SST(uint16_t data); From a2a75aefb3bae1eadeaa48755d4c11812e8e7e55 Mon Sep 17 00:00:00 2001 From: FlykeSpice Date: Mon, 2 Feb 2026 21:13:53 -0400 Subject: [PATCH 4/4] Restart CI --- src/devices/cpu/tms320c2x/tms320c2x.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/devices/cpu/tms320c2x/tms320c2x.cpp b/src/devices/cpu/tms320c2x/tms320c2x.cpp index 94e5b062306e2..6a7164796487b 100644 --- a/src/devices/cpu/tms320c2x/tms320c2x.cpp +++ b/src/devices/cpu/tms320c2x/tms320c2x.cpp @@ -542,7 +542,6 @@ inline void tms320c2x_device::GETDATA(int shift, int signext) /* next ARP */ if (m_opcode.b.l & 0x80) MODIFY_AR_ARP(); - } inline void tms320c2x_device::PUTDATA(uint16_t data)