diff options
Diffstat (limited to 'src/mame/machine/k007452.cpp')
-rw-r--r-- | src/mame/machine/k007452.cpp | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/mame/machine/k007452.cpp b/src/mame/machine/k007452.cpp index 3f6a3202d61..20d4ac450af 100644 --- a/src/mame/machine/k007452.cpp +++ b/src/mame/machine/k007452.cpp @@ -30,16 +30,16 @@ k007452_device::k007452_device(const machine_config &mconfig, const char *tag, d // read - read the registers //------------------------------------------------- -uint8_t k007452_device::read(offs_t offset) +u8 k007452_device::read(offs_t offset) { switch (offset & 7) { - case 0: return m_multiply_result & 0xff; - case 1: return (m_multiply_result >> 8) & 0xff; - case 2: return m_divide_remainder & 0xff; - case 3: return (m_divide_remainder >> 8) & 0xff; - case 4: return m_divide_quotient & 0xff; - case 5: return (m_divide_quotient >> 8) & 0xff; + case 0: return u8(m_multiply_result & 0xff); + case 1: return u8((m_multiply_result >> 8) & 0xff); + case 2: return u8(m_divide_remainder & 0xff); + case 3: return u8((m_divide_remainder >> 8) & 0xff); + case 4: return u8(m_divide_quotient & 0xff); + case 5: return u8((m_divide_quotient >> 8) & 0xff); default: return 0; } } @@ -51,22 +51,26 @@ uint8_t k007452_device::read(offs_t offset) void k007452_device::write(offs_t offset, u8 data) { - if (offset < 6) m_math_regs[offset] = data; - + if (offset < 6) + m_math_regs[offset] = data; + if (offset == 1) { // Starts multiplication process - m_multiply_result = m_math_regs[0] * m_math_regs[1]; + m_multiply_result = u16(m_math_regs[0]) * m_math_regs[1]; } else if (offset == 5) { // Starts division process - u16 dividend = (m_math_regs[4]<<8) + m_math_regs[5]; - u16 divisor = (m_math_regs[2]<<8) + m_math_regs[3]; - if (!divisor) { + u16 const dividend = (u16(m_math_regs[4]) << 8) | m_math_regs[5]; + u16 const divisor = (u16(m_math_regs[2]) << 8) | m_math_regs[3]; + if (!divisor) + { m_divide_quotient = 0xffff; m_divide_remainder = 0x0000; - } else { + } + else + { m_divide_quotient = dividend / divisor; m_divide_remainder = dividend % divisor; } @@ -98,4 +102,3 @@ void k007452_device::device_reset() m_divide_quotient = 0; m_divide_remainder = 0; } - |