m6809/konami: no need for those safe_shift functions

This commit is contained in:
hap 2022-12-15 13:35:57 +01:00
parent c23cebc36c
commit 0a58d76509
3 changed files with 20 additions and 91 deletions

View file

@ -237,58 +237,6 @@ inline void konami_cpu_device::write_exgtfr_register(uint8_t reg, uint16_t value
}
//-------------------------------------------------
// safe_shift_right
//-------------------------------------------------
template<class T> T konami_cpu_device::safe_shift_right(T value, uint32_t shift)
{
T result;
if (shift < (sizeof(T) * 8))
result = value >> shift;
else if (value < 0)
result = (T) -1;
else
result = 0;
return result;
}
//-------------------------------------------------
// safe_shift_right_unsigned
//-------------------------------------------------
template<class T> T konami_cpu_device::safe_shift_right_unsigned(T value, uint32_t shift)
{
T result;
if (shift < (sizeof(T) * 8))
result = value >> shift;
else
result = 0;
return result;
}
//-------------------------------------------------
// safe_shift_left
//-------------------------------------------------
template<class T> T konami_cpu_device::safe_shift_left(T value, uint32_t shift)
{
T result;
if (shift < (sizeof(T) * 8))
result = value << shift;
else
result = 0;
return result;
}
//-------------------------------------------------
// lmul
//-------------------------------------------------

View file

@ -64,9 +64,6 @@ private:
void divx();
// miscellaneous
template<class T> T safe_shift_right(T value, uint32_t shift);
template<class T> T safe_shift_right_unsigned(T value, uint32_t shift);
template<class T> T safe_shift_left(T value, uint32_t shift);
void set_lines(uint8_t data);
void execute_one();

View file

@ -521,19 +521,15 @@ LSRD:
@m_temp.b.h = read_operand(0);
@m_temp.b.l = read_operand(1);
if (m_bcount != 0x00)
while(m_bcount--)
{
// set C condition code
if (m_temp.w & safe_shift_left(1, m_bcount - 1))
m_cc |= CC_C;
else
m_cc &= ~CC_C;
m_temp.w = set_flags<uint16_t>(CC_NZ, safe_shift_right_unsigned<uint16_t>(m_temp.w, m_bcount));
@write_operand(0, m_temp.b.h);
write_operand(1, m_temp.b.l);
@eat(1);
m_cc &= ~CC_C;
m_cc |= (m_temp.w & 1) ? CC_C : 0;
m_temp.w = set_flags<uint16_t>(CC_NZ, m_temp.w >> 1);
}
eat(m_bcount);
@write_operand(0, m_temp.b.h);
write_operand(1, m_temp.b.l);
return;
ASLD:
@ -546,19 +542,13 @@ ASLD:
@m_temp.b.h = read_operand(0);
@m_temp.b.l = read_operand(1);
if (m_bcount != 0x00)
while(m_bcount--)
{
// set C condition code
if (m_temp.w & safe_shift_right(0x10000, m_bcount))
m_cc |= CC_C;
else
m_cc &= ~CC_C;
m_temp.w = set_flags<uint16_t>(CC_NZV, safe_shift_left<int16_t>(m_temp.w, m_bcount));
@write_operand(0, m_temp.b.h);
write_operand(1, m_temp.b.l);
@eat(1);
m_temp.w = set_flags<uint16_t>(CC_NZVC, m_temp.w, m_temp.w, m_temp.w << 1);
}
eat(m_bcount);
@write_operand(0, m_temp.b.h);
write_operand(1, m_temp.b.l);
return;
ASRD:
@ -571,19 +561,15 @@ ASRD:
@m_temp.b.h = read_operand(0);
@m_temp.b.l = read_operand(1);
if (m_bcount != 0x00)
while(m_bcount--)
{
// set C condition code
if (m_temp.w & safe_shift_left(1, m_bcount - 1))
m_cc |= CC_C;
else
m_cc &= ~CC_C;
m_temp.w = set_flags<uint16_t>(CC_NZ, safe_shift_right<int16_t>(m_temp.w, m_bcount));
@write_operand(0, m_temp.b.h);
write_operand(1, m_temp.b.l);
@eat(1);
m_cc &= ~CC_C;
m_cc |= (m_temp.w & 1) ? CC_C : 0;
m_temp.w = set_flags<uint16_t>(CC_NZ, ((int16_t) m_temp.w) >> 1);
}
eat(m_bcount);
@write_operand(0, m_temp.b.h);
write_operand(1, m_temp.b.l);
return;
ROLD:
@ -596,11 +582,10 @@ ROLD:
@m_temp.b.h = read_operand(0);
@m_temp.b.l = read_operand(1);
// doing this as a loop is lame
while(m_bcount--)
{
@eat(1);
m_temp.w = set_flags<uint16_t>(CC_NZ, rotate_left(m_temp.w));
m_temp.w = set_flags<uint16_t>(CC_NZV, rotate_left(m_temp.w));
}
@write_operand(0, m_temp.b.h);
write_operand(1, m_temp.b.l);
@ -616,7 +601,6 @@ RORD:
@m_temp.b.h = read_operand(0);
@m_temp.b.l = read_operand(1);
// doing this as a loop is lame
while(m_bcount--)
{
@eat(1);